//-------------------------------------------------- // Aragon | Peralta Content Management Framework //-------------------------------------------------- /* @date: 01-16-2007 * @author: cho * @notes: common jscript inclde file ***********************************************/ var host_url = 'http://www.grantcardone.com/'; //-------------------------------------------------- // Detect Browsers //-------------------------------------------------- var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i= 5) try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { xmlHttp = false; } } @end @*/ if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); } return xmlHttp; } //-------------------------------------------------- // Do XML Request //-------------------------------------------------- function doRequest(url,ajax_tagid) { if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { try { receiveReq.open("GET", url, true); receiveReq.onreadystatechange=function() { if (receiveReq.readyState==4) { if (ajax_tagid == 'content') ajax_tagid = 'trigger'; Element.update(ajax_tagid,receiveReq.responseText); } } receiveReq.send(null); } catch (e) { alert("xml:http request failure to url "+url); } } } //-------------------------------------------------- // Do LONG XML Request //-------------------------------------------------- function doLongRequest(ajax_url,ajax_params,ajax_tagid) { if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { try { receiveReq.open("POST", ajax_url); receiveReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); receiveReq.send(ajax_params); receiveReq.onreadystatechange=function() { if (receiveReq.readyState==4) { if (ajax_tagid == 'content') ajax_tagid = 'trigger'; Element.update(ajax_tagid,receiveReq.responseText); } } } catch (e) { alert("xml:http request failure to url "+url); } } } //-------------------------------------------------- // Handle Name and Value XML Pairs //-------------------------------------------------- function complainIE(name) { switch(name) { case 'head': var msg = "

  Upgrade to FireFox (HIGHLY RECOMMENDED)

