function openwin1(file,Iwidth,Iheight) {
      var newWin1=window.open(file,'iypWin2','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left=20,top=20');
}

function return_element_length(elem_obj) {
	return elem_obj.value.length;
}

function open_new_window(thisurl){	
	window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
}
function display_show_format_options(objName,x,newText) { //v4.01
		if ((obj=MM_findObj(objName))!=null) with (obj)
		if (document.layers) {
    		document.write(unescape(newText)); document.close();
    	}
		else innerHTML = unescape(newText);
}

/*Function  : isProhibitedToSubmit(param) 
  Objective : To check object value is allow or not
  @param    : Object
  Output    :
  	True    : If value is not allowed to enter
  	False   : If value is allowed to enter */
  	
function isProhibitedToSubmit(obj){
	var objval=obj.value;
	invalidstr=new Array("indiamart","india mart", "alibaba","ali baba","tradeindia", "trade-india");
	for(i=0;i<invalidstr.length;i++){
		if (chktrim(objval).toLowerCase().indexOf(chktrim(invalidstr[i]).toLowerCase())>=0){	
			alert("Usage of "+invalidstr[i]+" is Prohibited on this site.") 
			obj.focus();
			return true;		
		}
	}
	return false;
}//end of isProhibitedToSubmit()

/*Function isValidToSubmit(param) 
  Objective: To check object value is allow or not
  @param   :  Object
  Output   :
  	True   : If value is allowed to enter
  	False  : If value is not allowed to enter */
  
function isValidToSubmit(obj){
	var objval=obj.value;
    invalidstr = new Array("hotmail", "gmail", "indiatimes", "rediffmail", "yahoo", ".com", ".net",".org", ".co.in", ".co.cn", ".co.ca", ".gov", ".co.uk");
		 		
	for(i=0;i<invalidstr.length;i++){
		if (chktrim(objval).toLowerCase().indexOf(chktrim(invalidstr[i]).toLowerCase())>=0){	
			alert("Please don't use "+invalidstr[i]+".") 
			obj.focus();
			return false;		
		}
	}
	return true;
}//end of isValid
	

