function querry_check1(def,id){
var value = document.getElementById(""+id).value;
if(value == '')
{
document.getElementById(""+id).value = ""+def;
}
}

function querry_check2(def,id){
var value = document.getElementById(""+id).value;
var defaultText = ""+def;
(value == defaultText)?(document.getElementById(""+id).value = ""):(document.getElementById(""+id).select());
}

function executeTab(tab){
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	className=document.getElementById(""+tab).className;
	if(className!="selected")
	{
		document.getElementById(""+tab).style.borderBottom = "none";
		document.getElementById(""+tab).className = "selected";
		document.getElementById(""+tab+"a").src = "/images/main/act_lt.gif";
		document.getElementById(""+tab+"b").style.backgroundImage = "url(/images/main/act_ce.gif)";
		document.getElementById(""+tab+"c").src = "/images/main/act_rt.gif";
		if(browser == "Microsoft Internet Explorer"){
		(tab=="tab1")?document.getElementById("table1").style.display = "block":document.getElementById("table2").style.display = "block";
		}
		else{
		(tab=="tab1")?document.getElementById("table1").style.display = "table":document.getElementById("table2").style.display = "table";
		}
		
		for(i=1;document.getElementById("tab"+i)!=null;i++)
		{
			if(("tab"+i) == (""+tab)){
				continue;
			}
			document.getElementById("tab"+i).style.borderBottom = "1px solid #cccccc";
			document.getElementById("tab"+i).className = "";
			document.getElementById("table"+i).style.display = "none";
			document.getElementById("tab"+i+"a").src = "/images/main/una_lt.gif";
			document.getElementById("tab"+i+"b").style.backgroundImage = "url(/images/main/una_ce.gif)";
			document.getElementById("tab"+i+"c").src = "/images/main/una_rt.gif";
		
		}
	}
}

function searchtx(id,def,frm){
 var query = document.getElementById(""+id).value;
if((query.length < 1) || (query == (""+def))){
           alert("Enter the search string");
           document.getElementById(""+id).focus();
            return false;
      }  else {     
	 return true;
}  

}

function numCheck(str)
{
	
	var string = str.length;
	var iChars = "*|,\":<>[]{}`\';()/&$#%~!^-_+=?1234567890";
	for (var i = 0; i < string; i++) {
	if (iChars.indexOf(str.charAt(i)) != -1)
		return false;
	}
	return true;

}

function emailValidate(incomingString)
         {
         //alert("1 :: "+incomingString);
         var iChars = "*|,\":<>[]{}`\;()&$#%/?";
         
         var emailId=incomingString;
         if(Trim(emailId).length == 0)
         {
           alert("Not a valid e-mail address");
	   return false;
         }
         for (var i = 0; i < incomingString.length; i++) {
		 if (iChars.indexOf(emailId.charAt(i)) != -1)
		 {
			alert("Not a valid e-mail address");
			 return false;
		 }
       	 }
	 var atpos=emailId.indexOf("@");
	 var dotpos=emailId.lastIndexOf(".");
	 if (atpos<1 || dotpos<atpos+2 || dotpos+2>=emailId.length)
	   {
	   alert("Not a valid e-mail address");
	   return false;
  	   }
  	   
  	   /*
         	if(Trim(incomingString).length == 0 || incomingString.search(/[\_\-\d]*[A-Za-z]+[\w\_\-]*[\@][\d]*[A-Za-z]+[\w\-]*[\.][A-Za-z]+/g) == -1 )	
         		return false;
         		
         	
         	var iChars = "*|,\":<>[]{}`\';()&$#%/?";
         	
         	 for (var i = 0; i < incomingString.length; i++) {
       	      if (iChars.indexOf(incomingString.charAt(i)) != -1)
       	         return false;
       	       if(incomingString.lastIndexOf('.')>-1)
       	       {
       	        var lastStr = incomingString.substring(incomingString.lastIndexOf('.'),incomingString.length);
       	            	       		
       	       		if(!numCheck(lastStr))
       	       		 {
       	       		 	    	       		 	
       	       		 	return false;
       	       		 }
       	       }
       	        
         	 }
         	 */
         	
         	
         		return true;
}

function Trim(str){
var count =str.length;
var c=1;
while(str.charAt(0)==" " || str.charAt(0)=="\t"){
	str=str.substring(1,str.length);

	if(c==count){
		break;
	}
c=c+1;
}
return str;
}

function subscribeTrainingAlert(formId)
{
formObj = document.getElementById(formId);
var emailId = formObj.emailId.value;

var defaultEmailText = "Enter Your Email Address";

      	if(emailId==defaultEmailText){
			alert("Please enter your Email ID.")
			formObj.emailId.value=defaultEmailText;
			formObj.emailId.focus();
			return false;
      	}

      	if(Trim(emailId)==""){
			alert("Please enter your Email ID.")
			formObj.emailId.value=defaultEmailText;
			formObj.emailId.focus();
			return false;
      	}
		
      	if (emailValidate(emailId)==false){
			alert("Please enter your valid Email address.")
			formObj.emailId.focus();
			return false
		}

callTrack('Subscribe to alert - Home');
		
trainingSubscribeWindow = window.open("/ecommerce/control/subscribeTrainingAlert?emailId="+emailId,"_new","menubar=no,resizable=no,location=no,width=275,height=200"); 
trainingSubscribeWindow.moveTo(100,100);
trainingSubscribeWindow.focus();
return true;
}



