//THIS IS THE SCRIPT TO IDENTIFY AN ELEMENT
function myid(myelement)
{
	return document.getElementById(myelement);
}
//TO HERE





//THIS IS THE SCRIPT TO SWAP LAYERS Z-INDEX
function swap(thelayer, otherlayer)
{
	myid(thelayer).style.zIndex = 2;
	myid(otherlayer).style.zIndex = 1;
}
//TO HERE





//THIS IS THE LOAD IMAGES AND ROLLOVER SCRIPT
function 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=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];}}
}

function swapimgrestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findobj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function swapimage() { //v3.0
	var i,j=0,x,a=swapimage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=findobj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//to here





//THIS IS THE TABLE ROLLOVER EFFECT
function setcellbgcolor(id,color)
{
	var c = document.getElementById ? document.getElementById(id) :
	document.all ? document.all[id] :
	document.layers ? document[id+'Outer'].document[id+'Inner'] : null;
	if (document.layers)
	{
		c.background.src = '';
		c.bgColor = color;
	}
	else
	{
		c.style.background = '';
		c.style.backgroundColor = color;
	}
}

function setcellbgimage(id,sImgSrc)
{
	var c = document.getElementById ? document.getElementById(id) :
	document.all ? document.all[id] :
	document.layers ? document[id+'Outer'].document[id+'Inner'] : null;
	if (document.layers)
	{
		c.background.src = sImgSrc;
	}
	else
	{
		c.style.backgroundImage = 'url('+sImgSrc+')';
	}
}
//to here





//MAKES A URL
function geturl(formname, fieldname) {

	var lien = prompt("write the link title","");
	var url = prompt("write the url","");

	if (lien != null && url != null)
	{
		if ((url.indexOf("http://") == 0) || (url.indexOf("ftp.") == 0)){
			var mouse_out = 'window.status=""; return true';
			var mouse_over = 'window.status="open link in popup"; return true';
			var the_name = "<a href='" + url + "' target='_blank' onmouseout='" + mouse_out + "' onmouseover='" + mouse_over + "'>" + lien + "</a>";
			window.document[formname][fieldname].value+=the_name;
			window.document[formname][fieldname].focus();
		}
		else
		{
			alert ("You should enter a url with the format \n'http://' or 'ftp.' ");
		}

	}

}
//to here





//MAKES AN EMAIL
function getemail(formname, fieldname) {

	var lien = prompt("write the email title","");
	var email = prompt("write the email address","");

	if (lien != null && email != null)
	{
		if ((email.indexOf("@") != -1) && (email.indexOf(".") != -1)){
			var mouse_out = 'window.status=""; return true';
			var mouse_over = 'window.status="email me"; return true';
			var the_name = "<a href='mailto:" + email + "' onmouseout='" + mouse_out + "' onmouseover='" + mouse_over + "'>" + lien + "</a>";
			window.document[formname][fieldname].value+=the_name;
			window.document[formname][fieldname].focus();
		}
		else
		{
			alert ("You should enter an email address with the format \n'name@domain.ext' ");
		}
	}

}
//to here





//THIS IS THE SCRIPT FOR ANY POPUPS
function popup(page, name, xsize, ysize, menubars, scrollbars, location, directories, resizable, status, toolbar)
{

	var yes = 1;
	var no = 0;

	var myleftpos = (window.screen.width/2) - ((xsize/2) + 30);
	var mytoppos = (window.screen.height/2) - ((ysize/2) + 40);

	windowprops = "width=" + xsize + ",height=" + ysize + ",top=" + mytoppos + ",left=" + myleftpos + "";
	windowprops += "menubars=" + menubars + ",scrollbars=" + scrollbars + ",location=" + location + ",directories=" + directories + ",resizable=" + resizable + ",status=" + status + ",toolbar=" + toolbar;

	window.open(page, name, windowprops);
}
//to here





//THIS IS THE FIX WINDOW SCRIPT
function fixwin()
{

	if (window.screen)
	{
		var mywidth = screen.availWidth;
		var myheight = screen.availHeight;
		window.moveTo(0, 0);
		window.resizeTo(mywidth,myheight);
	}

}
//TO HERE
