/*
$(document).ready(function(){
	

  $('#tabs').tabs({
    select: function(event, ui) {
      if ($(ui.tab).attr('target') == '_blank')
      {
        window.open($(ui.tab).attr('href').replace('#',''));
        return false;
      }
    }
  });
	

  //window.location=($(ui.tab).attr("href").replace('#',''));

});
*/
	
/*
$(document).ready(function(){
      
        $("a.blank").click(function () {
    		//$("#mytabs").tabs("add","tabContent.htm","New Tab") 
    	     alert($(ui.tab).attr('target'));
    		 select: function(event, ui) {			
    	    	 //window.location=($(ui.tab).attr("href");	  
    	    	 $("#mytabs").tabs("add","google.com","New Tab") 
    	     }

    	});
    	
    	     	
});   
   
*/
 
 
 function isUnsignedInteger(s) {
   return (s.toString().search(/^[0-9]+$/) == 0);
 }


 function echeck(str) {
	 
	 	var msg ="";
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
			msg = _INVALID_EMAIL;
		   
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			msg = "Invalid E-mail";
		   
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			msg = _INVALID_EMAIL;
		    
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			 msg = _INVALID_EMAIL;
		    
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			 msg = _INVALID_EMAIL;
		    
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			 msg = _INVALID_EMAIL;
		    
		 }
		
		 if (str.indexOf(" ")!=-1){
			 msg = _INVALID_EMAIL;
		   
		 }

 		 return msg;					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }  	     	


function sendEmailByAJAX(phpFile,order_id){
	
	
	var msg = "";
	var email = $("#email_to").val();
	
	msg = echeck(email);
	
	if (msg==""){
		$.post(phpFile,"idOrder="+order_id+"&email="+email, function(){ });					
		alert(_EMAIL_SENT_IT_SUCCESSFULLY);		
	} else {
		alert(msg);
	}
	
	
	
}