function translator(pattern) {
	var open_in_same_window = 1;
	var my_location = unescape(document.location.toString());
	var new_location ='';
	var new_pattern = '';
	if (my_location.indexOf('translate_c?') != -1) {
		/// From google...
		var indexof_u = my_location.indexOf('u=');
		if (indexof_u == -1) {
			new_location = document.location;
		}
		else {
			var subs = my_location.substring(indexof_u, my_location.length);
			var ss = subs.split('&');
			new_location = ss[0].substring(2, ss[0].length);
		}
	}
	else {
		new_location = document.location;
	}

	indexof_p = pattern.indexOf('|');

	var isen = '';
	if (indexof_p == -1) {
		indexof_p1 = pattern.indexOf('><');
		if (indexof_p1 == -1) {
			new_pattern = pattern;
			if (pattern == 'en') {
				isen = 1;
			}
		}
		else {
			var psplit =pattern.split('><');
			new_pattern = psplit[0]+'|'+psplit[1];
			if (psplit[1] == 'en') {
				isen = 1;
			}
		}
	}
	else {
		var psplit = pattern.split('|');
		new_pattern = psplit[0]+'|'+psplit[1];
		if (psplit[1] == 'en') {
			isen = 1;
		}
	}

	var thisurl = '';
	if (isen == 1) {
		thisurl = new_location;
	}
	else {
		thisurl = 'http://translate.google.com/translate_c?langpair=' + new_pattern + "&u=" + new_location;
	}

	if (open_in_same_window == 1) {
		window.location.href = thisurl;
	}
	else {
		if (CanAnimate ){
			msgWindow=window.open('' ,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
			msgWindow.focus();
			msgWindow.location.href = thisurl;
		}
		else {
			msgWindow=window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
		}
	}
}

//function check all
function CheckAll(formName)
{
	count = document.getElementById(formName).elements.length;
    for (i=0; i < count; i++) 
	{
	document.getElementById(formName).elements[i].checked = 1;
	}
}
function UncheckAll(formName){
	count = document.getElementById(formName).elements.length;
    for (i=0; i < count; i++) 
	{
	document.getElementById(formName).elements[i].checked = 0;
	}
}

function selectDeselect(Arg,formName)
{
	
	if(Arg.checked==1)
	{
	document.getElementById("selectText").innerHTML = "<b>Deselect All</b>"
	CheckAll(formName);
	}
	else{
	document.getElementById("selectText").innerHTML = "<b>Select All</b>"
	UncheckAll(formName);
	}
}

function chktrim(inputString) {
	if (typeof inputString != "string") { 
		return inputString; 
	}
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
    while (ch == " ") { 
    	retValue = retValue.substring(1, retValue.length);
        ch = retValue.substring(0, 1);
	} 
    ch = retValue.substring(retValue.length-1, retValue.length);
    while (ch == " ") { 
    	retValue = retValue.substring(0, retValue.length-1);
        ch = retValue.substring(retValue.length-1, retValue.length);
	}
    while (retValue.indexOf("  ") != -1) { 
    	retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	}
    return retValue; 
} 

function newBizValid1(id1, chk1) {
	if (chk1=="chk") {
   		len=id1.elements.length;
   		var i=0;
 		var pp=1;
   		for (i=0; i<len; i++) {
	   		 if (id1.elements[i].type == "checkbox" && id1.elements[i].checked==true) {
				pp=2;
			}
		}
  		if (pp==1) {
	  		alert("Please select your Product checkbox");
	  		return false;
  		} 
  	}
   	
   if (chktrim(id1.gender.value).length==0)  {
      alert("Select  your Gender");
      id1.gender.focus();
      return false;
   }
  	
   if (chktrim(id1.first_name.value).length==0) {
      alert("Enter your First name");
	  id1.first_name.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.first_name))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.first_name))
		return false;	        
		
   }

   if (chktrim(id1.last_name.value).length==0) {
      alert("Enter your Last_name");
	  id1.last_name.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.last_name))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.last_name))
		return false;	        
		
   }
      
   if (chktrim(id1.comp_name.value).length==0) {
      alert("Enter your company name");
	  id1.comp_name.focus();
      return false;
   }
   else{
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.comp_name))
		return false;	        
   }
   
   if (chktrim(id1.address1.value).length ==0) {
      alert("Enter your Postal Address");
      id1.address1.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.address1))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.address1))
		return false;	        
		
   }
   
   if (chktrim(id1.country.value).length==0)  {
      alert("Enter your Country");
      id1.country.focus();
      return false;
   }
   
   
   if (chktrim(id1.country_code.value).length==0)  {
      alert("Enter your Country code");
      id1.country_code.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.country_code))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.country_code))
		return false;	        
		
   }

   if (chktrim(id1.area_code.value).length==0)  {
      alert("Enter your Area Code");
      id1.area_code.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.area_code))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.area_code))
		return false;	        
		
   }
      
   if (chktrim(id1.phone_number.value).length==0)  {
      alert("Enter your Phone Number");
      id1.phone_number.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.phone_number))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.phone_number))
		return false;	        
		
   }
   
   if (chktrim(id1.username.value).length == 0) {
      alert("E-mail address can't be left blank");
      id1.username.focus();
      return false;
   }
   else{
	   
	      var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		  if(!regex.test(id1.username.value)){
			  alert("Invalid email address format");
			  id1.username.focus();
			  return false;
		  }
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.username))
		return false;	        
		
   }
   if (chktrim(id1.your_requirement.value).length==0)  {
      alert("Enter Your Requirement");
      id1.your_requirement.focus();
      return false;
   }
}

function newBizValid(id1, chk1) {
	if (chk1=="chk") {
   		len=id1.elements.length;
   		var i=0;
 		var pp=1;
   		for (i=0; i<len; i++) {
	   		 if (id1.elements[i].type == "checkbox" && id1.elements[i].checked==true) {
				pp=2;
			}
		}
  		if (pp==1) {
	  		alert("Please select your Product checkbox");
	  		return false;
  		} 
  	}
   	
   if (chktrim(id1.your_name.value).length==0) {
      alert("Enter your name");
	  id1.your_name.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.your_name))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.your_name))
		return false;	        
		
   }
   
   if (chktrim(id1.comp_name.value).length==0) {
      alert("Enter your company name");
	  id1.comp_name.focus();
      return false;
   }
   else{
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.comp_name))
		return false;	        
   }
   
   if (chktrim(id1.address.value).length ==0) {
      alert("Enter your Postal Address");
      id1.address.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.address))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.address))
		return false;	        
		
   }
   
   if (chktrim(id1.country.value).length==0)  {
      alert("Enter your Country");
      id1.country.focus();
      return false;
   }
   
   if (chktrim(id1.phone.value).length==0)  {
      alert("Enter your Phone Number");
      id1.phone.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.phone))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.phone))
		return false;	        
		
   }
   
   if (chktrim(id1.username.value).length == 0) {
      alert("E-mail address can't be left blank");
      id1.username.focus();
      return false;
   }
   else{
	   
	      var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		  if(!regex.test(id1.username.value)){
			  alert("Invalid email address format");
			  id1.username.focus();
			  return false;
		  }
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.username))
		return false;	        
		
   }
   if (chktrim(id1.your_requirement.value).length==0)  {
      alert("Enter Your Requirement");
      id1.your_requirement.focus();
      return false;
   }
}

