 function IFGSpain_preloadImages() {
	//v3.0
	var d=document; 
	if(d.images){ 
		if(!d.MM_p) 
			d.MM_p=new Array();
		var i, j=d.MM_p.length, a=IFGSpain_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){ 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
	}
}

//changes the form action and submits the form.
//It assumes that all the IFGSpain pages main form will be called frmMain.
function IFGSpain_PostToPage(sPage){
	//var obj = document.getElementById('frmMain');
	//var state = document.getElementByName('__VIEWSTATE');
	//obj.removeChild(state);
	document.frmMain.action = sPage;
	document.frmMain.submit();
}

function OpenDialogWindow(url){
      var newWin = window.open(url, 'ifgspain', 'scrollbars=1,toolbar=0,location=0,status=1,menubar=0,resizable=1,width=300,height=250');
      newWin.focus();
}

function OpenWindow(url){
      var newWin = window.open(url, 'ifgspain', 'scrollbars=1,toolbar=0,location=0,status=1,menubar=0,resizable=1');
      newWin.focus();
}

function OpenAuxWindow(sWidth, sHeight, url){
      var newWin = window.open(url, '', 'scrollbars=1,toolbar=0,location=0,status=1,menubar=0,resizable=1,width=' + sWidth + ',height=' + sHeight);
      newWin.focus();
}

function OpenNamedWindow(name, sWidth, sHeight, url){
      var newWin = window.open(url, name, 'scrollbars=1,toolbar=0,location=0,status=1,menubar=0,resizable=1,width=' + sWidth + ',height=' + sHeight);
      newWin.focus();
}

var overdiv="0";var xMouse=0;var yMouse=0;var MSIE=document.all //prepare for IE kludge

//set globals for mouse coordinates
function getMouse(Event){
	if (MSIE && document.body != null)
		xMouse = event.clientX + document.body.scrollLeft;
	else
		xMouse = Event.pageX;
		
	if (MSIE && document.body != null)
		yMouse = event.clientY + document.body.scrollTop;
	else
		yMouse = Event.pageY;
}

if (!MSIE) {document.captureEvents(Event.MouseMove);}
document.onmousemove=getMouse; // initiate event handler

function popLayer(popMessage){
	var desc="<table class='pop content' summary='*'>\n<tr class='pop'><td class='pop' width=350>\n";
	desc+=popMessage+"<\/td><\/tr><\/table>";

	var div = document.getElementById("popupBox");
	div.innerHTML=desc;
	div.style.left=xMouse+15+'px';
	div.style.top=yMouse-5+'px';

	var frame = document.getElementById("popupFrame")
	frame.style.left=div.style.left;
	frame.style.top=div.style.top;
	frame.width=div.offsetWidth;
	frame.height=div.offsetHeight;
}

function hideLayer(){
	if (overdiv == "0") {
		document.getElementById("popupBox").style.top="-500px";
		document.getElementById("popupFrame").style.top="-500px";
	}
}

function StatusMessage(message){
	window.status = message;
}

function isInterTel(argvalue)
{
	var re=new RegExp('^((00|[+])[ ]{0,1}[0-9]{1,3}[ ]{0,1}){0,1}((\\(0\\)){0,1}[0-9]{3,5}[ ]{0,1}){0,1}[0-9]{5,20}$');	
	return argvalue.match(re);
}

function isEmailAddr(emailAddr)
{
	var re = new RegExp('^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*([,;]\\s*\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*)*$');
	return (emailAddr.match(re)) ? true : false;
}

function isNum(argvalue){
 /*
	Parameters:
	argvalue (In)	: String value to check
	Return-value	: True/False depending on whether the string is	a valid	number
	*/

	var	re=new RegExp('^[-]{0,1}[0-9]*[.]{0,1}[0-9]*$');		

	if(argvalue.length>0){
		argvalue = argvalue.replace(',', '');
		
		if(re.exec(argvalue)==null)	
			return false;
		else 
			return	true;
	}
	else
		return false;			
}

function isLetter(argvalue){ 
	var re = new RegExp('^[a-zA-ZàáâãäçèéêëìíîïñòóôõöùúûüÀÁÂÃÄÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜ\\s]*$');
	return (argvalue.match(re)) ? true : false;
}

String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}
