var str = location.search.substring(1, location.search.length);
if (str=="" || str==null){ str=1;}
headers = new Array();
archiveGearsInsider = new Array();
archiveBooks = new Array();


function writearchivepromo(num, sPage){
	num = num-0;
	macheight=((num-1)*83)+125;
	num = ((str-1)*3)+num;
	var dataArray = new Array();
	if(sPage == "GearsInsider"){
		dataArray = archiveGearsInsider;
	}
	if(sPage == "Books"){
		dataArray = archiveBooks;
	}
	if (dataArray.length > num){
		if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.platform.indexOf("Mac")!=-1){
			document.write('<div style="position:absolute;top:'+macheight+'px;height:80px;">');
		}
		document.write('<div id="bluebox'+num+'" class="archivemain">');
		document.write('<div class="archiveimage"><img src="../images/site/'+dataArray[num][2]+'" width="61" height="58" alt="'+dataArray[num][0]+'" border="0" align="left"></div>');
		document.write('<div class="archiveright">');
		document.write('<div class="archiveheader">'+dataArray[num][0]+'&nbsp;</div>');
		document.write('<div class="archivetext">'+dataArray[num][1]+'</div>');
		document.write('<div class="archivebuttons">');
		writebuttons(num,sPage);
		document.write('</div></div></div>');
		if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.platform.indexOf("Mac")!=-1){
			document.write('</div>');
		}
	}
}

function writepromo(iNum){
	document.write('<div id="bluebox'+iNum+'" class="main">');
	document.write('<div align="right">'+headers[iNum][0]+'&nbsp;</div>');
	document.write('<div class="image"><img src="../images/site/'+headers[iNum][2]+'" width="61" height="58" alt="'+headers[iNum][0]+'" border="0" align="left"></div>');
	document.write('<div class="right">');
	document.write('<div class="text">'+headers[iNum][1]+'</div>');
	if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.platform.indexOf("Mac")!=-1){
		document.write('<div class="buttonsmac">');
	}else{
		document.write('<div class="buttons">');
	}
	writebuttons(iNum,"Index");
	document.write('</div></div></div>');
	this["blubox"+iNum]=document.getElementById("bluebox"+iNum);
	if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.platform.indexOf("Mac")!=-1){
		this["blubox"+iNum].style.left="0px";
	}

}


function loadJSData(){
	var promoGearsLoaded = false;
	var promoInsiderLoaded = false;
	var promoBooksLoaded = 0;
	var promoDVDLoaded = 0;
	for(y=0;y<headerArray.length;y++) {
		if(headerArray[y] == "Disney DVD") {
			if(promoDVDLoaded >= 2) {
				archiveBooks[archiveBooks.length] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
			}else{
				if(promoDVDLoaded == 0) {
					headers[2] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}
				/*if(promoDVDLoaded == 1) {
					headers[3] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}*/
				promoDVDLoaded++;
			}
		}
		if(headerArray[y] == "Last Minute Book Reports"){
			if(promoBooksLoaded >= 1){
				archiveBooks[archiveBooks.length] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
			}else{
				/*if(promoBooksLoaded == 0){
					headers[2] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}
				if(promoBooksLoaded == 1){
					headers[3] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}*/
				if(promoBooksLoaded == 0){
					headers[3] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}
				promoBooksLoaded++;
			}
		}
		if(headerArray[y] == "The Gears Behind the Ears"){
			if(promoGearsLoaded){
				archiveGearsInsider[archiveGearsInsider.length] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
			}else{
				if(promoInsiderLoaded){       // ordering, if insider is first, gears second
					headers[1] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}else{
					headers[0] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}
				promoGearsLoaded = true;
			}
		}
		if(headerArray[y] == "Disney Insider"){
			if(promoInsiderLoaded){
				archiveGearsInsider[archiveGearsInsider.length] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
			}else{
				if(promoGearsLoaded){     // ordering, if gears is first, insider second
					headers[1] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}else{
					headers[0] = new Array(headerArray[y], textArray[y], imageArray[y], urlArray[y]);
				}
				promoInsiderLoaded = true;
			}
		}
	}
}



