function mypopup(C,T,R,W,H) 
{
out = window.open(C,T,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable='+R+',width='+W+',height='+H);
}
/***********************************************/
function validEmail(eAddr) 
{ 
var goodAddr = false;
var ndxAt = ndxDot = 0;

ndxAt  = eAddr.indexOf("@");
ndxDot = eAddr.indexOf(".");

if   ( (ndxDot < 0) || (ndxAt < 0) )
alert("Invalid E_mail address. !");  
else if (ndxDot < ndxAt)
alert("You entered email address incorrectly.\nThe '.' should come after the '@'.\n\nThe format is 'you@dom.suf'. !");
else if ( (ndxDot - 2) <= ndxAt)
alert("The domain name is missing.\n\nThe format is 'you@dom.suf'. !");
else if ( eAddr.length <= (ndxDot + 3) )
alert("There must be three characters after the 'dot'.\n\nThe format is 'you@dom.suf'. !");
else
goodAddr = true;
return (goodAddr);                       
}
/*************************************************/
function selectall(){ 
t=document.frm.length; 

for(i=0; i<t; i++)
 { 
	document.frm[i].checked=true; 
 } 
}
/****************************************************/
function deselectall(){ 
t=document.frm.length; 

for(i=0; i<t; i++)
 { 
	document.frm[i].checked=false; 
 } 
}
/*************************************************/
function chek(myaction) 
{
var str=0;
  t=document.frm.length; 

for(i=0; i<t; i++)
 { 
    if(document.frm[i].checked)
	   {
	     str++;
	   } 
 } 
  
   if(str == 0)
    {
	  alert("Select Atleast One Record to Delete");
	  return false;
	}
 	   else
		{   document.frm.action = myaction;
			document.frm.submit();
		}
}
/***********Forgot Password*************************************/
function myforgotpwd()
{
theForm = document.frm;

if (theForm.username.value == "")
{
    alert("You must Enter Username/LoginID");
	theForm.username.focus();
	theForm.username.select();
	return false;
}
return true;
}
/*********************************************/
function mysubmit(frm,act)
{
    theForm = this.document.frm;
	theForm.action = act;
	theForm.submit();			
}
/******************************************/
function myordsubmit(valu,act,frm)
{
    theForm = this.document.frm;
	//theForm.ordby.value= valu;
	theForm.elements['ordby'].value=valu;
	theForm.action = act;
	theForm.submit();			
}
/*******************************************/
function myrefresh()
{
  window.location.reload(false);
}
/*******************************************/
function mycheck(myfrm)
{	
	theForm = document.forms[myfrm];

if(theForm.elements['username'])
	{
		if (!theForm.elements['username'].value)
		{
			alert("Please Enter User ID");
			theForm.elements['username'].focus();
			theForm.elements['username'].select();
			return false;
		}
		else if (theForm.elements['username'].value== "Username Or Email")
		{
			alert("Please Enter Valid User ID");
			theForm.elements['username'].focus();
			theForm.elements['username'].select();
			return false;
		}
	}

if(theForm.password)
	{
		if (!theForm.password.value)
		{
			alert("Please Enter Password");
			theForm.password.focus();
			theForm.password.select();
			return false;
		}
	}

if(theForm.rpassword)
	{
		if (!theForm.rpassword.value)
		{
			alert("Please Re Enter Password");
			theForm.rpassword.focus();
			theForm.rpassword.select();
			return false;
		}
	}


if ((theForm.password)&&(theForm.rpassword))
{						 
	if (theForm.password.value != theForm.rpassword.value)
	{
		alert("Password Values Mismatch");
		theForm.password.focus();
		theForm.password.select();
		return false;
	}
}

if(theForm.age)
	{
		if (!theForm.age.value)
		{
			alert("Please Enter Your Age");
			theForm.age.focus();
			theForm.age.select();
			return false;
		}
	}

if(theForm.fname)
	{
		if (!theForm.fname.value)
		{
			alert("Please Enter First Name");
			theForm.fname.focus();
			theForm.fname.select();
			return false;
		}
	}
	

if(theForm.lname)
	{
		if (!theForm.lname.value)
		{
			alert("Please Enter Last Name");
			theForm.lname.focus();
			theForm.lname.select();
			return false;
		}
	}

if(theForm.address)
	{
		if (!theForm.address.value)
		{
			alert("Please Enter Your Address");
			theForm.address.focus();
			theForm.address.select();
			return false;
		}
	}


if(theForm.city)
	{
		if (!theForm.city.value)
		{
			alert("Please Enter Your City");
			theForm.city.focus();
			theForm.city.select();
			return false;
		}
	}
	

if(theForm.state)
	{
		if (!theForm.state.value)
		{
			alert("Please Enter Your State");
			theForm.state.focus();
			theForm.state.select();
			return false;
		}
	}
	
	
if(theForm.country)
	{
		if (!theForm.country.value)
		{
			alert("Please Select Your Country");
			theForm.country.focus();
			theForm.country.select();
			return false;
		}
	}
	
	
if(theForm.zipcode)
	{
		if (!theForm.zipcode.value)
		{
			alert("Please Enter Your Zip Code");
			theForm.zipcode.focus();
			theForm.zipcode.select();
			return false;
		}
	}
	
	
if(theForm.phone)
	{
		if (!theForm.phone.value)
		{
			alert("Please Enter Your Phone");
			theForm.phone.focus();
			theForm.phone.select();
			return false;
		}
	}	


if(theForm.email)
	{
		if (!theForm.email.value)
		{
			alert("Please Enter Email Address");
			theForm.email.focus();
			theForm.email.select();
			return false;
		}
		else
		{
			var eAddr = theForm.email.value;
			var goddAdr = validEmail(eAddr);
			if(goddAdr == false)
			{
				theForm.email.focus();
				theForm.email.select();
				return false;
			}			
		}
	}
return true;
}
/********************************************/
function chkbox(frm,chk)
{
	if(document.frm.chk.checked)
  		{
			selectall();
    	}
	else 
		{
			deselectall();			
		}
}

/*******************************************/
function mypassword()
{
theForm = document.forms['frmpwd'];

if (theForm.oldpassword.value == "")
{
    alert("You must Enter Old Password");
	theForm.oldpassword.focus();
	theForm.oldpassword.select();
	return false;
}


if (theForm.oldpassword.value != theForm.oldpwd.value)
{
    alert("Old Password Value is Incorrect");
	theForm.oldpassword.focus();
	theForm.oldpassword.select();
	return false;
}

if (theForm.newpassword.value == "")
{
    alert("You must Enter New Password");
	theForm.newpassword.focus();
	theForm.newpassword.select();
	return false;
}

if (theForm.confirmnewpassword.value == "")
{
    alert("You must confirm Password");
	theForm.confirmnewpassword.focus();
	theForm.confirmnewpassword.select();
	return false;
}

if(theForm.newpassword.value != theForm.confirmnewpassword.value)
{
	 alert("New Password Entries Mismatch!");
	 theForm.newpassword.focus();
	 theForm.newpassword.select();
	 return false;
}


if ((theForm.oldpassword.value==theForm.newpassword.value))
{
    alert("Old And New Passwords Are Same");
	theForm.newpassword.focus();
	theForm.newpassword.select();
	return false;
}	   
return true;
}

/*******************************************************/
function myload()
{
	if(document.frm.username)
	{
		document.frm.username.focus();
	}
	
}
/******************************************************/
function mycatcheck(frm)
{
theForm = document.frm;
	
if(theForm.cat)
	{
		if (!theForm.cat.options[theForm.cat.selectedIndex].value)
		{
			alert("Please Select Category");
			theForm.cat.focus();
			return false;
		}
	}
	
	
 if(theForm.title)
	{
		if (!theForm.title.value)
		{
			alert("Please Enter Title");
			theForm.title.focus();
			theForm.title.select();
			return false;
		}
	}
	

if(theForm.url)
	{
		if (!theForm.url.value)
		{
			alert("Please Enter Website Url");
			theForm.url.focus();
			theForm.url.select();
			return false;
		}
	}

if(theForm.company)
	{
		if (!theForm.company.value)
		{
			alert("Please Enter Company");
			theForm.company.focus();
			theForm.company.select();
			return false;
		}
	}	




return true;
}

/***********************************************/
function mysearchchk(frm,act)
{
	theForm = document.frm;
	if(theForm.search)
	{
		if (!theForm.search.value)
		{
			alert("Please Enter Search Text");
			theForm.search.focus();
			theForm.search.select();
			return false;
		}
	   else
		{   theForm.action = act;
			theForm.submit();
		}	
	}

return true;
}
/***************************************/
function enterdisable(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;
     else
          key = e.which;

     if(key == 13)
          return false;
     else
          return true;
}
/************************************
function add_file(id, i) {
			document.getElementById(id + '_' + i).innerHTML = '<tr><td><div align="center" class="mytext">'+(i+1)+'</div></td><td><input type="text" name="title[]" class="myinput" value=""></td><td><div align="center"><input type="file" name="icon[]" class="myfinput"/></div></td><td><div align="center"><input type="file" class="myfinput" name="document[]" onChange="return add_file(\'' + id + '\', ' + (i+1) + ');" /></div></td><span id="' + id + '_' + (i+1) + '"><\/span></td><td>&nbsp;</td></tr>';
	}
/*************************************/
function stripCharacter(words,character) {
	//documentation for this script at http://www.shawnolson.net/a/499/
	  var spaces = words.length;
	  for(var x = 1; x<spaces; ++x){
	   words = words.replace(character, "");   
	 }
	 return words;
    }
	
	function changecss(theClass,element,value) {
	//documentation for this script at http://www.shawnolson.net/a/503/
	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }
	 for (var S = 0; S < document.styleSheets.length; S++){
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    document.styleSheets[S][cssRules][R].style[element] = value;
	   }
	  }
	 }	
	}

	
	