if (typeof(defined) == 'undefined' ) var defined = function( obj ) { return (typeof(obj) != 'undefined') ; } if ( !defined(in_array) ) var in_array = function( needle, haystack ) { var found = false ; if (haystack instanceof Array && haystack.length > 0) for ( var i in haystack ) found |= ( haystack[i] == needle ) ; return found ; } if ( !defined(is_array) ) var is_array = function(obj) { return defined(obj) ? obj.constructor.toString().indexOf('Array') != -1 : null ; } // used for escaping the values of ajax POST parameters function postEscape( params ) { var p, v, ret = ''; var p_arr = defined(params) ? params.split('&') : [] ; if ( p_arr.length ) for ( var i in p_arr ) { p = p_arr[i].split('=')[0] ; v = p_arr[i].split('=')[1] ; if (p) ret = ret + '&' + p + '=' + escape(v) ; } return ret; } // used for delayed execution of any function Function.prototype.delayed = function() { var _method = this, args = []; for ( var i=0; i= 4) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) ); } // correct version number for Opera else if (this.isOpera) { if (ua.indexOf('opera/') != -1) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) ); } else { this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) ); } } // correct version number for Konqueror else if (this.isKonqueror) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) ); } // correct version number for iCab else if (this.isIcab) { if (ua.indexOf('icab/') != -1) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) ); } else { this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) ); } } // correct version number for WebTV else if (this.isWebtv) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('webtv/') + 6 ) ); } this.versionMajor = parseInt(this.versionMinor); this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 ); // platform this.isWin = (ua.indexOf('win') != -1); this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1) ); this.isMac = (ua.indexOf('mac') != -1); this.isUnix = (ua.indexOf('unix') != -1 || ua.indexOf('linux') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1) // specific browser shortcuts this.isNS4x = (this.isNS && this.versionMajor == 4); this.isNS40x = (this.isNS4x && this.versionMinor < 4.5); this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7); this.isNS4up = (this.isNS && this.versionMinor >= 4); this.isNS6x = (this.isNS && this.versionMajor == 6); this.isNS6up = (this.isNS && this.versionMajor >= 6); this.isIE4x = (this.isIE && this.versionMajor == 4); this.isIE4up = (this.isIE && this.versionMajor >= 4); this.isIE5x = (this.isIE && this.versionMajor == 5); this.isIE55 = (this.isIE && this.versionMinor == 5.5); this.isIE5up = (this.isIE && this.versionMajor >= 5); this.isIE6x = (this.isIE && this.versionMajor == 6); this.isIE6up = (this.isIE && this.versionMajor >= 6); this.isIE4xMac = (this.isIE4x && this.isMac); } var browser = new BrowserDetectLite(); // * end browser detect sutff // Flash Player Version Detection - Rev 1.6 // Detect Client Browser type // Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved. var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; function ControlVersion() { var version; var axo; var e; // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry try { // version will be set for 7.X or greater players axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { } if (!version) { try { // version will be set for 6.X players only axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); // installed player is some revision of 6.0 // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, // so we have to be careful. // default to the first public version version = "WIN 6,0,21,0"; // throws if AllowScripAccess does not exist (introduced in 6.0r47) axo.AllowScriptAccess = "always"; // safe to call for 6.0r47 or greater version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 4.X or 5.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 3.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = "WIN 3,0,18,0"; } catch (e) { } } if (!version) { try { // version will be set for 2.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); version = "WIN 2,0,0,11"; } catch (e) { version = -1; } } return version; } // JavaScript helper required to detect Flash Player PlugIn version information function GetSwfVer(){ // NS/Opera version >= 3 check for Flash plugin in plugin array var flashVer = -1; if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if (versionRevision == "") { versionRevision = descArray[4]; } if (versionRevision[0] == "d") { versionRevision = versionRevision.substring(1); } else if (versionRevision[0] == "r") { versionRevision = versionRevision.substring(1); if (versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); } } var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; //alert("flashVer="+flashVer); } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; else if ( isIE && isWin && !isOpera ) { flashVer = ControlVersion(); } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { versionStr = GetSwfVer(); if (versionStr == -1 ) { return false; } else if (versionStr != 0) { if(isIE && isWin && !isOpera) { // Given "WIN 2,0,0,11" tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] tempString = tempArray[1]; // "2,0,0,11" versionArray = tempString.split(","); // ['2', '0', '0', '11'] } else { versionArray = versionStr.split("."); } var versionMajor = versionArray[0]; var versionMinor = versionArray[1]; var versionRevision = versionArray[2]; // is the major.revision >= requested major.revision AND the minor version >= requested minor if (versionMajor > parseFloat(reqMajorVer)) { return true; } else if (versionMajor == parseFloat(reqMajorVer)) { if (versionMinor > parseFloat(reqMinorVer)) return true; else if (versionMinor == parseFloat(reqMinorVer)) { if (versionRevision >= parseFloat(reqRevision)) return true; } } return false; } } // end flash sniffer // active content stuff function AC_AddExtension(src, ext) { if (src.indexOf('?') != -1) return src.replace(/\?/, ext+'?'); else return src + ext; } function AC_Generateobj(objAttrs, params, embedAttrs) { var str = ''; if (isIE && isWin && !isOpera) { str += ' '; str += '>'; } else { str += ''); document.write(''); document.write(''); document.write(''); document.write(''); document.write(''); } // PNG DISPLAY SCRIPT // if IE5.5+ on Win32, then display PNGs with AlphaImageLoader if ((browser.isIE55 || browser.isIE6x) && browser.isWin32) { var pngAlpha = true; // else, if the browser can display PNGs normally, then do that } else if ((browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast)) { var pngNormal = true; } //--------------------------------------------------------------- //--------------------------------------------------------------- // OPACITY DISPLAY FUNCTION // Outputs the image as a div with the AlphaImageLoader, or with // a standard image tag. function od_displayImage(strId, strPath, intWidth, intHeight, strClass, strAlt, strTitle) { if (pngAlpha) { document.write('
'); } else { document.write(''+strAlt+''); } } //--------------------------------------------------------------- //--------------------------------------------------------------- /* USAGE: PLACE THIS CODE WHERE YOU WOULD NORMALLY PUT REPLACE THE ARGUMENTS WITH PROPER VALUES */ // SLIDEY SCRIPT var _spd = null, _zspd = null; function _moveIt(_eid,_way,_max) { _element = _eid; _direction = _way; var _elem = document.getElementById(_eid); _maxrig = 0; if(_max == undefined) { _maxlef = -1200; } else { _maxlef = _max; } if(_way == 'right' && parseInt(_elem.style.left) > _maxlef) { _elem.style.left = parseInt(_elem.style.left) - 20 + 'px'; } else if(_way == 'left' && (parseInt(_elem.style.left) < _maxrig)) { _elem.style.left = parseInt(_elem.style.left) + 20 + 'px'; } if(_way == 'left' && (parseInt(_elem.style.left) < _maxrig)) { _zspd = setTimeout("_moveIt(_element,_direction,_maxlef)",1); } if(_way == 'right' && (parseInt(_elem.style.left) > _maxlef )) { _spd = setTimeout("_moveIt(_element,_direction,_maxlef)",1); } } function _stopIt() { if(_spd != null) { clearTimeout(_spd); } if(_zspd != null) { clearTimeout(_zspd); } } function MM_openBrWindow(theURL,winName,features) { window.open(theURL,winName,features); } w = window.screen.availWidth; h = window.screen.availHeight; /* standardized ajax box stuff */ function getHTTPObject() { var xmlhttp = false; if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); } else if(!xmlhttp) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } return xmlhttp; } function package_ajx_slider(start,total,action,id) { parameters='action='+encodeURIComponent(action)+'&start='+start+'&total='+total; /* this is messy! this grabs the keys and values in any forms within the ajax holder */ for(i in document.getElementById(id).childNodes) { if(document.getElementById(id).childNodes[i].className == 'ajx-load-contents') { for(j in document.getElementById(id).childNodes[i].childNodes) { if(document.getElementById(id).childNodes[i].childNodes[j].nodeName == 'FORM') { for(k in document.getElementById(id).childNodes[i].childNodes[j].childNodes) { if(document.getElementById(id).childNodes[i].childNodes[j].childNodes[k].nodeName == 'INPUT') { parameters += '&'+document.getElementById(id).childNodes[i].childNodes[j].childNodes[k].name+'='+document.getElementById(id).childNodes[i].childNodes[j].childNodes[k].value; } } } } } } document.getElementById(id).innerHTML = '
' url = '/i/php/generic_ajax_handler.php'; makePostRequest(url,id,parameters); } function makeCBRequest( url, callback ) { var xmlhttp = getHTTPObject(); if ( typeof callback == 'function' ) { xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.responseText) callback.call( xmlhttp ); // set scope to xmlhttp } xmlhttp.send(null); xmlhttp.close; } } function makeRequest( url, elementID, callback ) { var xmlhttp = getHTTPObject(); var targetElement = document.getElementById(elementID); xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.responseText) { if (targetElement) targetElement.innerHTML = xmlhttp.responseText + '\n'; (typeof callback == 'function')? callback.call( xmlhttp ) : null ; } } xmlhttp.send(null); xmlhttp.close; } function makePostRequest( url, elementID, parameters, callback ){ //alert(parameters); var xmlhttp = getHTTPObject(); var targetElement = document.getElementById(elementID); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.responseText) { if (targetElement) targetElement.innerHTML = xmlhttp.responseText + '\n'; (typeof callback == 'function')? callback.call( xmlhttp ) : null ; } } xmlhttp.open('POST', url, true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", parameters.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(parameters); } function collect(a,f){ var n=[]; for(var i=0;i document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) return arrayPageSize; } function placeIt(mylayer,left_offset) { (document.getElementById) ? dom = true : dom = false; var l = document.getElementById(mylayer); if (self.innerHeight) { l.style.top = window.pageYOffset + (window.innerHeight - ((window.innerHeight/2) + 200)) + "px"; l.style.left = window.pageXOffset + (window.innerWidth - ((window.innerWidth/2) + left_offset)) + "px"; } else if (document.documentElement && document.documentElement.clientHeight) { l.style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight - ((document.documentElement.clientHeight/2)+200)) + "px"; l.style.left = document.documentElement.scrollLeft + (document.documentElement.clientWidth - ((document.documentElement.clientWidth/2)+left_offset)) + "px"; } else if (document.body) { l.style.top = document.body.scrollTop + (document.body.clientHeight - ((document.body.clientHeight/2) + 200)) + "px"; l.style.left = document.body.scrollLeft + (document.body.clientWidth - ((document.body.clientWidth/2)+left_offset)) + "px"; } window.setTimeout("placeIt('"+mylayer+"',"+left_offset+")", 10); } var ok = false; function hide(element) { document.getElementById(element).style.display = 'none'; //alert(document.getElementById(element).style.display); } function unhide(element,d_prop) { d_prop = defined(d_prop) ? d_prop : 'block'; document.getElementById(element).style.display = d_prop; } function check_myage(){ check_mydate(); var my_year = document.getElementById('year'); var my_month = document.getElementById('month'); var my_day = document.getElementById('zday'); var today_date = new Date(); var input_date = new Date(my_month.value+"/"+my_day.value+"/"+my_year.value); var test_month = input_date.getMonth()+1; var test_year = input_date.getFullYear(); var test_day = input_date.getDate(); //var today1_date = new Date(today_m+"/"+today_d+"/"+today_y); var sec = (today_date.getTime()/1000.0) - (input_date.getTime()/1000.0); var diff = Math.floor(sec/31564926); if (diff < 13) { unhide('underage_disclaimer_div'); unhide('parent_email_div'); } else { hide('underage_disclaimer_div'); hide('parent_email_div'); } } function updatepage(str,div){ ok = true; if(str == "no"){ unhide(div); ok = false; } else { hide(div); ok = true; } return ok; } function check_avail(myfield,myerrordiv,myurl) { var my_name = document.getElementById(myfield); var myxmlhttp = getHTTPObject(); var test; var url = myurl+my_name.value; hide(myerrordiv); if (my_name.value != ""){ myxmlhttp.onreadystatechange = function() { //alert ("test is "+test); if (myxmlhttp.readyState == 4) { test = updatepage(myxmlhttp.responseText,myerrordiv); } } myxmlhttp.open("GET", url, true); myxmlhttp.send(url); } //alert (ok); } function validate_email(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false } if (str.indexOf(at,(lat+1))!=-1){ return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false } if (str.indexOf(dot,(lat+2))==-1){ return false } if (str.indexOf(" ")!=-1){ return false } return true } function check_myemail(addr) { var s = document.getElementById(addr).value; var test = validate_email(s); hide('email_bad'); if (s != ""){ if (test == false){ unhide('email_bad'); return false; } else { hide('email_bad'); return true; } } else { unhide('email_blank'); return false; } } function validate_date(){ day = document.getElementById('zday').value; month = document.getElementById('month').value; js_month = month -1;// js months are 0-11 instead of 1-12 year = document.getElementById('year').value; var today_date = new Date(); var test_month = today_date.getMonth()+1; var test_year = today_date.getFullYear(); var test_day = today_date.getDate(); //alert(month + "/" + day + "/" + year); // tests for future dates. if(year > test_year){ return false; } else if( year == test_year){ if(month > test_month){ return false; } else if(month == test_month){ if(day > test_day){ return false; } } } dteDate=new Date(year,js_month,day); // tests for invalid dates, like february 31st return ((day==dteDate.getDate()) && (js_month==dteDate.getMonth()) && (year==dteDate.getFullYear())); } function check_mydate(){ var x = validate_date(); hide('illegal_date_div'); if (x == false){ unhide('illegal_date_div'); document.getElementById('go').disabled = true; } else { document.getElementById('go').disabled = false; } } function check_form(form){ var user = check_avail('member_name','username_taken','/i/php/check_name.php?member_name='); var email = check_avail('email_address','email_taken','/i/php/check_email.php?email='); sendPostForm('/i/php/loadreg.php',form,'registration_panel'); } // -- done function hide_flash_objects(z){ var my_obj = new Array(4); my_obj[0] = 'embed'; my_obj[1] = 'object'; my_obj[2] = 'iframe'; my_obj[3] = 'ilayer'; for (ii = 0; ii < 4; ii++){ var x = document.getElementsByTagName(my_obj[ii]); if (x.length > 0){ for (i = 0; i < x.length; i++){ if (z == 1){ x[i].style.display = "none"; } else { x[i].style.display = ""; } } } } } /* registration stuff */ function loadSignup(ref) { var arrayPageSize = getPageSize(); var arrayPageScroll = getPageScroll(); hide_flash_objects(1); var overLayMain = document.getElementById('trans_layer'); var overLay = document.getElementById('registration_panel'); overLayMain.style.height = (arrayPageSize[1] +'px'); overLayMain.style.display = 'block'; overLay.style.display = 'block'; placeIt('registration_panel',300); placeIt('reg_side',1020); makeRequest('/i/php/loadreg.php?ref='+ref, 'registration_panel'); } /*MR added 7/30*/ function loadWorld() { var ironman = document.getElementById('reg_side'); ironman.style.display = 'none'; var arrayPageSize = getPageSize(); var arrayPageScroll = getPageScroll(); hide_flash_objects(1); var overLayMain = document.getElementById('trans_layer'); var overLay = document.getElementById('world_map'); overLayMain.style.height = (arrayPageSize[1] +'px'); overLayMain.style.display = 'block'; overLay.style.display = 'block'; placeIt('world_map',475); /*placeIt('reg_side',1020);*/ makeRequest('/i/php/worldmap.php', 'world_map'); } function closeWorld() { hide_flash_objects(0); document.getElementById('trans_layer').style.display = 'none'; document.getElementById('world_map').style.display = 'none'; document.getElementById('world_map').innerHTML = "Loading..."; } /*for world map*/ function closeSignup(step,kid,ref) { // per 1.5 spec // 05.06.2008: added site reference - Ú if (step && step != '1'){ makeRequest('/i/2007/php/loadreg.php?action=html&step=3&kid='+kid+'&ref='+ref,'registration_panel'); } else { hide_flash_objects(0); document.getElementById('trans_layer').style.display = 'none'; document.getElementById('registration_panel').style.display = 'none'; document.getElementById('registration_panel').innerHTML = "Loading..."; } } ////////////////////////////////////////////////////////////////////////////// // Create a JSON object only if one does not already exist. // Closure technique is used to avoid creating extra globals. // methods: // var json_string = JSON.encode( javascript data ); // var js_data = JSON.decode( json_string ); // Yoinked from http://www.json.org/json2.js // and renamed the methods to be more like PHP -Ñ if (!this.JSON) { JSON = {}; } (function () { function f(n) { // Format integers to have at least two digits. return n < 10 ? '0' + n : n; } if (typeof Date.prototype.toJSON !== 'function') { Date.prototype.toJSON = function (key) { return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z'; }; String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function (key) { return this.valueOf(); }; } var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' }, rep; function quote(string) { escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { var c = meta[a]; if (typeof c === 'string') { return c; } return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } function str(key, holder) { var i, // The loop counter. k, // The member key. v, // The member value. length, mind = gap, partial, value = holder[key]; if (value && typeof value === 'object' && typeof value.toJSON === 'function') { value = value.toJSON(key); } if (typeof rep === 'function') { value = rep.call(holder, key, value); } switch (typeof value) { case 'string': return quote(value); case 'number': return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': return String(value); case 'object': if (!value) { return 'null'; } gap += indent; partial = []; if (typeof value.length === 'number' && !value.propertyIsEnumerable('length')) { length = value.length; for (i = 0; i < length; i += 1) { partial[i] = str(i, value) || 'null'; } v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']'; gap = mind; return v; } if (rep && typeof rep === 'object') { length = rep.length; for (i = 0; i < length; i += 1) { k = rep[i]; if (typeof k === 'string') { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } else { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}'; gap = mind; return v; } } // If the JSON object does not yet have a encode method, give it one. if (typeof JSON.encode !== 'function') { JSON.encode = function (value, replacer, space) { var i; gap = ''; indent = ''; if (typeof space === 'number') { for (i = 0; i < space; i += 1) { indent += ' '; } } else if (typeof space === 'string') { indent = space; } rep = replacer; if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.encode'); } return str('', {'': value}); }; } if (typeof JSON.decode !== 'function') { JSON.decode = function (text, reviver) { var j; function walk(holder, key) { var k, v, value = holder[key]; if (value && typeof value === 'object') { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = walk(value, k); if (v !== undefined) { value[k] = v; } else { delete value[k]; } } } } return reviver.call(holder, key, value); } cx.lastIndex = 0; if (cx.test(text)) { text = text.replace(cx, function (a) { return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }); } if (/^[\],:{}\s]*$/. test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { j = eval('(' + text + ')'); return typeof reviver === 'function' ? walk({'': j}, '') : j; } throw new SyntaxError('JSON.decode'); }; } })(); /* * Object: marvel_loader * Purpose: this loads data from our php objects via an ajax call. It converts the results * into json, xml or templated output depending on the mode selected in the request object. * Simple example: * var loader = marvel_loader.init( 'catalog/catalog' ); * loader.request = { * params: [ {"s.series_name": "Ultimate Spider-Man"} ], * mode: 'json', * expire: 3600, * }; * loader.callback = update_my_content_function; * loader.energize(); * * Note: * For detailed explanation of all the features visit http://devblog.crossbow */ var marvel_loader = function() { this.base_url = '/i/2008/php/ajaxanator.php/' ; this.req_details = {} ; this.supported_modes = [ 'json','xml','htm' ] ; this.hash = {}; this.validate_request = function() { var err, r = this.request ; if ( !defined(r) ) { err = 'Request is not defined!'; } else { // verify params if ( !defined(r.params) ) { err = 'params is required'; } // will leave this in to encourage use of parameters // check mode if ( defined(r.mode) && !in_array( r.mode, this.supported_modes ) ) { err = r.mode + ' is not supported mode'; } } // check url if ( !defined(this.req_id) ) { err = 'Request URL is not defined or incorrect!'; } return err ; } this.energize = function( eid,subset ) { // first validate var err = this.validate_request() ; if ( !err ) { var req_id = this.req_id ; if ( this.req_details[this.req_id].post_params ) var post_params = this.req_details[this.req_id].post_params ; else { // encode the parameters var post_params = this.request ; !is_array(post_params.params) || ( post_params.params = JSON.encode( this.request.params ) ); defined(this.request.cparams) && is_array(post_params.cparams) ? post_params.cparams = JSON.encode( this.request.cparams ) : null ; this.req_details[this.req_id].post_params = post_params ; if ( typeof this.callback == 'function' ) this.req_details[this.req_id].callback = this.callback ; } this.mode = defined(post_params.mode) ? post_params.mode : 'json' ; var post_arr = [] ; defined( subset ) ? post_params.subset = subset : null ; for ( var i in post_params ) post_arr.push( i+'='+ this.clean_param(post_params[i]) ) ; post_arr.push( 'mhash='+ this.get_hash(req_id) ) ; if (eid) this.req_details[this.req_id].el_id = eid ; var closure_cb = function() { marvel_loader.catch_data.call(this, req_id); }; makePostRequest( this.url, null, postEscape(post_arr.join('&')), closure_cb ) ; } else alert( "Error: "+ err ) ; return req_id ; } // grab the data returned // obj context should be xmlhttp object this.catch_data = function(req_id) { var ml = window.marvel_loader ; var req = ml.req_details[req_id] ; var modes = ml.mode.indexOf(',') > -1 ? ml.mode.split(',') : [ ml.mode ]; if ( this.responseText ) { if ( in_array('htm',modes) ) { var resText,id = defined(req.el_id) ? req.el_id : null ; if ( in_array('json',modes) && req.post_params.setsize ) { var response_info = ml.handle_htmSubset_response( this.responseText ) ; resText = response_info.text ; req.result = response_info.result ; } else resText = this.responseText ; !id || ( document.getElementById(id).innerHTML = resText ); } else if ( in_array('xml',modes) ) req.result = this.responseXML ; else try { req.result = JSON.decode( this.responseText ) ; } catch(err) { alert( 'Error: Unexpected response\n'+ this.responseText ); } } if ( typeof req.callback == 'function' ) req.callback.call( req ) ; } this.handle_htmSubset_response = function( res ) { var ret = res; var result = null ; var arr = res.split('|||') ; if ( arr.length == 2 ) { try { result = JSON.decode(arr[0]); } catch (e) { alert('Error: Unexpected response'); } } return { "result": result, "text": arr[1] } ; } this.get_hash = function(rid) { if ( !this.hash[rid] ) { var e = document.getElementsByTagName('meta'),i=e.length; while (i--) if ( e[i].getAttribute('name') == rid ) { this.hash[rid] = e[i].getAttribute('content'); } } return this.hash[rid]; } this.clean_param = function(txt) { return ( defined(txt.indexOf) && (txt.indexOf('&') >= 0 || txt.indexOf('=') >= 0) ) ? escape(txt) : txt ; } this.prev = function(eid,rid) { !rid || this.set_reqId(rid); var r = this.req_details[this.req_id].result ; defined(r.subset) && this.energize(eid,r.subset.previous) ; } this.next = function(eid,rid) { !rid || this.set_reqId(rid); var r = this.req_details[this.req_id].result ; defined(r.subset) && this.energize(eid,r.subset.next) ; } // check and set the request id this.set_reqId = function(req_id) { var s = req_id.split('/'); if ( req_id && s.length == 2 ) this.req_id = s.join('|') ; else if ( req_id && this.req_details[req_id] ) { this.req_id = req_id ; this.url = this.base_url + req_id.split('|').join('/') ; } } this.init = function( cm_str ) { // check for the dependencies if ( typeof makePostRequest !== 'function' ) alert( 'marvel_loader: makePostRequest() is not found' ) ; if ( typeof JSON !== 'object' ) alert( 'marvel_loader: JSON object is not found' ) ; var len = cm_str.split('/').length ; if ( len > 2 ) { this.base_url = cm_str.split('/').slice(0, len-2 ).join('/') + '/' ; cm_str = cm_str.split('/').slice(-2).join('/') ; } else if ( len <= 1 ) alert( 'marvel_loader: marvel loader initialized with '+ cm_str + '\nShould be in this format:\n class/method OR\nfull relative path to ajaxanator.php' ); this.set_reqId( cm_str ); if ( this.req_id ) { this.url = this.base_url + cm_str ; this.req_details[this.req_id] = {} ; this.req_details[this.req_id].result = {} ; this.req_details[this.req_id].callback = this.callback = null ; } return this ; } } window.marvel_loader = new marvel_loader() ; // BRIGHTCOVE JS API WRAPPERS // document.bc_dump = new Object; document.bc_dump.listeners = new Object; function onContentLoad() { //callFlash("fetchTitleById", 1733163322); } function selectTitle_Result(message) { //alert(message); } function onTitleLoad(infoObj) { var titleDTO = infoObj.parameters.title; callFlash("loadTitleById", titleDTO.id); } function onTemplateLoaded(message) { if(defined(document.bc_dump.listeners)) { for(eventName in document.bc_dump.listeners) { callFlash("addEventListener", eventName, document.bc_dump.listeners[eventName]); } } document.bc_dump.bc_init = true; } function getTitleById_Result(infoObj) { if(defined(infoObj)) { document.bc_dump.getTitleById = true; } else { document.bc_dump.getTitleById = false; } } function swapVid(titleId) { if(defined(document.bc_dump.bc_init)) { callFlash("getTitleById",titleId); if(document.bc_dump.getTitleById) { callFlash("loadTitleById", titleId); } else { callFlash("fetchTitleById", titleId); } } else { alert('Please wait for the player to load before switching videos.'); } } function fw_config(){ return { networkId:12880,cb_profile:"marvel_brightcove",siteSectionNetworkId:12880, videoAssetNetworkId:12880,fw_server:"http://3250.v.fwmrm.net/ad/p/1?",renderersXML:"http://m2.fwmrm.net/p/lib/bc/renderers.xml",siteSection:'mkids'+document.fwSiteSection,autoplay:false,video_profile:"marvel_video",needsCARU:false,CARU_width:230,CARU_location:"http://marvelkids.marvel.com/i/flash/freewheel_preroll.swf",amLocation:"http://adm.fwmrm.net/p/marvel_live/AdManager.swf" }; } function comic_locator() { // this is for comic shop locator box throughout the site var zz = document.getElementById('Zip'); // zipcode field var zy = document.getElementById('ziperror'); // error field if (zz.value == ''){ zy.style.display = ''; } else { zy.style.display = 'none'; MM_openBrWindow('/map.php?Zip='+zz.value,'Zipfinder','status=no,resizable=yes,width=460,height=695,scrollbars=no'); } return false; } function showAd() { var myDiv = document.getElementById("marvel_game_ad"); myDiv.style.display = "block"; } function showGame() { var myDiv = document.getElementById("marvel_game_ad"); myDiv.style.display = "none"; } function clearAd() { loadAd('blank.html'); return; } function loadAd(url) { var iframe = document.getElementById('adFrame'); iframe.src = url; }