/************************************

 *

 * Global config for CW js

 *

 ************************************/

//Global debug param. Place jsDebug=true in query string to enable.

if (window.location.href.indexOf("jsDebug=true") != -1){

 var debug = true;

}

/**

 * Site initialization function

 */

window.onload = function()

{

 // run onload events

 config.runOnLoadEvents();

}

//alert("Config.js included");

 // Used to be we had hostRoot/prodRoot because there were two different servers, no we have one for current protocol/host and one for the secure protocol/host

 // They may often turn out to the be the same

 var hostRoot = window.location.protocol + '//' + window.location.host + '/';

 var prodRoot = 'https://' + window.location.host + '/';

// Image Sources

 var imageDir = hostRoot + 'images/';

// Submit counter for limiting submits

 var submitCount = 0;

// Cookie Munging, produces array: cookie with all the cookie fields

// Cookie fields:

// $service_address # index: 0

// $service_city # index: 1

// $service_state # index: 2

// $service_zip # index: 3

// $service_type # index: 4

// $service_floor # index: 5

// $success = false; # index: 6

// $service_firstname # index: 7

// $customer_id # index: 8

 var c_array = document.cookie.split(/;/);

 var pqcookie = -1;

 var cookies = new Array;

 //alert("Cookie: " + document.cookie);

 for(var c_ind = 0; c_ind < c_array.length; c_ind++) {

 var split_array = c_array[c_ind].split(/=/);

 split_array[0] = split_array[0].replace(' ','');

 cookies[split_array[0]] = split_array[1];

 //alert("cookies[" + split_array[0] + "] = " + cookies[split_array[0]] + " from original: " + split_array[1]);

 }

 if(cookies["PrequalAddress"]) {

 //alert("PrequalAddress cookie found! " + cookies["PrequalAddress"]);

 cookies["PrequalAddress"] = decodeURI(cookies["PrequalAddress"]);

 cookies["PrequalAddress"] = cookies["PrequalAddress"].replace(/%3F/g,':');

 cookies["PrequalAddress"] = cookies["PrequalAddress"].replace(/%3D/g,'=');

 cookies["PrequalAddress"] = cookies["PrequalAddress"].replace(/\+/g,' ');

 pq_array = cookies["PrequalAddress"].split(/:/);

 //alert("pq_array size=" + pq_array.length);

 if(pq_array.length > 0) {pqcookie = new Array;}

 for(var pq_ind = 0; pq_ind < pq_array.length; pq_ind++) {

 //alert("pq_array[" + pq_ind + "] = " + pq_array[pq_ind]);

 var keyval = pq_array[pq_ind].split(/=/);

 //alert("assigning pqcookie[" + keyval[0] + "] = " + keyval[1]);

 pqcookie[keyval[0]] = keyval[1];

 //alert("pqcookie[" + keyval[0] + "] = " + pqcookie[keyval[0]]);

 }

 /*for(var z in pqcookie) {

 document.write("pqcookie[" + z + "] = " + pqcookie[z] + "<br>");

 }*/

 }

// Urchin tracking

_uacct = "UA-164960-2";

try {

 urchinTracker();

} catch (e) {

 // do nothing, urching is not a fatal error

}

// Main Nav Bar definition

 MainNav = new Array();

 MainNav[0] = {

 name:"home", alt:"Home", link:"index.php", display:"true",

 lnav:{}

 };

 MainNav[1] = {

 name:"prod", alt:"Products", link:"products/gallery.php", display:"true",

 lnav:{

 0:{name:"bb", alt:"Wireless Broadband", link:"wireless-broadband/overview.php"},

 1:{name:"voip", alt:"Internet Phone Service", link:"internet-phone-service/overview.php"},

 2:{name:"plans", alt:"Service Plans", link:"wireless-broadband/getstarted.php"},

 3:{name:"maps", alt:"Coverage Areas", link:"store/service_areas.php"},

 4:{name:"stories", alt:"Testimonials", link:"wireless-broadband/testimonials.php"}

 }

 };

 MainNav[2] = {

 name:"order", alt:"Order", link:"store/order.php", display:"true",

 lnav:{}

 };

 MainNav[3] = {

 name:"co", alt:"Company", link:"company/about.php", display:"true",

 lnav:{

 0:{name:"about", alt:"About Clearwire", link:"company/about.php"},

 1:{name:"news", alt:"News Room", link:"company/news/main.php"},

 2:{name:"careers", alt:"Careers", link:"company/careers.php"},

 3:{name:"contact", alt:"Contact", link:"company/contact.php"}}

 };

 MainNav[4] = {

 name:"support", alt:"Support", link:"support/support.php", display:"true",

 lnav:{

 0:{name:"main", alt:"Customer Care", link:"support/support.php"},

 1:{name:"faqs", alt:"FAQs", link:"support/faq.php"},

 2:{name:"signal", alt:"Signal Tips", link:"support/signal.php"},

 3:{name:"acc", alt:"Accessories", link:"support/accessories.php"},

 4:{name:"network", alt:"Networking", link:"support/networking.php"},

 5:{name:"logins", alt:"Logins", link:"support/logins.php"}

 }

 };