function writebuttons(num,sPage){
	if(sPage == "GearsInsider"){
		theUrl = archiveGearsInsider[num][3]
	}
	if(sPage == "Books"){
		theUrl = archiveBooks[num][3]
	}
	if(sPage == "Index"){
		theUrl = headers[num][3]
	}
	document.write('<a href="'+theUrl+'" onMouseOver="document.getElementById(\'listen'+num+'\').src =\'../images/site/btn_listen_on.gif\'" onMouseOut="document.getElementById(\'listen'+num+'\').src =\'../images/site/btn_listen_off.gif\'">');
	document.write('<img src="../images/site/btn_listen_off.gif" width="55" height="18" alt="Listen Now" border="0" hspace="1" vspace="3" id="listen'+num+'"></a>');
	document.write('<a onClick="javascript:writePopUp(\'../instructions.html\'); return false" href="'+theUrl+'" onMouseOver="document.getElementById(\'download'+num+'\').src =\'../images/site/btn_download_on.gif\'" onMouseOut="document.getElementById(\'download'+num+'\').src =\'../images/site/btn_download_off.gif\'">');
	document.write('<img src="../images/site/btn_download_off.gif" width="55" height="18" alt="Download" border="0" vspace="3" hspace="2" id="download'+num+'"></a>');
}



function writeprevnext(sPage){
	var dataArray = eval("archive" + sPage);
	var targetPage = "";
	str=str-0;
	switch(sPage){
        case "GearsInsider":   targetPage = "archive_inside";  break
        case "Books":          targetPage = "archive_kids";    break
    }
	document.write('<div align="center">');
	if (str!=1){
		document.write('<a href="'+targetPage+'.html?'+(str-1)+'" onMouseOver="document.getElementById(\'prev\').src =\'../images/site/btn_prevpage_on.jpg\'" onMouseOut="document.getElementById(\'prev\').src =\'../images/site/btn_prevpage_off.jpg\'"><img src="../images/site/btn_prevpage_off.jpg" width="95" height="24" alt="Previous" border="0" hspace="30" vspace="10" id="prev"></a>');
	}
	if (dataArray.length>=(str*3)+1){
		document.write('<a href="'+targetPage+'.html?'+(str+1)+'" onMouseOver="document.getElementById(\'next\').src =\'../images/site/btn_nextpage_on.jpg\'" onMouseOut="document.getElementById(\'next\').src =\'../images/site/btn_nextpage_off.jpg\'"><img src="../images/site/btn_nextpage_off.jpg" width="95" height="24" alt="Next" border="0" hspace="30" vspace="10" id="next"></a>');
	}
	document.write('</div>');
}



function writePopUp(URL){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=240,height=120,left = 520,top = 420');");
}



function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase();
   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1);
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1);
   this.isIcab        = (ua.indexOf('icab') != -1);
   this.isAol         = (ua.indexOf('aol') != -1);
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) );
   //this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isMozilla     = (ua.indexOf('mozilla') != - 1 && ua.indexOf('firefox') != - 1);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );

   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);

   // 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 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
}



function getSaveString(){
	var returnString = "";
	var browser = new BrowserDetect();
	if(browser.isWin || browser.isWin32){
		if(browser.isMozilla){
			returnString = "To download, right click, then select 'Save Link As'";
		}else if (browser.isNS){
			returnString = "To download, right click, then select 'Save Link Target As'";
		}else{
			returnString = "To download, right click, then select 'Save Target As'";
		}
	}
	if(browser.isMac){
		if(browser.isIE){
			returnString = "To download, hold down the control button and click, then select 'Save Target As'.";
		}
		if(browser.isSafari){
			returnString = "To download, hold down the control button and click, then select 'Download Linked File As…'.";
		}
		if(browser.isNS || returnString == ""){
			returnString = "To download, hold down the control button and click, then select 'Save Link Target As…'.";
		}
	}
	return returnString;
}




