function StoreAPI() { this.domain = "mestore"; this.storedomain = ".store.zoho.com"; this.domainhome = "http://mestore.store.zoho.com"; this.responsetype = "json"; this.apihome = this.domainhome + "/api/public/" + this.responsetype; this.operation = "getcategories"; this.get = function(modulename, id) { var modules = ["getcategories", "getproducts", "getproductdetails", "getsubgroups"]; var callapi = ["getcategories", "getproducts/" + id, "getproductdetails/" + id, "getsubgroups/" + id]; for(var i = 0 ; i < modules.length ; i++) { if(modulename == modules[i]) { this.operation = modulename; var scriptSrc = this.apihome + "/" + callapi[i]; this.constructScript(scriptSrc); } } } this.constructScript = function(scriptSrc) { try { var headArr = document.getElementsByTagName("head"); if(!headArr || headArr.length == 0) { headArr = []; headArr[0] = document.createElement("head"); document.insertBefore(doc.body,headArr[0]); } var opscript = document.createElement("script"); opscript.defer = true; opscript.src = scriptSrc; headArr[0].appendChild(opscript); } catch(e) { } } this.loadData = function(module, output) { handleData(module, output); } } ZohoStore = new StoreAPI(); ZohoStore.constructFormLoadFrame = function(formName, divid, iframecls) { var num = Math.random(); var frameName = "_" + num; var frameId = "ID" + frameName; var bdyframe = document.createElement("iframe"); bdyframe.id = frameId; bdyframe.setAttribute('check', "true"); bdyframe.name = frameName; bdyframe.style.cssText = "display:none;"; bdyframe['onload'] = function(){ZohoStore.constructDisplayCartFrame(bdyframe, divid, iframecls);}; document.getElementsByTagName('body')[0].appendChild(bdyframe); document.forms[formName].target=frameName; } ZohoStore.constructDisplayCartFrame = function(frameobj, divid, iframecls) { if(frameobj.getAttribute('check') == "true") { frameobj.setAttribute('check', 'false'); return; } var divobj = document.getElementById(divid); var displaycarturl = this.domainhome + '/viewcart.na'; var frameclass = "iframecls"; frameclass += (iframecls) ? " " + iframecls : ""; divobj.innerHTML = ''; divobj.style.display='block'; }