var timesover=0;
var timerID = null;
//var boolFirstMenuFlag = true;
var boolTimerOn = false;
var intTimecount = 450;
var intRunCount = 0;

var timer = null;
var timerOn = false;
var timecount = 10000;
var runCount = 0;

var timerSound = null;
var timecountSound = 10000;

var timerDuracionSound = null;
var timeDuracionSound = 15000;

var intTabActive = 999;
var intNumTabs = 5;
var asTabs = new Array();
	asTabs[0] = "menu1";
	asTabs[1] = "menu2";
	asTabs[2] = "menu3";
	asTabs[3] = "menu4";
	asTabs[4] = "menu5";

function cerrarVentana() {
	window.close();
}

function Volver() {
	history.go(-1);
}

function doInitializeMenu() {
	for (i=0; i<intNumTabs; i++)
	{
			if(document.getElementById("menuitem-" + asTabs[i]).className=="mainmenuitem active")
				intTabActive = i;
	}
}

function settimeover(){
timesover=1;
}
function doMenuOn(id) {
	/* initialize the menu to figure out which tab is set to active */
	if (intRunCount < 1)
	{
		doInitializeMenu();
		intRunCount++;
	}

	
	//if (boolFirstMenuFlag == true)
	//{

		/*hide any menus that might be open*/
		if (document.getElementById("menuitem-" + id).className == "mainmenuitem active" && timesover==0)
		{
		//alert("active");
		timesover=1;
		}
		else
		{
		timesover=1;
		doHideAll();
		/* if statement to check if the submenu acutally exists, because the home menu doesn't have one */
		if(document.getElementById("submenu-" + id))
			document.getElementById("submenu-" + id).style.display = "block"; /*turn on the submenu*/
		
		/*change the style of the tab to the hover style*/	
		document.getElementById("menuitem-" + id).className = "mainmenuitem hover"; 
	
		/* stop the timer */
		doStopTime(); 
		}
	//}
}
function doMenuOff(id) {
for (i=0; i<intNumTabs; i++)
	{
			if(document.getElementById("menuitem-" + asTabs[i]).className=="mainmenuitem active")
				timesover=1;
	}


	/*start the timer */
	doStartTime(); 
}
function doSubMenuOn(){
	/* stop the timer */
	doStopTime(); 
}
function doSubMenuOff(){
	 /* start the timer */
	 doStartTime();
}
function doHideAll(){
	
	for (i=0; i<intNumTabs; i++)
	{
		/* if statement to check if the submenu exists before we try to hide it */
		if(document.getElementById("submenu-" + asTabs[i]))
			document.getElementById("submenu-" + asTabs[i]).style.display = "none"; /* hide the submenu */
		/*set all tabs to the inactive style */
		document.getElementById("menuitem-" + asTabs[i]).className="mainmenuitem inactive";
	}
	/*set the active tab to the active style*/
	if (intTabActive < 999)
	{
		document.getElementById("menuitem-" + asTabs[intTabActive]).className="mainmenuitem active";
	}
}
function doStopTime(){
	if (boolTimerOn){
		clearTimeout(timerID);
	timerID = null;
	boolTimerOn = false;
	}

}
function doStartTime(){
	if (boolTimerOn == false) {
		timerID=setTimeout( "doHideAll()" , intTimecount);
		boolTimerOn = true;
	}
}
function setcoords(){

if (document.newaccount.dropdowncountry.value=="Canada" || document.newaccount.dropdowncountry.value=="United States" || document.newaccount.txtpostalcode || document.newaccount.txtzipcode){
    var myPageX;
    var myPageY;
    if (document.all){
	myPageX = document.body.scrollLeft;
	myPageY = document.body.scrollTop;
	}
    else{
	myPageX = window.pageXOffset;
	myPageY = window.pageYOffset;
	}
    document.newaccount.PageX.value = myPageX;
    document.newaccount.PageY.value = myPageY;
    document.newaccount.submit();
    }
    }
    
function stopTimerCarrusel(){
	if (timerOn){
		clearTimeout(timer);
		timer = null;
		timerOn = false;
	}
}

function stopTimerSound(){	
	clearTimeout (timerSound);
	timerSound=null;
}

function doStopCarrusel(URL,pagina,boton){
	stopRetardo();
	stopTimerCarrusel();
	stopTimerSound();
	doStartCarrusel(URL,pagina,boton);
	ponSonido();	
}

function doStartCarrusel(URL,pagina,boton){
	if (timerOn == false) {
		timer=setTimeout( "carrusel("+URL+","+pagina+","+boton +")" , timecount);
		timerOn = true;
	}
}

function carrusel(URL,pagina,boton) {
	stopRetardo();
	stopTimerSound();
	window.open(URL+"carrusel.jsp?CODPANTALLA="+pagina+"&amp;CODBOTON="+boton,"my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, fullscreen=yes");
}

function CerrarCarrusel() {	
	window.opener.ponSonido();
	window.close();
}

function quitaSonidos() {	
	window.opener.document.getElementById("son").stop();
}


function ponSonido() {
	 stopRetardo(); 
	 timerSound=setTimeout( "play()" , timecountSound);
}

function play() {	
	  stopTimerSound();	
	  sound = document.getElementById("son");
	  sound.play();
	  startRetardo();
}

function startRetardo() {
	  timerDuracionSound=setTimeout( "ponSonido()" , timeDuracionSound);		
}

function stopRetardo() {
	  clearTimeout (timerDuracionSound);
	  timerDuracionSound=null;			
}

var ventana=null;
var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false