// MyAccount Nav Bar definition

 MyAccountNav = new Array();

 MyAccountNav[0] = {

 name:"home", alt:"MyAccount Home", link:"my_account/home.php", display:"true",

 lnav:{}

 };

 MyAccountNav[1] = {

 name:"broadband",alt:"Broadband Service",link:"my_account/broadband/broadband.php", display:"true",

 lnav:{

 0:{name:"home", alt:"Broadband Home", link:"my_account/broadband/broadband.php", display:"true"},

 1:{name:"email_setup", alt:"Set Up Email Address", link:"my_account/broadband/email_setup.php", display:"true"},

 2:{name:"email_manage", alt:"Manage Email Accounts", link:"my_account/broadband/email_manage.php", display:"true"},

 3:{name:"web_activate", alt:"Activate Web Account", link:"my_account/broadband/web_activate.php", display:"true"},

 4:{name:"staticip_setup", alt:"Set Up Static IPs", link:"my_account/broadband/staticip_setup.php", display:"true"},

 5:{name:"customize", alt:"Add Features/Accessories", link:"my_account/broadband/customize.php", display:"true"},

 6:{name:"upgrade", alt:"Upgrade Your Plan", link:"my_account/broadband/upgrade.php", display:"true"},

 7:{name:"refer_a_friend", alt:"Refer A Friend", link:"my_account/broadband/refer_a_friend.php", display:"true"}

 }

 };

 MyAccountNav[2] = {

 name:"voice",alt:"Phone Service",link:"my_account/voice/voice.php", display:"true",

 lnav:{

 0:{name:"home", alt:"Phone Service Home", link:"my_account/voice/voice.php", display:"true"},

 1:{name:"callactivity", alt:"Call Activity", link:"my_account/voice/voip_callactivity.php", display:"true"},

 2:{name:"change911", alt:"911 Address Change", link:"my_account/voice/voip_change911.php", display:"true"},

 3:{name:"numbers", alt:"Manage Phone Numbers", link:"my_account/voice/voip_numbers.php", display:"true"},

 4:{name:"ratetable", alt:"International Call Rates", link:"my_account/voice/voip_ratetable.php", display:"true"},

 5:{name:"features", alt:"Features Dashboard", link:"my_account/voice/voip_features.php", display:"true"},

 6:{name:"getstarted", alt:"Getting Started", link:"my_account/voice/voip_getstarted.php", display:"true"},

 7:{name:"911info", alt:"Important 911 Information", link:"my_account/voice/voip_911info.php", display:"true"}

 }

 };

 MyAccountNav[3] = {

 name:"billing",alt:"Billing",link:"my_account/billing/billing.php", display:"true",

 lnav:{

 0:{name:"home", alt:"Billing Home", link:"my_account/billing/billing.php", display:"true"},

 1:{name:"pay_online", alt:"Pay Bill Online", link:"my_account/billing/pay_online.php", display:"true"},

 2:{name:"invoice_history", alt:"Invoice History", link:"my_account/billing/billing.php", display:"true"},

 3:{name:"billing_info", alt:"Update Billing Information", link:"my_account/billing/billing_info.php", display:"true"}

 }

 };

 MyAccountNav[4] = {

 name:"helpdesk",alt:"Customer Care",link:"my_account/helpdesk/helpdesk.php", display:"true",

 lnav:{

 0:{name:"home", alt:"Customer Care Home", link:"my_account/helpdesk/helpdesk.php", display:"true"},

 1:{name:"trouble_tickets", alt:"Trouble Tickets", link:"my_account/helpdesk/trouble_tickets.php", display:"true"},

 2:{name:"order_history", alt:"Order Tracking / History", link:"my_account/helpdesk/order_history.php", display:"true"},

 3:{name:"update_profile", alt:"Update Profile", link:"my_account/helpdesk/update_profile.php", display:"true"},

 4:{name:"account_history", alt:"Account History", link:"my_account/helpdesk/account_history.php", display:"true"},

 5:{name:"helpdesk", alt:"Site Help", link:"support/help/site_help.htm", display:"true"}

 }

 };

