// JavaScript Document
function setnewclass(id)
{
	tabid="";
	tabid=id + "1";
	document.getElementById(tabid).className = "selecttab_bg";
	tabid=id + "2";
	document.getElementById(tabid).className = "selecttab_right";
	//tabid=id + "3";
	//document.getElementById(tabid).className = "selecttab_right";
	
	document.getElementById(id).style.cursor='pointer';

}

function setoldclass(id)
{
	tabid="";
	tabid=id + "1";
	document.getElementById(tabid).className = "normtab_bg";
	tabid=id + "2";
	document.getElementById(tabid).className = "normtab_right";
	//tabid=id + "3";
	//document.getElementById(tabid).className = "normtab_right";
	
	document.getElementById(id).style.cursor='pointer';


}


function setnewclass2(id)
{
	tabid="";
	tabid=id + "1";
	document.getElementById(tabid).className = "selectlefttab_left";
	tabid=id + "2";
	document.getElementById(tabid).className = "selectlefttab_bg";
	tabid=id + "3";
	document.getElementById(tabid).className = "selectlefttab_right";
	
	document.getElementById(id).style.cursor='pointer';

}

function setoldclass2(id)
{
	tabid="";
	tabid=id + "1";
	document.getElementById(tabid).className = "normlefttab_left";
	tabid=id + "2";
	document.getElementById(tabid).className = "normlefttab_bg";
	tabid=id + "3";
	document.getElementById(tabid).className = "normlefttab_right";
	
	document.getElementById(id).style.cursor='pointer';

}

function isValidData(val,valid,minl,maxl,fieldname,msg)
{
	if(Trim(val,' ')=="")
	{
		alert(fieldname + " is empty.");

return false;
	}
	else if(val.length<minl || val.length>maxl)
	{
		alert(fieldname + " must be " + minl + " to " + maxl + " characters long")
		return false;
	}
	else
	{
		for (var i=0, len=val.length; i<len ; i++) 
		{
			if (valid.indexOf(val.substring(i,i+1)) == -1) 
			{
				var wrong = i*1+1;
				alert(msg + ' ' + fieldname + '. Check character no ' + wrong + '.');
				return false;
			}
		}
	}
	return true;
}

function isEmail(val)
{
	if(Trim(val,' ') == "")
	{
		alert("Please enter a Email!");
		return false;
	}
	else if (!(val.indexOf('\@') > -1))
	{
		alert("Email must contain a \@");
		return false;
	}
	else if (!(val.indexOf('.') > -1))
	{
		alert("Email must contain a '.' (dot)");
		return false;
	}
	else if (val.indexOf('\@') == (val.indexOf('.')-1))
	{
		alert("Email can't contain a \@ and '.' side by side");
		return false;
	}
	else if (val.indexOf('.') == (val.length-1))
	{
		alert("Email can't contain a '.' (dot) at the end");
		return false;
	}
	return true;
}

function Trim(inputString, removeChar) 
{
	var returnString = inputString;
	if (removeChar.length)
	{
	  while(''+returnString.charAt(0)==removeChar)
		{
		  returnString=returnString.substring(1,returnString.length);
		}
		while(''+returnString.charAt(returnString.length-1)==removeChar)
	  {
	    returnString=returnString.substring(0,returnString.length-1);
	  }
	}
	return returnString;
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
	  return IsNumber;
}

function alphaonly(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
	{
	  var alphaa = numaric.charAt(j);
	  var hh = alphaa.charCodeAt(0);
	  if((hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==32)
	  {
	 
	  }
	  else
	  {
	  return false;
	  }

	}
  return true;
}

function isFriendFormOk(frm)
{
	if(Trim(frm.name.value,' ')=="")
	{
		alert("Please specify Your Name.");
		frm.name.focus();
		return false;
	}
	if(!isEmail(frm.email.value))
	{
		frm.email.focus();
		return false;
	}
	if(Trim(frm.fname.value,' ')=="")
	{
		alert("Please specify Friends Name.");
		frm.fname.focus();
		return false;
	}
	if(!isEmail(frm.femail.value))
	{
		frm.femail.focus();
		return false;
	}
	return true;
}

function isContactFormOk(frm)
{
	if(Trim(frm.name.value," ")== "" )
	{
		alert("Please specify Your name.");
		frm.name.focus();
		return false;
	}
	if(!isEmail(frm.email.value))
	{
		frm.email.focus();
		return false;
	}
	else if(Trim(frm.phone.value," ")== "" )
	{
		alert("Please specify Phone.");
		frm.phone.focus();
		return false;
	}
	/*else if(Trim(frm.phone.value," ")!="" && !isValidData(frm.phone.value,"0123456789-",10,20,"Phone","Only numbers in"))
	{
		frm.phone.focus();
		return false;
	}*/
	
	if(Trim(frm.comment.value," ")== "" )
	{
		alert("Please specify your comment.");
		frm.comment.focus();
		return false;
	}
	return true;
}
