// JavaScript Document
function changeLook(x)
{
x.className="olinks";
}

function revertLook(x)
{
x.className="links";
}
	
function submitform1()
{
/* **************************************************************************************************
	script by Team-inertia Technologies 			-	2003 
	contactus@team-inertia.net
	www.team-inertia.net
		
*******************************************************************************************************/

	var form=document.forms[0]
	e=0;	 // means error
	for(i=0; i<form.elements.length; i++)    <!--- To check that data is entered in textboxes >
	{
		if(form.elements[i].type=="text" && form.elements[i].value=="" && form.elements[i].name!="txtspid" && form.elements[i].name!="txtemail" && form.elements[i].name!="txtrgdt")
		{
			form.elements[i].focus()
			alert("Please choose " +form.elements[i].id+ " !!!")
			e=1;
			return;	
		}
	}
	
	if( e==1)
	{
		// do nothing !!!
	}
	else
	{
		document.dates.submit();
	}
}

function WindowXPosition(widthX,heightX,windowName)
{
	var width = (screen.width);
	var height = (screen.height - 25);
	var centerleft = 0;
	var centertop = 0;
	var centerleft = (width/2) - (widthX/2);
	var centertop = (height/2) - (heightX/2);
	var width=widthX;
	var height=heightX;
	windowName.moveTo(centerleft,centertop);
	windowName.resizeTo(width, height);
	windowName.focus();
}

function WindowXXPosition(widthX,heightX,windowName) //same as above, only it takes %age vals as params for width n height
{
	var width = (screen.width);
	var height = (screen.height - 25);
		
	var wt = (width * widthX) / 100;
	var ht = (height * heightX) / 100;

	var centerleft = (width/2) - (wt/2);
	var centertop = (height/2) - (ht/2);

	windowName.resizeTo(wt, ht);
	windowName.moveTo(centerleft,centertop);
	windowName.focus();
}

function WindowPosition(widthX,heightX)
{
	var width = (screen.width);
	var height = (screen.height - 25);
	var centerleft = 0;
	var centertop = 0;
	var centerleft = (width/2) - (widthX/2);
	var centertop = (height/2) - (heightX/2);
	var width=widthX;
	var height=heightX;
	window.moveTo(centerleft,centertop);
	window.resizeTo(width, height);
	window.focus();
}

function GoToPage(page)
{
	window.document.location.href= page;
}

function DeleteDataAndGoToPage(txt, page)
{
	var msg = "You Are About To Delete this " + txt + "! Continue?";

	if(confirm(msg))
		window.document.location.href=page;
}

function ConfirmDelete(txt, page)
{
	var msg = "You Are About To Delete this " + txt + "! Continue?";

	if(confirm(msg))
		window.document.location.href=page;
	else
		return false;
}

function str_trim(str)
{	
	if(str.length > 0)
		while(str.charAt(0)==' ')
			str = str.substr(1);
		
	if(str.length > 0)
		while(str.charAt((str.length - 1))==' ')
			str = str.substring(0, str.length-1);
	
	return str;
}

function checkEmail(x)
{
	a=new Array();
	s=x.value;
	
	for(i=0; i<s.length; i++)
		a[i]=s.charAt(i);

	dot = s.indexOf(".");
	at   = s.indexOf("@");

	if (dot == -1 || at == -1)
	{
		x.focus()
		alert ("Please Check Email Address");
		return 1;
	}

	str1=s.substring(dot+1,s.length);
	str2=s.substring(at+1, dot);
	str3=s.substring(0,at);

	if((str1.length==0)||(str2.length==0)||(str3.length==0))
	{
		x.focus()     
		alert ("Please Check Email Address");
		return 1;
	}

	return 0;
}

function ChangeRank(mode, fld, fld_val) // mode, condition fld, condition value
{
	var str = "";

	if(fld != "" && fld_val != "")
		str = "&fld=" + fld + "&fld_val=" + fld_val;

	var file = "rank-update.php?mode="+mode+str;
	win = window.open(file,'ChangeRank','width=900,height=600,scrollbars=1,resizable=1,status=1');
	WindowXPosition(900,600,win);
}
