function getPageSize(){	
	var windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight){ // Explorer 6 Strict Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}	
	return windowHeight;
}

function setSize(ySize) {
	var obj = document.getElementById("leroyHome");
	obj.height = ySize+"px";
}
function setSize2(xSize) {
	var obj = document.getElementById("leroyHome");
	obj.width = xSize+"px";
}

function setOverlay(){
	var theOverlay = document.createElement('DIV');
	theOverlay.setAttribute('id','overlay')
	document.body.appendChild(theOverlay);
	var aSizes = getPageSize();
	document.body.style.height = aSizes;
}

function resizeSWF(ySize){
	setOverlay();
	setSize(ySize);
	//setSize2(1050);
}

function closeSWF(){
	var  obj = document.getElementById("overlay");
	setSize("222");
	obj.parentNode.removeChild(obj);
}


function openForm(){
	var theOverlay = document.createElement('DIV');
	theOverlay.setAttribute('id','overlay')
	theOverlay.style.zIndex = "600"
	document.body.appendChild(theOverlay);	
	var aSizes = getPageSize();
	document.body.style.height = aSizes;	
	var theDivForm = document.getElementById("theFormHome");
	theDivForm.style.display="block";
}

function openFormCV(){
	var theOverlay = document.createElement('DIV');
	theOverlay.setAttribute('id','overlay')
	theOverlay.style.zIndex = "600"
	document.body.appendChild(theOverlay);	
	var aSizes = getPageSize();
	document.body.style.height = aSizes;	
	var theDivForm = document.getElementById("theFormHomeCV");
	theDivForm.style.display="block";
}

function openFormCVNoticias(cod,tienda,subject){
	var theOverlay = document.createElement('DIV');
	theOverlay.setAttribute('id','overlay')
	theOverlay.style.zIndex = "600"
	document.body.appendChild(theOverlay);	
	var aSizes = getPageSize();
	document.body.style.height = aSizes;
	jQuery("#theFormHomeCVNoticias #rp_command").val(cod);
	jQuery("#theFormHomeCVNoticias #tienda").val(cod);
	jQuery("#theFormHomeCVNoticias #region").val(cod);
	jQuery("#theFormHomeCVNoticias #tiendaFija").val(tienda);
	jQuery("#theFormHomeCVNoticias #rp_subject").val(subject);
	jQuery("#theFormHomeCVNoticias").show();
	window.scrollTo(0,0);
}
/*
function openFormCVNoticias(){
	var theOverlay = document.createElement('DIV');
	theOverlay.setAttribute('id','overlay')
	theOverlay.style.zIndex = "600"
	document.body.appendChild(theOverlay);	
	var aSizes = getPageSize();
	document.body.style.height = aSizes;	
	var theDivForm = document.getElementById("theFormHomeCVNoticias");
	theDivForm.style.display="block";
}

function openFormCVNoticias2(){
	var theOverlay = document.createElement('DIV');
	theOverlay.setAttribute('id','overlay')
	theOverlay.style.zIndex = "600"
	document.body.appendChild(theOverlay);	
	var aSizes = getPageSize();
	document.body.style.height = aSizes;	
	var theDivForm = document.getElementById("theFormHomeCVNoticias2");
	theDivForm.style.display="block";
}
*/
function closeForm(){
	var theF = document.getElementById("theFormHome");
	theF.style.display = "none";
	var  obj = document.getElementById("overlay");
	obj.parentNode.removeChild(obj);
}

function closeFormCV(){
	var theF = document.getElementById("theFormHomeCV");
	theF.style.display = "none";
	var  obj = document.getElementById("overlay");
	obj.parentNode.removeChild(obj);
}

function closeFormCVNoticias(){
	jQuery("#theFormHomeCVNoticias").hide();
	var obj = document.getElementById("overlay");
	obj.parentNode.removeChild(obj);
}

function closeFormCVNoticias2(){
	var theF = document.getElementById("theFormHomeCVNoticias2");
	theF.style.display = "none";
	var  obj = document.getElementById("overlay");
	obj.parentNode.removeChild(obj);
}


/*checkea formato de dirección de e-mail*/
 /*function validarEmail(campoId) {
 valor = campoId.value;
  if (/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(valor)){   
   return true;
  } else {	
  	return false;
  }
 }  
*/
//valida campo caracteres numericos
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function controlMsg(caso,valor){

	switch(caso){
			case 0:
					var elem = document.getElementById("msgMail");
					break;
					
			case 1:
					var elem = document.getElementById("msgCondiciones");
					break;					
	
			case 2:
					var elem = document.getElementById("msgCP");
					break;	
	}	

	if(valor){
			elem.style.visibility = "hidden";
		}else{
				elem.style.visibility = "visible";							
			}			
}

 

//jQuery.noConflict();


var newsitems;
var curritem=0;
var iPause=0;
var clickTicker = -1;
var speedTicker = 6000;//milisegundos
var intTimer;



jQuery(document).ready(function(){
	$("#ticker span").each(
		function(i){
			$(this).bind("click",function(){	
					if(i==curritem){return false;}	
					clickTicker = i;
					tickClick();
				}										  
			)
		}	
	);

	
    var tickerSelector = "#ticker li";
    newsitems = $(tickerSelector).hide().hover(
        function(){
            jQuery(this).addClass("hovered");
            iPause=1;
        },
        function(){
            jQuery(this).removeClass("hovered");
            iPause=0;
        }
    ).filter(":eq(0)").show().add(tickerSelector).size();
    intTimer = setInterval(ticknews,speedTicker); 

});


function ticknews() {
  if (iPause==0){
    jQuery("#ticker li:eq("+curritem+")").fadeOut("slow",function(){$(this).hide();});
    curritem = ++curritem%newsitems;
		$("#ticker span").each(function(i){
				if(curritem==i){
					$(this).addClass("active");
					}else{
						$(this).removeClass("active");
						}

			})		
    jQuery("#ticker li:eq("+curritem+")").fadeIn("slow", function(){													  
		});	
    }
}


function tickClick() {
  if (iPause==0){
	 

    jQuery("#ticker li:eq("+curritem+")").fadeOut("fast",function(){$(this).hide();});

	$("#ticker span").each(function(i){
			if(clickTicker==i){
				$(this).addClass("active");
				}else{
					$(this).removeClass("active");
			}
	})	
	
	
    jQuery("#ticker li:eq("+clickTicker+")").fadeIn("slow", function(){
		clearInterval(intTimer);	
			intTimer= "";
			curritem = clickTicker;	
			intTimer = setInterval(ticknews,speedTicker);
		});	

    }
}

