//=====================================================================
//  Demo: http://chrispoole.com/scripts/dom_image_rollover_hover
//=====================================================================
function domRollover() {
	if (navigator.userAgent.match(/Opera (\S+)/)) {
		var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]);
	}
	if (!document.getElementById||operaVersion <7) return;
	var imgarr=document.getElementsByTagName('img');
	var imgPreload=new Array();
	var imgSrc=new Array();
	var imgClass=new Array();
	for (i=0;i<imgarr.length;i++){
		if (imgarr[i].className.indexOf('domroll')!=-1){
			imgSrc[i]=imgarr[i].getAttribute('src');
			imgClass[i]=imgarr[i].className;
			imgPreload[i]=new Image();
			if (imgClass[i].match(/domroll (\S+)/)) {
				imgPreload[i].src = imgClass[i].match(/domroll (\S+)/)[1]
			}
			imgarr[i].setAttribute('xsrc', imgSrc[i]);
			imgarr[i].onmouseover=function(){
				this.setAttribute('src',this.className.match(/domroll (\S+)/)[1])
			}
			imgarr[i].onmouseout=function(){
				this.setAttribute('src',this.getAttribute('xsrc'))
			}
		}
	}
}
domRollover();


//=====================================================================
//  Swap Image 
//=====================================================================
function SwapImg(ID1) {
	var PIC = document.getElementById(ID1);
	var SPLIT = PIC.src.split(".");
	if (SPLIT[3]=="png") {
		PIC.src = SPLIT[0]+"."+SPLIT[1]+"."+SPLIT[2]+".MO."+SPLIT[3];
	}
	if (SPLIT[3]=="MO") {
		PIC.src = SPLIT[0]+"."+SPLIT[1]+"."+SPLIT[2]+"."+SPLIT[4];
	}
}
function SwapImg2(ID1) {
	var PIC = document.getElementById(ID1);
	var SPLIT = PIC.src.split(".");
	if (SPLIT[3]=="png") {
		PIC.src = SPLIT[0]+"."+SPLIT[1]+"."+SPLIT[2]+".MO."+SPLIT[3];
	}
	if (SPLIT[3]=="MO") {
		PIC.src = SPLIT[0]+"."+SPLIT[1]+"."+SPLIT[2]+"."+SPLIT[4];
	}
	PIC.nextSibling.checked = (PIC.nextSibling.checked==true) ? false : true ;
}


//==================================================================
//  Show-Hide														
//==================================================================
function showhide(x) {
	document.getElementById(x).style.display = (document.getElementById(x).style.display=='block') ? 'none' : 'block';
}


//==================================================================
//  Select corresponding option from dropdown						
//==================================================================
function PickOption(Opt,Sel) {
	var selectbox = document.getElementById(Sel);
	for (i=0; i<selectbox.options.length; i++) {
		if (selectbox.options[i].value == Opt) {
			selectbox.selectedIndex = i;
		}
	}
}

//==================================================================
//  Change the text in empleos										
//==================================================================
function ChangeEmpleosText(myChoice){
	if (myChoice=='I') {
		document.getElementById("text_ic").innerHTML = "Yo soy un(a) candidato(a) buscando";
		document.getElementById("opt1").innerHTML = 'Postularme';
		document.getElementById("opt2").innerHTML = 'Empleo';
	}
	else if (myChoice=='C') {
		document.getElementById("text_ic").innerHTML = "Somos una compañía buscando";
		document.getElementById("opt1").innerHTML = 'Postularnos';
		document.getElementById("opt2").innerHTML = 'Empleados';
	}
}

//==================================================================
//  Redirect the user based on his choices							
//==================================================================
function RedirectEmpleos (FORM){
	// get vars
	var PE = document.EmpleosForm.pe.selectedIndex;
	var IC = (document.getElementById("opt1").innerHTML == 'Postularme') ? 'I' : 'C' ;
	// pick something
	if (PE == 0) alert("Debe eligir una opcion!");
	// if user wants to place an ad...
	else if (PE==1 && IC=='I') window.location = "usercheckout.php?step=3&category=903&listingid=0&productid=17";
	else if (PE==1 && IC=='C') window.location = "usercheckout.php?step=3&category=902&listingid=0&productid=17";
	// if user wants to search...
	else if (PE == 2 && IC=='I') window.location = "search.php?cat=empleos_I";
	else if (PE == 2 && IC=='C') window.location = "search.php?cat=empleos_C";
	// done
	return false;
}
