/*
  unlimioo
  http://www.unlimioo.com
  unlimioo, S.L.
  Copyright (c) 2009
*/
/**** Preload images ****/
var myimages=new Array();
function preloadimages() {
	for(i=0;i<preloadimages.arguments.length;i++) {
		myimages[i] = new Image();
		myimages[i].src = preloadimages.arguments[i];
	}
}
/************************/
function trim( str, charlist ) {
	var whitespace, l = 0;
	if (!charlist) {
		whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
	} else {
		whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
	}
	l = str.length;
	for (var i = 0; i < l; i++) {
		if (whitespace.indexOf(str.charAt(i)) === -1) {
			str = str.substring(i);
			break;
		}
	}
	l = str.length;
	for (i = l - 1; i >= 0; i--) {
		if (whitespace.indexOf(str.charAt(i)) === -1) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}

/* Popup window */
function openPopup(URL,ancho,alto,izq,sup) {
var Sx=((screen.availWidth-ancho)/2)-5;
var Sy=((screen.availHeight-alto)/2)-15;
window.open(URL,'new','width='+ancho+'px,height='+alto+'px,top='+Sy+'px,left='+Sx+'px,directories=0,scrollbars=1,status=0,location=0,menubar=0,toolbar=0,resizable=0');
}
function setFocus(fieldName) {
	var objRef = myGetElementById(fieldName);
	if(objRef != null) {
		objRef.focus();
	}
}
function setVisible(objName) {
	var bRes = false;
	var objRef = myGetElementById(objName);
	if(objRef != null) {
		setOpacity(objName,100);
		objRef.style.visibility = 'visible';
		objRef.style.display = 'block';
		bRes = true;
	}
	return bRes;
}
function setVisible_ceroOpacity(objName) {
	var bRes = false;
	var objRef = myGetElementById(objName);
	if(objRef != null) {
		setOpacity(objName,0);
		objRef.style.visibility = 'visible';
		objRef.style.display = 'block';
		bRes = true;
	}
	return bRes;
}
function setHidden(objName) {
	var bRes = false;
	var objRef = myGetElementById(objName);
	if(objRef != null) {
		setOpacity(objName,0);
		objRef.style.visibility = 'hidden';
		objRef.style.display = 'none';
		bRes = true;
	}
	return bRes;
}
function setHidden_AllcontentLayers() {
	var strIndex = "";
	var bRes = false;
	for(var i=1; i<=10; i++) {
		bRes = false;
		strIndex = i;
		if(i <= 10) {
			strIndex = "0" + i;
		}
		bRes = setHidden("contentLayer" + strIndex + "");
		if(bRes == false) {
			break;
		}
	}
}
/************************/
var fade_duration = 750;  /* 750 millisecond fade = 0.75 sec */
var fade_steps = 20;       /* number of opacity intervals   */
var fade_delay = 4000;     /* 4 sec delay before fading out */

/* get the opacity of the element (between 0.0 and 1.0) */
function getOpacity(objName) {
	var objRef = myGetElementById(objName);
	if(objRef != null) {
		if(objRef.style.opacity != null) {
			// Safari 1.2, newer Firefox and Mozilla, CSS3
			return objRef.style.opacity;
		}
		if(objRef.style.MozOpacity != null) {
			// Older Mozilla and Firefox
			return objRef.style.MozOpacity;
		}
		if(objRef.style.KhtmlOpacity != null) {
			// Safari<1.2, Konqueror
			return objRef.style.KhtmlOpacity;
		}
	}
}
/* set the opacity of the element (between 0.0 and 1.0) */
function setOpacity(objName, level) {
	var objRef = myGetElementById(objName);
	if(objRef != null) {
		if(objRef.style.opacity != null) {
			// Safari 1.2, newer Firefox and Mozilla, CSS3
			objRef.style.opacity = level;
		}
		if(objRef.style.MozOpacity != null) {
			// Older Mozilla and Firefox
			objRef.style.MozOpacity = level;
		}
		if(objRef.style.KhtmlOpacity != null) {
			// Safari<1.2, Konqueror
			objRef.style.KhtmlOpacity = level;
		}
		if(objRef.style.filter != null) {
			// IE/Win
			objRef.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + parseInt(level * 100) + ");";
		}
	}
}
function fadeInEffect(objName, objHeight) {
	var i = 0;
	for(i = 0; i <= 1; i += (1/fade_steps)) {
		setTimeout("setOpacity('" + objName + "', " + i + ")", i * fade_duration);
	}
	setTimeout("setOpacity('" + objName + "', 1)", fade_duration);
}
function fadeOutEffect(objName, objHeight) {
	var i = 0;
	for(i = 0; i <= 1; i += (1/fade_steps)) {
		setTimeout("setOpacity('" + objName + "', " + (1 - i) + ")", i * fade_duration);
	}
	setTimeout("setOpacity('" + objName + "', 0)", fade_duration);
}
/************************/
var selectedSuboption = "";
var alertTimerId = 0;
var imgPathMove = "";
var imgPathStill = "";
var imgPathSelected = "";

function setSelected(objName) {
	var objRefTmp = null;
	var strIndex = "";
	var objRef = myGetElementById(objName);
	if(objRef != null) {
		selectedSuboption = trim(objName);
		for(var i=1; i<=10; i++) {
			strIndex = i;
			if(i < 10) {
				strIndex = "0"+i;
			}
			objRefTmp = myGetElementById("list" + strIndex);
			if(objRefTmp != null) {
				objRefTmp.src = imgPathStill;
			} else {
				break;
			}
		}
		objRef.src = imgPathSelected;
	}
}
function setImageMove(imgPath) {
	imgPathMove = trim(imgPath);
}
function setImageStill(imgPath) {
	imgPathStill = trim(imgPath);
}
function setImageSelected(imgPath) {
	imgPathSelected = trim(imgPath);
}
function startAnimation(objName) {
	if(trim(objName) != selectedSuboption) {
		var objRef = myGetElementById(objName);
		if(objRef != null) {
			/* Stop after 0.03 (s/frame) * 7 (num_frames) = 210 ms) */
			alertTimerId = setTimeout("stopAnimation('" + objName + "','" + imgPathSelected + "');",210);
			objRef.src = imgPathMove;
		}
	}
}
function stopAnimation(objName,imgPath) {
	clearTimeout(alertTimerId);
	var imgPathToSet = "";
	if(imgPath) {
		imgPathToSet = imgPath;
	} else {
		imgPathToSet = imgPathStill;
	}
	if(trim(objName) != selectedSuboption) {
		var objRef = myGetElementById(objName);
		if(objRef != null) {
			objRef.src = imgPathToSet;
		}
	}
}
/************************/
function validaEmail(strEmail) {
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail)) {
		return true;
	}
	return false;
}


/***********************/
