// JavaScript Document
var init = 0;
var pl;
var plSUB;
var plIMG;
var plTXT;
var totalList;
var selCONTAINER;
var thisMenu;
var thisMenuIDn;

if (window.XMLHttpRequest){ // Mozilla, Safari,...
	// Active XMLHTTPRequest Function
	http_request = new XMLHttpRequest();
}else if(window.ActiveXObject){ // IE
	// Active XMLHTTPRequest Function
	http_request = new ActiveXObject("Microsoft.XMLHTTP");
}

function makeSRequest(url,thisContainer,thisMenuID){
	conURL = url;
	http_request.abort();
	http_request.onreadystatechange = displayOnPageContents;
	selCONTAINER = thisContainer;
	thisMenuIDn = thisMenuID;
	thisMenu = document.getElementById("pim_"+thisMenuID);

	http_request.open('GET', url, true);
	http_request.send(null);
	return http_request;
}

function displayOnPageContents(){
	if (http_request.readyState == 4){
		if (http_request.status == 200){
			document.getElementById(selCONTAINER).innerHTML = http_request.responseText;
			if(selCONTAINER == 'saveTimerContainer') begintimer();
			ctr = 0;
			while(ctr < 3){
				if(ctr == 0) document.getElementById('pim_'+ctr).style.background = 'url(images/product-description.jpg) no-repeat top';
				if(ctr == 1) document.getElementById('pim_'+ctr).style.background = 'url(images/safety-information.jpg) no-repeat top';
				if(ctr == 2) document.getElementById('pim_'+ctr).style.background = 'url(images/side-effects.jpg) no-repeat top';
				ctr++;
			}
			if(thisMenuIDn == 0) thisMenu.style.background = 'url(images/product-description-hover.jpg) no-repeat top';
			if(thisMenuIDn == 1) thisMenu.style.background = 'url(images/safety-information-hover.jpg) no-repeat top';
			if(thisMenuIDn == 2) thisMenu.style.background = 'url(images/side-effects-hover.jpg) no-repeat top';
		}else{
			if(selCONTAINER != 'saveTimerContainer') alert('There was a problem with the request. Please try again.');
		}
	}
}

// These are used for preventing Javascript Errors //

// These are used for preventing Javascript Errors //

function pl_expand(plID){
	if(init == 1){
		pl = document.getElementById("pl_"+plID);
		plSUB = document.getElementById("plsub_"+plID);
		plIMG = document.getElementById("plimg_"+plID);
		plTXT = document.getElementById("thisList"+plID);
		totalList = document.getElementById("totalList").value;
		/*
		ctr = 0;
		while(ctr < totalList){
			if(ctr != 0){
				document.getElementById("pl_"+ctr).style.background = 'url(images/prl-menu-bg.jpg) repeat-x top';
				document.getElementById("plimg_"+ctr).src = 'images/prl-menu-icon.gif';
			}
			else document.getElementById("pl_"+ctr).style.background = 'url(images/bestseller-menu-bg.jpg) repeat-x top';
			document.getElementById("pl_"+ctr).style.fontWeight = 'normal';
			document.getElementById("pl_"+ctr).style.textDecoration = 'none';
			document.getElementById("plsub_"+ctr).style.display = 'none';
			document.getElementById("thisList"+ctr).value = 0;
			ctr++;
		}
		*/
		if(plTXT.value == 0){
			plSUB.style.display = 'block';
			plTXT.value = 1;
			if(plID != 0){
				plIMG.src = "images/prl-menu-select-icon.gif";
				pl.style.background = 'url(images/prl-menu-bg-hover.jpg) repeat-x top';
			}else{
				pl.style.background = 'url(images/bestseller-menu-bg-hover.jpg) repeat-x top';
			}
		}else{
			plSUB.style.display = 'none';
			plTXT.value = 0;
			if(plID != 0){
				plIMG.src = "images/prl-menu-icon.gif";
				pl.style.background = 'url(images/prl-menu-bg.jpg) repeat-x top';
			}else{
				pl.style.background = 'url(images/bestseller-menu-bg.jpg) repeat-x top';
			}
		}
		pl.style.fontWeight = 'bold';
		pl.style.textDecoration = 'underline';
	}
}

function pl_hover(plID){
	if(init == 1){
		pl = document.getElementById("pl_"+plID);
		plTXT = document.getElementById("thisList"+plID);
		
	}
}

function pl_out(plID){
	if(init == 1){
		pl = document.getElementById("pl_"+plID);
		plTXT = document.getElementById("thisList"+plID);
	
	}
}