function newBizValid2(id1, chk1) {
	if (chk1=="chk") {
   		len=id1.elements.length;
   		var i=0;
 		var pp=1;
   		for (i=0; i<len; i++) {
	   		 if (id1.elements[i].type == "checkbox" && id1.elements[i].checked==true) {
				pp=2;
			}
		}
  		if (pp==1) {
	  		alert("Please select your Product checkbox");
	  		return false;
  		} 
  	}
   if (chktrim(id1.arrival_date.value).length==0) {
      alert("Enter Arrival Date");
	  id1.arrival_date.focus();
      return false;
   }
   if (chktrim(id1.departure_date.value).length==0) {
      alert("Enter Departure Date");
	  id1.departure_date.focus();
      return false;
   }
   if (chktrim(id1.no_of_persons.value).length==0) {
      alert("Enter Total No. of Persons");
	  id1.no_of_persons.focus();
      return false;
   }
   if (chktrim(id1.no_of_days.value).length==0) {
      alert("Enter Total No. of Days");
	  id1.no_of_days.focus();
      return false;
   }
   if (chktrim(id1.check_in.value).length==0) {
      alert("Enter Check in");
	  id1.check_in.focus();
      return false;
   }
   if (chktrim(id1.check_out.value).length==0) {
      alert("Enter Check Out");
	  id1.check_out.focus();
      return false;
   }
   if (chktrim(id1.no_of_room.value).length==0) {
      alert("Enter No. Of Rooms");
	  id1.no_of_room.focus();
      return false;
   }
   
   if (chktrim(id1.your_name.value).length==0) {
      alert("Enter your name");
	  id1.your_name.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.your_name))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.your_name))
		return false;	        
		
   }
   
   if (chktrim(id1.comp_name.value).length==0) {
      alert("Enter your company name");
	  id1.comp_name.focus();
      return false;
   }
   else{
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.comp_name))
		return false;	        
   }
   
   if (chktrim(id1.address.value).length ==0) {
      alert("Enter your Postal Address");
      id1.address.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.address))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.address))
		return false;	        
		
   }
   
   if (chktrim(id1.country.value).length==0)  {
      alert("Enter your Country");
      id1.country.focus();
      return false;
   }
   
   if (chktrim(id1.phone.value).length==0)  {
      alert("Enter your Phone Number");
      id1.phone.focus();
      return false;
   }
   else{
		//To check .net .com etc words in name field
		if(!isValidToSubmit(id1.phone))
		return false;
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.phone))
		return false;	        
		
   }
   
   if (chktrim(id1.username.value).length == 0) {
      alert("E-mail address can't be left blank");
      id1.username.focus();
      return false;
   }
   else{
	   
	      var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		  if(!regex.test(id1.username.value)){
			  alert("Invalid email address format");
			  id1.username.focus();
			  return false;
		  }
		
		//To check Indiamart, alibaba etc words in alternate_email field
		if(isProhibitedToSubmit(id1.username))
		return false;	        
		
   }
   if (chktrim(id1.your_requirement.value).length==0)  {
      alert("Enter Your Requirement");
      id1.your_requirement.focus();
      return false;
   }
}