// Intranet Nav Bar definition

 HubNav = new Array();

 HubNav[0] = {

 name:"home", alt:"Home", link:"https://hub.clearwire.com", display:"true",

 lnav:{}

 };

 HubNav[1] = {

 name:"sharepoint",alt:"Sharepoint",link:"https://share.clearwire.com/", display:"true",

 lnav:{}

 };

 HubNav[2] = {

 name:"webtools",alt:"WebTools",link:"https://webtools.clearwire.com", display:"true",

 lnav:{}

 };

 HubNav[3] = {

 name:"boss",alt:"BOSS",link:"https://boss.clearwire.com", display:"true",

 lnav:{}

 };

 HubNav[4] = {

 name:"support",alt:"Support",link:"https://hub.clearwire.com/#", display:"true",

 lnav:{

 0:{name:"samplelnav", alt:"Sample LNAV", link:"", display:"false"}

 }

 };

function assert(pCondition, pMessage, pLocation)

{

 if(!pCondition && debug){

 pLocation = pLocation?pLocation:"unknown script";

 alert("Assertion Failure in " + pLocation + ":\n" + pMessage);

 }

}

function prodLink(link, text) {

 document.write('<a href="' + prodRoot + link + '">' + text + '</a>');

}

// could be made into an all purpose submit function if oop'd

function one_click() {

 submitCount++;

 if(submitCount != 1) {

 alert("Please click the submit button only once.");

 return false;

 } else {

 if( submitCount > 5 ) {

 //alert("Seriously, stop clicking me or I'm going to get mad...");

 return false;

 }

 return true;

 }

}

function popUp(strURL,strType,strHeight,strWidth) {

 var strOptions="";

 if (strType=="console") strOptions="scrollbars,resizable,height="+strHeight+",width="+strWidth;

 if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;

 if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;

 window.open(strURL, 'newWin', strOptions);

}

function getElem(id) {

 var d = document;

 var element = null;

 if (!element && d.getElementById) {

 element = d.getElementById(id);

 if(element) {

 return element;

 }

 }

 if (!element && d.getElementsByTagName) {

 var tr_elms = d.getElementsByTagName("TR");

 if (tr_elms) {

 for (j=0;j<tr_elms.length;j++) {

 if (tr_elms[j].name == id) {

 element = tr_elms[j];

 if(element) {

 return element;

 }

 }

 }

 }

 }

 if (!element && d.getElementsByTagName) {

 var inp_elms = d.getElementsByTagName("INPUT");

 if (inp_elms) {

 for (j=0;j<inp_elms.length;j++) {

 if (inp_elms[j].name == id) {

 element = inp_elms[j];

 if(element) {

 return element;

 }

 }

 }

 }

 }

 return element;

}

function hide(element_name) {

 elem = getElem(element_name);

 if(elem) {

 elem.style.display = 'none';

 }

}

function show(element_name) {

 elem = getElem(element_name);

 if(elem) {

 elem.style.display = '';

 }

}

function addOption( ) {

 var selectBox = arguments[0];

 var optionValue = arguments[1];

 var optionText = arguments[--arguments.length]; // This makes text an optional param, will default to optionValue

 var newOption = document.createElement('option');

 newOption.text = optionText;

 newOption.value = optionValue;

 try {

 selectBox.add(newOption, null); // standards compliant; doesn't work in IE

 } catch(ex) {

 selectBox.add(newOption); // IE only

 }

}

// returns the selected index of the radioFamily object passed (i.e. var selectedIndex = selectedRadio( document.myForm.radioFamily );)

