var CZAJSONP = (function(){ var counter = 0, head, query, key, window = this; function load(url) { var script = document.createElement('script'), done = false; script.src = url; script.async = true; script.onload = script.onreadystatechange = function() { if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) { done = true; script.onload = script.onreadystatechange = null; if ( script && script.parentNode ) { script.parentNode.removeChild( script ); } } }; if ( !head ) { head = document.getElementsByTagName('head')[0]; } head.appendChild( script ); } function jsonp(url, params, callback) { query = "?"; params = params || {}; for ( key in params ) { if ( params.hasOwnProperty(key) ) { query += encodeURIComponent(key) + "=" + encodeURIComponent(params[key]) + "&"; } } var jsonp = "json" + (++counter); window[ jsonp ] = function(data){ callback(data); try { delete window[ jsonp ]; } catch (e) {} window[ jsonp ] = null; }; load(url + query + "callback=" + jsonp); return jsonp; } return { get:jsonp }; }()); var ajaxQueue = {}; function czaAjaxRequest(options) { if (!options || !options['url']) return false; if (!options['type']) options['type'] = 'GET'; if (!options['params']) options['params'] = { }; if (!options['header']) options['header'] = 'Content-Type'; if (!options['header-type']) options['header-type'] = 'application/x-www-form-urlencoded'; if (!options['async']) options['async'] = true; if (!options['onSuccess']) options['onSuccess'] = function(response) { ajaxQueue[options['url']] = 0; }; if (!options['onError']) options['onError'] = function() { ajaxQueue[options['url']] = 0; }; if (!options['data-type']) option['data-type'] = 'html'; ajaxQueue[options['url']] = 1; if (options['data-type'] != 'jsonp') { var xmlHttpReq = false; var self = this; // Mozilla/Safari if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } else if (window.ActiveXObject) {// IE self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open(options['type'], options['url'], options['async']); self.xmlHttpReq.setRequestHeader(options['header'], options['header-type']); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { if (self.xmlHttpReq.status == 200 ) { if (option['data-type'] != 'json') self.xmlHttpReq.responseText = JSON.parse(self.xmlHttpReq.responseText); options['onSuccess'](self.xmlHttpReq.responseText); ajaxQueue[options['url']] = 0; } else { options['onError'](); ajaxQueue[options['url']] = 0; } } } self.xmlHttpReq.send(options['params']); } else { CZAJSONP.get(options['url'], options['params'], options['onSuccess']); } } function czaGetCookie(cname){ var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i