function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}
var pop='';
function MM_openBrWindow(theURL,winName,features) { //v2.0
   if (pop && !pop.closed) {
      pop.close();
   }

    pop=eval(window.open(theURL,'pop',features));
   if (!pop.opener) popUpWin.opener = self;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function addtoBasket(var3, chkS) {
	if (chkS=="Y") {
		var pp=1;
	    dml=document.form1;
	    len=dml.elements.length;
	    var i=0;
	    for(i=0; i<len; i++) {
	      	if ((document.form1.elements[i].type == "checkbox") && (dml.elements[i].checked==true)) {
	         	pp=2;
	      	}
	    }
	    if (pp==1) {
	      	alert("You have not selected any Product / Item.\n\nPlease select  and  proceed");
	      	
	    }
	    else {
	      	document.form1.action=''+var3+'';
	      	document.form1.id.value="cart";
	      	document.form1.submit();	
	      	return true;
	      	
	  	}
	  	
  	}
  	else {
		document.form1.action=''+var3+'';
	    document.form1.id.value="cart";
	    document.form1.submit();	
  	}
}

function deltoBasket(lnk) {
	if (lnk!="") 
	{
		document.form1.action=''+lnk+'';
	    document.form1.id.value="cart";
	    document.form1.submit();	
  	}
}




function inquiry_now_for_part_pro(formname, elementname, submitValue, var3) {
	var formObj = eval('document.form1.'+elementname+'.checked=1');
	if(submitValue=="Y"){	
      	document.form1.action=''+var3+'';
      	document.form1.id.value="Inquiry";
      	document.form1.submit();	
	}	
	return true;
}

function catalog_inquiry_now_for_all_pro(var3) {
	var pp=1;
    dml=document.form1;
	len=dml.elements.length;
	var i=0;
	for (i=0; i<len; i++) {
		if (document.form1.elements[i].type == "checkbox" && dml.elements[i].checked==true) {
	    	pp=2;
	    }
	}
	if (pp==1) {
		alert("You have not selected any Product / Item.\n\nPlease select  and  proceed");
		return false;
	}
	else {
      	document.form1.action=''+var3+'';
      	document.form1.id.value="Inquiry";
      	document.form1.submit();	
	}
}
	
function catalog_inquiry_now() {
	var pp=1;
    dml=document.form1;
	len=dml.elements.length;
	var i=0;
	for (i=0; i<len; i++) {
		if (document.form1.elements[i].type == "checkbox" && dml.elements[i].checked==true) {
	    	pp=2;
	    }
	}
	if (pp==1) {
		alert("You have not selected any Product / Item.\n\nPlease select  and  proceed");
		return false;
	}
	else {
		return true;
	}
}

/*following function calls to show any type of validation in any form*/
function Form_Validation(Form_Object) {
	
	/*fetching the total number of elements from form*/
	Total_Elements=(Form_Object.elements.length);
    
	var Email_Check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	/*running loop to check the elements of form one by one*/
	for(Element_Count=0; Element_Count<Total_Elements; Element_Count++) {
		
		/*storing element object*/
		var Element_Object=Form_Object.elements[Element_Count];
		
		/*storing element name*/
		var Element_Name=Element_Object.name;
		
		/*storing element value*/
		var Element_Value=chktrim(Element_Object.value);
		
		/*storing element type*/
		var Element_Type=Element_Object.type;
		
		/*spliting the element namer*/
		var Array_Split=Element_Name.split("_");		
		
		if(Array_Split[0].indexOf('Req')!=-1){
			if(Element_Type=='select-one'){
				if (Element_Object.options[Element_Object.selectedIndex].value=="")  {
					alert('Please Select ' +Array_Split[2]);
					Element_Object.focus();
					return false;
				}
			}
			else{
				if(Element_Value.length<1){
					alert('Please enter your ' +Array_Split[2]);
					Element_Object.focus();
					return false;
				}
				else if(Element_Name.indexOf('_Email-Id')!=-1){
					if(!Email_Check.test(Element_Value)){
						alert('Please enter valid ' +Array_Split[2]);
						Element_Object.focus();
						return false;
					}
					else if(Array_Split[0].indexOf('Prohb')!=-1 || Array_Split[0].indexOf('Prohb1')!=-1){
					   	//To check indiamart, Alibaba etc words in email field
					   	if(isProhibitedToSubmit(Element_Object))
					   		return false;
					}
				}
				else if(Element_Name.indexOf('_Int_')!=-1){
					if(!parseInt(Element_Value)){
						alert('Please enter valid ' +Array_Split[2]);
						Element_Object.focus();
						return false;
					}
				}
				else if(Array_Split[0].indexOf('Prohb')!=-1){
					if(Array_Split[0].indexOf('Prohb')!=-1 || Array_Split[0].indexOf('Prohb1')!=-1){
					   	//To check indiamart, Alibaba etc words in email field
					   	if(isProhibitedToSubmit(Element_Object))
					   		return false;
					}
					
					if(Array_Split[0].indexOf('Prohb')!=-1 || Array_Split[0].indexOf('Prohb2')!=-1){
					   	//To check .net .com etc words in company name field
					    if(!isValidToSubmit(Element_Object))
					   		return false;
					}
					
				}
			}
		}
		else if(Array_Split[0].indexOf('Prohb')!=-1 && Element_Value.length>0){
			if(Element_Name.indexOf('_Int_')!=-1){
				if(!parseInt(Element_Value)){
					alert('Please enter valid ' +Array_Split[2]);
					Element_Object.focus();
					return false;
				}
			}
			else{
				if(Array_Split[0].indexOf('Prohb')!=-1 || Array_Split[0].indexOf('Prohb1')!=-1){
				   	//To check indiamart, Alibaba etc words in email field
				   	if(isProhibitedToSubmit(Element_Object))
				   		return false;
				}
				
				if(Array_Split[0].indexOf('Prohb')!=-1 || Array_Split[0].indexOf('Prohb2')!=-1){
				   	//To check .net .com etc words in company name field
				    if(!isValidToSubmit(Element_Object))
				   		return false;
				}
			}
		}
	}
}