function selectedRadio( radioFamily ) {

 if( typeof( radioFamily.length ) == "undefined" ) {

 return false;

 }

 for( var radioCount = 0; radioCount < radioFamily.length; radioCount++ ) {

 if( radioFamily[radioCount].checked == true ) {

 return radioCount;

 }

 }

 return false;

}

/**

 * SpecialEffectsLibrary (special) is a Library used for visual effects on the site

 * typically using DHTML

 *

 * @author Jesse Brown

 * @version 1.0

 *

*/

function SpecialEffectsLibrary() 

{ 

 var t = this;

 t.frames = 200;

 t.r;

 t.g;

 t.b;

 t.elem;

 

 t.colorFade = function(nodeID, color, frames){

 elem = document.getElementById(nodeID);

 if(frames > 0) {

 frames--;

 aColor = getRGB(color);

 r = aColor[0]; g = aColor[1]; b = aColor[2];

 elem.style.backgroundColor = "rgb("+ r +","+ g +","+ b +")";

 delR = Math.round((255-r)/frames); 

 delG = Math.round((255-g)/frames);

 delB = Math.round((255-b)/frames);

 r += delR; g += delG; b += delB;

 aColor[0] = r; aColor[1] = g; aColor[2] = b;

 color = getHex(aColor);

 var functionCall = "special.colorFade('" + nodeID + "','" + color + "'," + frames + ")";

 window.setTimeout(functionCall, 20);

 }

 else {

 elem.style.backgroundColor = "#FFF";

 }

 }

 

 function getRGB(color){

 var aReturn = new Array();

 hR = color.substr(0,2);

 hG = color.substr(2,2);

 hB = color.substr(4,2);

 aReturn[0] = parseInt(hR,16);

 aReturn[1] = parseInt(hG,16);

 aReturn[2] = parseInt(hB,16);

 return aReturn;

 }

 

 function getHex(color){

 var sReturn = "";

 var hD="0123456789ABCDEF";

 for(var i=0;i<3;i++){

 var h = hD.substr(color[i]&15,1);

 while(color[i]>15){color[i]>>=4;h=hD.substr(color[i]&15,1)+h;}

 sReturn += (h.length<2?'0'+h:h);

 }

 return sReturn;

 }

}

var special = new SpecialEffectsLibrary;

