//find query attached
var pageLoc = String(document.location);
var queryPos = pageLoc.indexOf("?");
var queryString = (queryPos < 0) ? "" : pageLoc.substring(queryPos);

function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
}

if (getQueryVariable('section')){
	if (getQueryVariable('section') == ''){
		//
	}
}

//popup
function popup( url, w, h, windowName, r, s ) {
	win = window.open(url, windowName, 'height=' +h+ ', width=' +w+ ', resizable=' +r+ ', status=no, scrollbars=' +s+ ', location=no, menubar=no, toolbar=no, left=50, top=50');
	win.focus();
}
function popupFull( url, w, h, windowName, r, s ) {
	alertTest('popupFull');
	win = window.open(url, windowName, 'height=' +h+ ', width=' +w+ ', resizable=' +r+ ', status=no, scrollbars=' +s+ ', location=no, menubar=yes, toolbar=no, left=50, top=50');
	win.focus();
}

// browser and os detect
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('safari')) browser = "safari"
else if (checkIt('msie')) browser = "msie"
else if (!checkIt('compatible')) browser = "ns"
else browser = "unknown";

if (checkIt('windows')) os = "pc"
else if (checkIt('mac')) os = "mac"
else os = "unknown";

function checkIt(string){
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function linksComingSoon(){
	alertTest('linksComingSoon');
	win = popup('links_cs.html', 300, 200, 'links', 0, 0);
	win.focus();
}

function popLinks(){
	win = popup('links.html', 600, 550, 'links', 0, 0);	
}

//order now link
function orderNow(){
	alertTest('orderNow');
	trackSection('order');
	//win = window.open('');
	win = popup('http://disneyvideos.disney.go.com/moviefinder/calltoorder.html', 380, 265, 'calltoorder', 'no', 'no');
	win.focus();
}

//clips
function popClip(number){
	switch(number){
		case 1: //trailer
			hbxPageHit('trailer', 'jungle+book/multimedia/trailer;multimedia/animated+classics/jungle+book/trailer');
			popup('http://www.totaleclips.com/player/splash.aspx?custid=3&playerid=2&clipid=e32819', 360, 480, 'trailer', 'no', 'no');
			break;
		default:
			break;
	}
}

//wallpapers - pass me the number and width
//wallpaper(2, 800);
function wallpaper(number, width){
	//popup('wallpaper.html?number='+number+'&width='+width, 700, 500, 'wallpaper', 'yes', 'yes');
	var n =1;
	switch(width){
		case 800 : n=600; break;
		case 1024 : n=768; break;
		case 1280 : n=1024; break;
		case 1600 : n=1200; break;
		}
	
	popup('download/wallpaper/wp'+number+'_'+width+'.jpg',width,n,'wallpaper','no','no');
}

//screensaver - pass me the os (win or osx)
//screensaver('win');
function screensaver(os){
	alertTest('screensaver(\''+ os +'\')');
	switch(os){
		case undefined: //instructions
			win = popup('screensaver.html', 600, 550, 'ss', 0, 0);
			break;
		case 'pc': //windows
			hbxPageHit('ss+win', 'jungle+book/downloads/screensavers;downloads/animated+classics/jungle+book/screensavers');
			popup('download.html?file=download/JungleBook.exe.zip', 300, 250, 'download', 'no', 'no');//sp2 fix
			break;
		case 'osx': //osx
			hbxPageHit('ss+osx', 'jungle+book/downloads/screensavers;downloads/animated+classics/jungle+book/screensavers');
			popup('download.html?file=download/JungleBook.sit', 300, 250, 'download', 'no', 'no');//sp2 fix
			break;
		default:
			break;
	}
}

//buddy icons
function buddyIcons(){
	popup('ikony.html', 550, 520, 'icons', 'no', 'no')
}

//buddy icons
function buddyIconSet(){
	hbxPageHit('icons+download+set', 'jungle+book/downloads/icons;downloads/animated+classics/jungle+book/icons');
	popup('download.html?file=download/JungleBook_AIM-Icons.zip', 300, 250, 'download', 'no', 'no');//sp2 fix
}

//buddy icon download
function buddyIcon(icon){
popup('download/icon/'+icon+'.jpg',48,48,'icon','no','no');
   // var pagePath = "" + window.location;
   // var pageRoot = pagePath.substring(0,pagePath.lastIndexOf("/")+1) + "download/icons/";
//	var iconUrl = "aim:BuddyIcon?src="+pageRoot+icon+'.gif';
	//var iconUrl = pageRoot+icon;
//	if (os == 'pc'){
//		hbxPageHit('icon+'+icon, 'jungle+book/downloads/icons;downloads/animated+classics/jungle+book/icons');
//		document.location = iconUrl;
//	}
//	else alert ('This is a PC feature only.  Please click "Download Full Set".');

}

//animated signatures
function emailSig(){
	popup('emailsig.html', 800, 600, 'animsig', 'no', 'no')
}

//games
function popMowgliGame(){
	alertTest('popMowgliGame');
	popup('games/mowgli/index.html', 600, 560, 'mowgli', 'no', 'no');
}
function popKaaGame(){
	alertTest('popKaaGame');
	popup('games/kaa/index.html', 770, 660, 'kaa', 'no', 'no');
}

//blog tools
function popBlogTools(){
	alertTest('popBlogTools');
	win = popup('countdown.html', 600, 550, 'blog', 'yes', 'yes'); //live link
	//win = popup('countdown_cs.html', 300, 200, 'links', 0, 0); //countdown coming soon
	win.focus();
}

function popSweeps(){
	//win = window.open('http://disney.com');
	win = popup('sweeps_cs.html', 600, 550, 'links', 0, 0); //countdown coming soon
	actionTag('Jungle_Book_Sweeps');
}

//printables
function printColoringPage(filename){
	alertTest('printColoringPage(\''+ filename +'\')');
	popupFull('img/printables/'+filename, 729, 612, 'coloring', 'yes', 'yes');//pop printable
}

//disclaimer
function openDisclaimer(URL){
	win = window.open('http://disney.go.com/disneyvideos/javascript/disclaimer/disclaimer.html?'+ URL, 'intermediate', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=370,height=210');
}