"; return msg; break; case 'alert': if (BrowserDetect.browser == 'Explorer') { var msg = 'ATTENTION: You are using Internet Explorer '+BrowserDetect.version+ "\n\n"+'It is HIGHLY recommended that you upgrade to FireFox and use it'+ ' as your default web-browser.'+"\n\n"+'Aragon | Peralta suggests this to all clients'+ ' because Internet Explorer currently has many open security vulnerabilities which'+ ' can be exploited by mailicious script writers. Since this admin utility gives an authenticated user full administrative control over this website, it would be a very bad thing if the login to this website got into the wrong hands. '+ ' Internet viruses are currently circulating for Internet Explorer that may make it possible for someone to compromise its data; and by doing so, also compromise the security of this website.'+ "\n\n"+'The features of this admin tool will work normally until you upgrade, but we would really appreciated it if you did!'; alert (msg); } return; break; } } //-------------------------------------------------- // Handle Name and Value XML Pairs //-------------------------------------------------- function handleData(name,value) { var update = true; switch(name) { case 'content': return value; break; } if(update) update_element(name,value); return true; } //-------------------------------------------------- // Handle Receiving Response Text for IE //-------------------------------------------------- function handleReceiveRequest(url,ajax_tagid) { // 0 Uninitated // 1 Loading // 2 Loaded // 3 Interactive // 4 Complete if (receiveReq.readyState == 4) { if (receiveReq.responseText) textResponse = receiveReq.responseText; else alert("No XML Response was received"); Element.update(ajax_tagid,textResponse); return textResponse; } return false; mTimer = setTimeout('Element.update(ajax_tagid,textResponse)',10000); } //-------------------------------------------------- // Handle Receiving XML Request for IE //-------------------------------------------------- function handleXMLReceiveRequest(url) { // 0 Uninitated // 1 Loading // 2 Loaded // 3 Interactive // 4 Complete if (receiveReq.readyState == 4) { var xmldoc = receiveReq.responseXML.documentElement; var root_node = xmldoc.getElementsByTagName('root').item(0); var nodes = root_node.childNodes; var n = nodes.length; for (i = 0; i < n; i++) { var node = nodes[i]; var name = node.nodeName; var value = ''; if(node.firstChild) value = node.firstChild.nodeValue; //alert(name + '=' + value); handleData(name,value); } return; } //mTimer = setTimeout('handleReceiveRequest()',10000); } //-------------------------------------------------- // Get Element by ID //-------------------------------------------------- function getElement(id) { var element = 0; if(document.getElementById) { element = document.getElementById(id); } else if (document.all) { element = document.all[id]; } return element; } //-------------------------------------------------- // Ajax Update Content - Edit Mode //-------------------------------------------------- var receiveReq = getXmlHttpRequestObject(); function updateContent(tagid,fname) { var ajax_tagid = tagid; var ajax_fname = fname; if (ajax_tagid == 'content') { var inst = tinyMCE.getInstanceById('content'); var ajax_content = inst.getHTML(); } else { var fieldname = "content-" + ajax_tagid; var ajax_content = document.getElementById(fieldname).value; } /******************************************************************** * Note: ie6+ ie7 do not support Ajax.Updater as of prototype 1.4.0 * ... the xmlhttprequest is sent, but no response code is pulled. * so alas, until there is support for this class, we have to * fool ie into refreshing the updated tag by. * * what sucks even more about this whole situation is that the * innerHTML property doesn't work properly in ie when sending it * fresh html to insert. *********************************************************************/ var ajax_url = '/cms_update_ajax'; var ajax_params = 'file=' + ajax_fname + '&tag=' + ajax_tagid + '&content=' + escape(ajax_content); doLongRequest(ajax_url,ajax_params,ajax_tagid); if (ajax_tagid == 'content') ajax_tagid = 'trigger'; handleReceiveRequest(ajax_url+'?'+ajax_params,ajax_tagid); } //-------------------------------------------------- // Ajax Update Microcart //-------------------------------------------------- function updateCart(tagid,fpage) { var ajax_tagid = tagid; var ajax_fpage = fpage; /******************************************************************** * Note: ie6+ ie7 do not support Ajax.Updater as of prototype 1.4.0 * ... the xmlhttprequest is sent, but no response code is pulled. * so alas, until there is support for this class, we have to * fool ie into refreshing the updated tag by. * * what sucks even more about this whole situation is that the * innerHTML property doesn't work properly in ie when sending it * fresh html to insert. *********************************************************************/ if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version >=6) { var url = host_url + 'microcart_ajax/?div=' + ajax_tagid + '&page=' + ajax_fpage; doRequest(url,'edit-light-c01'); handleReceiveRequest(url,'edit-light-c01'); } else { var url = '/microcart_ajax/?div=' + ajax_tagid + '&page=' + ajax_fpage; var myAjax = new Ajax.Updater( 'edit-light-c01', url, { asynchronous:true, evalScripts:true, method: 'post', onComplete: showResponse, onFailure: reportError }); } } //-------------------------------------------------- // Ajax Update Microcart Summary Screen //-------------------------------------------------- function updateCartSummary(tagid,fpage) { var ajax_tagid = tagid; var ajax_fpage = fpage; /******************************************************************** * Note: ie6+ ie7 do not support Ajax.Updater as of prototype 1.4.0 * ... the xmlhttprequest is sent, but no response code is pulled. * so alas, until there is support for this class, we have to * fool ie into refreshing the updated tag by. * * what sucks even more about this whole situation is that the * innerHTML property doesn't work properly in ie when sending it * fresh html to insert. *********************************************************************/ if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version >=6) { var url = host_url + 'microcart_ajax/?div=' + ajax_tagid + '&page=' + ajax_fpage; doRequest(url,'shoppingcart'); handleReceiveRequest(url,'shoppingcart'); } else { var url = '/microcart_ajax/?div=' + ajax_tagid + '&page=' + ajax_fpage; var myAjax = new Ajax.Updater( 'shoppingcart', url, { asynchronous:true, evalScripts:true, method: 'post', onComplete: showResponse, onFailure: reportError }); } } //-------------------------------------------------- // Ajax Show Response //-------------------------------------------------- function showResponse(req) { //alert('RESPONSE:'+req.responseText); } //-------------------------------------------------- // Ajax Report Error //-------------------------------------------------- function reportError(request) { //alert('Sorry. There was an AJAX System Response error.'); } //-------------------------------------------------- // Make Layer Vis/InVisible //-------------------------------------------------- function toggleLayer(layer,visi) { if(document.getElementById) document.getElementById(layer).style.visibility = visi; else if (document.all) document.all[layer].style.visibility = visi; else if (document.layers) document.layers[layer].visibility = visi; } //-------------------------------------------------- // Swap Image Restore //-------------------------------------------------- function MM_swapImgRestore() { var i,x,a=document.MM_sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i this.beforeLength) && (this.value.length >= this.maxLength) ) this.nextField.focus(); downStrokeField=null; }