function FlashClass(){

 var t = this;

 var activeX = false;

 t.ieAutoInstall = true;

 t.isSecure = false;

 t.versionStr = "6,0,0,0";

 t.defaultAlt = '<div align="center"><a href="https://www.macromedia.com/go/getflashplayer/" target="_blank">click here to install</a><br>or<br>refresh to try again</div>';

 t.hasVersion = function(ver){ //ver can either be single int or full version: eg 6.0.79

 t.swf = false;

 var major;

 var minor;

 var testFullVersion = false;

 if(!ver) ver = 0;

 if(ver.length > 1){

 ver = ver.split(".");

 major = ver[1]; if(!major) major = 0;

 minor = ver[2]; if(!minor) minor = 0;

 ver = ver[0]; if(!ver) ver = 0;

 t.versionStr = ver + "," + major + "," + minor + ",0";

 testFullVersion = true;

 }else if(ver != 0){

 t.versionStr = ver + ",0,0,0";

 }

 var n = navigator;

 if(n.plugins && n.plugins.length > 0){

 var m,tp,d,pluginVer;

 m = n.mimeTypes;

 tp = 'application/x-shockwave-flash';

 if(m && m[tp] && m[tp].enabledPlugin && m[tp].enabledPlugin.description){

 d = m[tp].enabledPlugin.description; // Shockwave Flash 7.0 r19

 pluginVer = d.charAt(d.indexOf('.')-1); // 7

 if(!testFullVersion){

 t.swf = (pluginVer >= ver) ? true : false;

 }else{

 var pluginMajor = d.charAt(d.indexOf('.')+1); //0

 var pluginMinor = d.substr(-2); //19

 //document.write(ver + "," + major + "," + minor);

 //check version

 if(pluginVer < ver){

 t.swf = false;

 }else if(pluginVer > ver){

 //no need to check major or minor

 t.swf = true;

 }else{

 if(pluginMajor < major){

 t.swf = false;

 }else if(pluginMajor > major){

 //no need to check minor

 t.swf = true;

 }else{

 if(pluginMinor >= minor){

 t.swf = true;

 }else{

 t.swf = false;

 }

 }

 }

 }

 }

 }else if(n.appVersion.indexOf("Mac") == -1 && window.execScript){

 for(var i=ver; i<=8&&i!=1&&t.swf!=true; i++){

 execScript('on error resume next: flash.swf=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash'+((i==0)?'':'.'+i)+'"))','VBScript');

 }

 activeX = true;

 }else{

 t.swf = false;

 }

 return t.swf;

 }

 t.getPluginTag = function(swfFile,width,height,bgcolor,ver,altFormat,params){

 //ver is either single int or full version name, eg: 6.0 r79

 var s = '';

 var win = (navigator.appVersion.toLowerCase().indexOf("win")!=-1);

 var ie = (navigator.appName=="Microsoft Internet Explorer");

 if(t.hasVersion(ver) && swfFile || win && ie && swfFile && t.ieAutoInstall){

 var additionalParams = '';

 var id = "";

 if(params && params.length>0){

 var pArray = params.split(",");

 for(var i=0; i<pArray.length; i++){

 var ta = pArray[i].substr(0,pArray[i].indexOf('='));

 var v = pArray[i].substr(pArray[i].indexOf('=')+1,pArray[i].length);

 if(ta == "name" || ta == "id")id = 'id="' + v + '"';

 additionalParams += (activeX)?'\t<param name="' + ta + '" value="' + v + '" />\n': ' '+ ta + '="' + v + '"';

 }

 }

 //check is width and height are %, if is int add quotes

 if(width.toString().indexOf("%") == -1) width = '"' + width + '"';

 if(height.toString().indexOf("%") == -1) height = '"' + height + '"';

 if(activeX){

 if(t.isSecure){

 s = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + t.versionStr + '" ' + id + ' width=' + width + ' height=' + height + '>\n';

 }else{

 s = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + t.versionStr + '" ' + id + ' width=' + width + ' height=' + height + '>\n';

 }

 s += '\t<param name="movie" value="'+swfFile+'" />\n';

 s += '\t<param name="quality" value="high" />\n';

 s += '\t<param name="menu" value="false" />\n';

 s += '\t<param name="bgcolor" value="'+bgcolor+'" />\n';

 s += additionalParams;

 s += '</object>\n\n';

 return s;

 }else{

 if(t.isSecure){

 s = '<embed src="'+swfFile+'" quality="high" type="application/x-shockwave-flash" swLiveConnect=true pluginspage="https://www.macromedia.com/go/getflashplayer" width=' + width + ' height=' + height + ' bgcolor="'+bgcolor+'"'+additionalParams+'></embed>\n';

 }else{

 s = '<embed src="'+swfFile+'" quality="high" type="application/x-shockwave-flash" swLiveConnect=true pluginspage="https://www.macromedia.com/go/getflashplayer" width=' + width + ' height=' + height + ' bgcolor="'+bgcolor+'"'+additionalParams+'></embed>\n';

 }

 return s;

 }

 }else{

 if(!altFormat || altFormat == ""){

 altFormat = t.defaultAlt;

 }

 return altFormat;

 }

 }

 //calls getPluginTag but writes output from external to fix ie future plugin error

 t.embedMovie = function(swfFile,width,height,bgcolor,ver,altFormat,params){

 document.write(flash.getPluginTag(swfFile,width,height,bgcolor,ver,altFormat,params));

 }

 t.renderHomeFlash = function(){ // simple call for home page main flash object

 this.embedMovie("images/store/home_banner.swf",650,280,"#FFFFFF",7,"","allowScriptAccess=sameDomain");

 }

 t.renderHomeMarket = function(){

 this.embedMovie("images/store/markets_scroll.swf",118,105,"#828283","6.0.29","","allowScriptAccess=sameDomain");

 }

}

var flash = new FlashClass();

/****************************************

 * GlobalConfigClass for handling onLoad events (allows stacking)

 *

 * example:

 * <script language="javascript">

 * config.addOnLoadEvent("document.zipform.address.select();document.zipform.address.focus();");

 * </script>

 ****************************************/

function GlobalConfigClass() {

 var t = this;

 var onLoadEvents = new Array;

 /**

 * Event handler so that more than one onload event can be assigned per page.

 * @param pEvent a string of javascript code that you would normally put in the onload event.

 */

 t.addOnLoadEvent = function(pEvent) {

 onLoadEvents.push(pEvent);

 }

 /**

 * method to run all the queued up onload events.

 * this will be fired by the window.onload event and should only happen once.

 */

 t.runOnLoadEvents = function() {

 for(var pEvent in onLoadEvents) {

 try{

 eval(onLoadEvents[pEvent]);

 } catch(exc) {

 if(debug) alert(exc + "\nevent input: " + onLoadEvents[pEvent]);

 }

 }

 }

}

var config = new GlobalConfigClass();

/*==================================================================

 * A function to interface with my semi-cool xml web services

 *

 * First Param is the name of the cw_web_service (minus .php)

 * Second Param is the handler function reference for the return data

 * Additional Params are, name => value, pairs for passing params to the webservice

 * Function returns an xmlDoc (use JavaScript XML functions)

 *

 * # Example usage

 *

 * function getCityStateByZip( zipcode ) {

 * var functionRef = displayZip; // define the callback function to handle the request once it's done

 * getWebServiceXML('lookupZip', functionRef, 'zip_code',zipcode);

 * }

 * function displayZip( requestObj ) {

 * var xmlDoc = requestObj.responseXML;

 * var cityStateList = xmlDoc.documentElement.getElementsByTagName('zipcode');

 * var zips = new Array();

 * for (var i = 0; i < cityStateList.length; i++) {

 * zips[i] = cityStateList[i].getAttribute("city");

 * }

 * alert("found city/state ["+zips[0]+"]");

 * return zips[0];

 * }

 *

 *==================================================================*/

function getWebServiceXML() {

 var serviceName = arguments[0];

 var functionRef = arguments[1];

 request = false;

 if(typeof XMLHttpRequest != 'undefined') {

 request = new XMLHttpRequest();

 } else {

 try {

 request = new ActiveXObject("Msxml2.XMLHTTP");

 } catch(e) {

 try {

 request = new ActiveXObject("Microsoft.XMLHTTP");

 } catch(E) {

 request = false;

 }

 }

 }

 if(request) {

 request.open("POST", hostRoot+"/cw_web_services/"+serviceName+".php", true);

 request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");

 request.onreadystatechange=function() {

 loaded = false;

 switch(request.readyState) {

 case 4:

 if(debug) alert("state changing: " + request.readyState);

 if(request.status != 200) {

 // The request failed

 if (debug) alert("request failed: " + request.status);

 } else {

 if(!loaded) {

 if(debug) alert("request status: " + request.status);

 loaded = true;

 functionRef( request );

 }

 }

 break;

 default:

 break;

 }

 };

 var requestString = '';

 for( var x = 2; x < arguments.length - 1; x+=2 ) {

 requestString += arguments[x] + "=" + arguments[x+1] + "&";

 }

 //alert("requesting " + serviceName + "(" + requestString + ")");

 if(debug) alert("about to send request");

 request.send(requestString);

 } else {

 alert("Your browser does not support XMLHTTP requests because it is too old. Please update to a newer browser.\nFirefox, IE5, IE6, and Safari are all known to work with this script.");

 }

 return 1;

}

function MediaLoader()

{

 var t = this;

 t.loadMedia = function(location) {

 if(debug) alert(location);

 var mediaElement = document.getElementById(location);

 getWebServiceXML("getSiteMedia", t.loadPromoImage, "page_location", location)

 }

 t.loadPromoImage = function(req) {

 var elems = req.responseXML.getElementsByTagName("mediaItem");

 var l = elems.length;

 for(var i = 0; i < l; i++) {

 var curDiv = document.getElementById(elems[i].getAttribute("page_location"));

 try {

 curDiv.getElementsByTagName("a")[0].href = elems[i].getAttribute("media_link");

 curDiv.getElementsByTagName("img")[0].src = elems[i].getAttribute("media_address");

 curDiv.getElementsByTagName("span")[0].innerHTML = elems[i].getAttribute("short_text");

 }

 catch(e) {

 if(debug) alert("missing elements: " + e );

 }

 }

 }

}

var mediaLoader = new MediaLoader();