/* 
/******************************************************************************
/*   Copyright (C) 2007  INTERBERRY SOLUTIONS                                 
/*   http://www.interberry.com                                                
/*                                                                            
/*   Date of creation		  :  	08-AUG-2007
/*   Date last modified		:  	08-AUG-2007.
/*   Project				         :  	Project Frame
/*   Release				         :  	1.0
/*   Comment			          :  	<Common Javascript Functions>
/*   Author              :   Subin Jose.         
/*                                                                  
/******************************************************************************/


/* null checking */
function check_fields(form_name,f_name,d_name,c_array)
{
	var incre=0;
	for (incre=0; incre<c_array; incre++)
	{
		var frm="document."+form_name+"."+f_name[incre]+".value";
		var foc="document."+form_name+"."+f_name[incre];
		
		if(trimSpaces(eval(frm))=="")
		{	
		      alert(d_name[incre]+" is a Required Field !!");
			  var foc_field=eval(foc);
			  foc_field.focus();
			  return false;
		}		
	}
	
	return true;
}


function trimSpaces(stringValue) 
{
	   // Checks the first occurance of spaces and removes them
	   for(i = 0; i < stringValue.length; i++) 
	   {
		    if(stringValue.charAt(i) != " ") 
		     {			break;		}
	   }
	
	   if(i > 0) 
	   {		stringValue = stringValue.substring(i);	}
	
	   // Checks the last occurance of spaces and removes them
	   strLength = stringValue.length - 1;
	   for(i = strLength; i >= 0; i--) 
	   {
		   if(stringValue.charAt(i) != " ") 
		   {		break;		}
	   }
	
	   if(i < strLength) 
	   {		stringValue = stringValue.substring(0, i + 1);	}
	
	   // Returns the string after removing leading and trailing spaces.
	return stringValue;
}


/* character checking */
function checkAllowedChars(strToCheck, allowedChars) 
{
     var acLen     = allowedChars.length;
     var stcLen     = strToCheck.length;
     strToCheck     = strToCheck.toLowerCase();
     var i;
     var j;
     var rightCount = 0;
     for(i = 0; i < acLen; i++)
     {
          switch(allowedChars.charAt(i))
          {
          case 'A':
               for(j = 0; j< stcLen; j++)
               {
                    rightCount += strToCheck.charAt(j) >= 'a' && strToCheck.charAt(j) <= 'z';
               }
               break;
          case 'N':
               for(j = 0; j< stcLen; j++)
               {
                    rightCount += strToCheck.charAt(j) >= '0' && strToCheck.charAt(j) <= '9';
               }
               break;
          default:
               for(j = -1; -1 != (j = strToCheck.indexOf(allowedChars.charAt(i), j + 1)); rightCount++);
               break;
          }
     }
     if(rightCount == stcLen)
     {
          return true;
     }
     return false;
}


function checkEmail(emailString)
{
	splitVal = emailString.split('@');
	
	if(splitVal.length <= 1) 
	{
		alert("Please Enter A Valid Email Address !!");
		return false;
	}
	if(splitVal[0].length <= 0 || splitVal[1].length <= 0) 
	{
		alert("Please Enter A Valid Email Address !!");
		return false;
	}
	
	splitDomain = splitVal[1].split('.');
	if(splitDomain.length <= 1) 
	{
		alert("Please Enter A Valid Email Address !!");
		return false;
	}
	
	if(splitDomain[0].length <= 0 || splitDomain[1].length <= 1) 
	{
		alert("Please Enter A Valid Email Address !!");
		return false;
	}
	return true;
}



// 	field_name,display_name,count_array,file_type,count_file_type
function check_file(f_name,d_name,c_array,f_type,c_f_array)
{
	var incre=0;
	for (incre=0; incre<c_array; incre++)
	{
		var frm	=	"document."+f_name[incre]+".value";
	
		if(eval(frm)=="")
		{	
			var file	=	frm.split(".");
			var ext		=	file[file.length-1].toLowerCase();
			for (increment=0; increment<c_f_array; increment++)
			{
				if(f_type[increment]!=ext)
				{
					alert("Invalid File Type In "+d_name[incre]);
					return false;
				}
			}
		}		
	}
	return true;
}



function check_int_fields(formname,f_name,d_name,c_array)
{
	var incre=0;	
	for (incre=0; incre<c_array; incre++)
	{
		var frm="document."+formname+"."+f_name[incre]+".value";
		var foc="document."+formname+"."+f_name[incre];
		
		if(isNaN(eval(frm)))
		{	
		   alert(d_name[incre]+" Should Be A Number !!");
			  var foc_field=eval(foc);
			  foc_field.focus();
			  return false;
		}		
	}
	return true;
}



function check_greater(min_val,max_val,d_name,c_array)
{
	var incre=0;
	for (incre=0; incre<c_array; incre++)
	{
		var frm_min="document."+min_val[incre]+".value";
		var foc_min="document."+min_val[incre];
		var frm_max="document."+max_val[incre]+".value";
		var foc_max="document."+max_val[incre];
		if(eval(frm_min)>eval(frm_max))
		{	
		      alert(d_name[incre]+" Must Be Larger !!");
			  var foc_field=eval(foc_min);
			  foc_field.focus();
			  return false;
		}		
	}	
	return true;
}



function fckeditor(name)
{
	window.open("fckeditor.php?name="+name,'fckeditor',"menubar=1,resizable=0,width=720,height=450,top=100,left=100");
}

function fckeditorNews(name)
{
	window.open("fckeditor_newsletter.php?name="+name,'fckeditor',"menubar=1,resizable=0,width=720,height=450,top=100,left=100");
}

function fckeditorProduct(name)
{
	window.open("fckeditor_product.php?name="+name,'fckeditor',"menubar=1,resizable=0,width=720,height=450,top=100,left=100");
}



// Make the XMLHttpRequest object
var http_request = false;
function makeRequest(url) 
{
    if(window.XMLHttpRequest)
	{
      	http_request = new XMLHttpRequest();
   	} 
   	else if(window.ActiveXObject) 
   	{
      	http_request = new ActiveXObject("Microsoft.XMLHTTP");
   	} 
   	else 
   	{
      	alert('Problem creating the XMLHttpRequest object');
   	}
   	http_request.open('get', url);
   	http_request.onreadystatechange = alertContents;
   	http_request.send(null);
}

function alertContents() 
{

   if(http_request.readyState == 4)
   {
   		if(http_request.status == 200)
		{
	      	var response = http_request.responseText;
			alert(response);   	//window.open("fckeditor.php?name="+name+"&content="+content.value,'fckeditor',"menubar=1,resizable=0,width=720,height=450,top=100,left=100");
		}
	}
}

function check_intgreat_val(min,max)
{
	
	var min,max;
	
	if(parseFloat(min) > parseFloat(max))
	{
			alert('Minimum Total Should Be Less Than Maximum Total')
			return false
	}
	if(parseFloat(min) < 0)
	{
		alert('Negative Value Is Not Allowed') 
		return false
	}
	else if(parseFloat(max) < 0)
	{	
		alert('Negative Value Is Not Allowed') 
		return false
	}

	return true
}

function check_intgreat_val2(min,max)
{
	
	var min,max;
	
	if(parseFloat(min) > parseFloat(max))
	{
			alert('Start Range Should Be Less Than End Range')
			return false
	}
	if(parseFloat(min) < 0)
	{
		alert('Negative Value Is Not Allowed') 
		return false
	}
	else if(parseFloat(max) < 0)
	{	
		alert('Negative Value Is Not Allowed') 
		return false
	}

	return true
}







function isInteger(value) 
{  return (parseInt(value) == value); }

var integer = /^\d+$/;

function validateInteger(form,myField) 
{
  if (!isInteger(eval("document."+form+"."+myField+".value"))) 
  {    
    alert('Invalid Integer Value Entered !! \n');
    eval("document."+form+"."+myField+".focus()");
    return false
  }

  if (window.RegExp && !integer.test(eval("document."+form+"."+myField+".value"))) {
    
    alert('Invalid Integer Value Entered !! \n');
    eval("document."+form+"."+myField+".focus()");
   return false
  }
	

  return true;
}





//  Function To Check Minimum - Maximum value  (Int - Integer Value)


function checkGreaterInt(min_field,max_field,min_text,max_text,form_name)
{
  
 var min_value="document."+form_name+"."+min_field+".value";
 var max_value="document."+form_name+"."+max_field+".value";
 var temp;
 
        if(isNaN(eval(min_value)))
	    {	
     	alert(min_text+" Should Be A Number !! ");
        temp="document."+form_name+"."+min_field;
        eval(temp).focus();
        return false;	 
	    }
		
	    if(isNaN(eval(max_value)))
        {	
	       alert(max_text+" Should Be A Number !! ");
        temp="document."+form_name+"."+max_field;
        eval(temp).focus();
        return false;	 
	    }
		
	    
	    if(isInteger(eval(min_value)))
	    {    }
	    else
	    {
	     
	    alert(min_text+" Should Not Be A Decimal Number !! ");
        temp="document."+form_name+"."+min_field;
        eval(temp).focus();
        return false;	
	    }
	    
	    if(isInteger(eval(max_value)))
	    {    }
	    else
	    {
	    alert(max_text+" Should Not Be A Decimal Number !! ");
        temp="document."+form_name+"."+max_field;
        eval(temp).focus();
        return false;	
	    }
	    
	    
     if(parseInt(eval(min_value))<0)
     {
        alert(min_text+" Should Be Greater Than Or Equal To Zero !! ");
        temp="document."+form_name+"."+min_field;
        eval(temp).focus();
        return false;
     }
 
     if(parseInt(eval(max_value))<0)
     {
        alert(max_text+" Should Be Greater Than Or Equal To Zero !! ");
        temp="document."+form_name+"."+max_field;
        eval(temp).focus();
        return false;
     }
 
     if(parseInt(eval(max_value))<=parseInt(eval(min_value)))
     {
        alert(max_text+" Should Be Greater Than "+min_text+" !! ");
        temp="document."+form_name+"."+max_field;
        eval(temp).focus();
        return false;
      }
 
 return true;
}



//  Function To Check Minimum - Maximum value  (Float - Decimal Value)


function checkGreaterFloat(min_field,max_field,min_text,max_text,form_name)
{
  
 var min_value="document."+form_name+"."+min_field+".value";
 var max_value="document."+form_name+"."+max_field+".value";
 var temp;
 
     if(isNaN(eval(min_value)))
	    {	
     	  alert(min_text+" Should Be A Number !! ");
        temp="document."+form_name+"."+min_field;
        eval(temp).focus();
        return false;	 
	    }
		
	    if(isNaN(eval(max_value)))
     {	
	       alert(max_text+" Should Be A Number !! ");
        temp="document."+form_name+"."+max_field;
        eval(temp).focus();
        return false;	 
	    }
		
     if(parseFloat(eval(min_value))<0)
     {
        alert(min_text+" Should Be Greater Than Or Equal To Zero !! ");
        temp="document."+form_name+"."+min_field;
        eval(temp).focus();
        return false;
     }
 
     if(parseFloat(eval(max_value))<0)
     {
        alert(max_text+" Should Be Greater Than Or Equal To Zero !! ");
        temp="document."+form_name+"."+max_field;
        eval(temp).focus();
        return false;
     }
 
     if(parseFloat(eval(max_value))<=parseFloat(eval(min_value)))
     {
        alert(max_text+" Should Be Greater Than "+min_text+" !! ");
        temp="document."+form_name+"."+max_field;
        eval(temp).focus();
        return false;
      }
 
 return true;
}

// Function To Check Whether The Value Entered Is A Non Negative Float 

function check_numeric(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 to check password entry when change ing pwd


*/
  function checkPass()
		{
				
				if(document.frmpsd.newpassword.value=="")
				{
					alert("Please Enter Your New Password !!");
					document.frmpsd.newpassword.value=="";
					document.frmpsd.newpassword.focus();
					return false;	
				}	
				if(document.frmpsd.confirmpassword.value=="")
				{
					alert("Please Confirm Your New Password !!");
					document.frmpsd.confirmpassword.value=="";
					document.frmpsd.confirmpassword.focus();
					return false;	
				}
				if(document.frmpsd.newpassword.value!=document.frmpsd.confirmpassword.value)
				{
					alert("Password Mismatch !!");
					document.frmpsd.confirmpassword.value=="";
					document.frmpsd.confirmpassword.focus();
					return false;
				}	
		}	

		
		
		/*
**Function to check password entry when changeing pwd of customer at user side


*/
  function checkPassUser()
		{
				
				if(document.frmpsd.newpassword.value=="")
				{
					alert("Please Enter Your New Password !!");
					document.frmpsd.newpassword.value=="";
					document.frmpsd.newpassword.focus();
					return false;	
				}	
				if(document.frmpsd.confirmpassword.value=="")
				{
					alert("Please Confirm Your New Password !!");
					document.frmpsd.confirmpassword.value=="";
					document.frmpsd.confirmpassword.focus();
					return false;	
				}
				if(document.frmpsd.newpassword.value!=document.frmpsd.confirmpassword.value)
				{
					alert("Password Mismatch !!");
					document.frmpsd.confirmpassword.value=="";
					document.frmpsd.confirmpassword.focus();
					return false;
				}	
		}	


//functions required for products page
function checknew()
	{ 
	   for (i=0;i<document.formSubmit.radmodelnum.length;i++)
		{
			//alert("val="+document.formSubmit.radmodelnum[i].value);
			if (document.formSubmit.radmodelnum[i].checked==true)
				document.formSubmit.modelnum.value =document.formSubmit.radmodelnum[i].value; 
		}
		//alert("1modelnum="+document.formSubmit.modelnum.value);
		if(document.formSubmit.modelnum.value=="")
		{
			if (document.formSubmit.radmodelnum.checked==true)
			{
				document.formSubmit.modelnum.value =document.formSubmit.radmodelnum.value; 
			}
		}
		//alert("2modelnum="+document.formSubmit.modelnum.value);
		if(document.formSubmit.modelnum.value=="")
		{
			alert("Please select a key model");
			return false;
		}
		else if(document.formSubmit.keys.value=="")
		{
			alert("Select how many keys you want to order?");
			document.formSubmit.keys.focus();
			return false;
		}
	    
		var i ;
		var flag = 0 ;
		for(i=1;i<=document.formSubmit.keys.value;i++)
		{
		   if(document.getElementById('keyvalue'+i).value!="")
		   {
		      var flag = 1 ;
		   }
		}
		
		if(flag==0)
		{
		   alert("Please Enter Atleast One Key !!");
		   return false ;
		}

	/*
		if(document.formSubmit.hinges.value !="")
		{
			var h ;
    		var flagh = 0 ;
    		for(h=1;h<=document.formSubmit.hinges.value;h++)
    		{
    		   if(document.getElementById('hingevalue'+h).value!="")
    		   {
    		      var flagh = 1 ;
    		   }
    		}
    		
    		if(flagh==0)
    		{
    		   alert("Please Enter Atleast One Set !!");
    		   return false ;
    		}
		}	
	*/	
		return true;
		
	}
	
	//old fn.
function check()
	{
		var field_name   = new Array("modelnum","parts","keys");
		var display_name = new Array("Model Number","Part(s) you need","QTY of keys");
		var count_array  = 3;
		
		if(check_fields('formSubmit',field_name,display_name,count_array))
		{
			var i ;
			var flag = 0 ;
			for(i=1;i<=document.formSubmit.keys.value;i++)
			{
			   if(document.getElementById('keyvalue'+i).value!="")
			   {
			      var flag = 1 ;
			   }
			}
			
			if(flag==0)
			{
			   alert("Please Enter Atleast One Key !!");
			   return false ;
			}
		}
		else
		{
			return false;
		}
	}

function getKeyRows(count)
	{ 
   		 var i ;
   		 var rowTier  = "<table width='100%' border='0'>";
   		 for(i=1;i<=count;i++)
   		 {		 	   
   		   //rowTier  += "	 <tr> <td class='left_label' width='30%' align='right'>KEY "+i+"</td><td align='left'><input type='text' name='keyvalue"+i+"' id='keyvalue"+i+"' size='10' style='width: 100px' class='style4'></td> </tr>";
			rowTier += '<tr><td style="width: 396px" class="style4">&nbsp;</td>';
			rowTier += '<td style="width: 396px" class="style4">';
			rowTier += '<strong>Key '+i+' </strong>';
			rowTier += '<input type="text" name="keyvalue'+i+'" id="keyvalue'+i+'" size="10" style="width: 100px" class="style4">';
			rowTier += '</td><td style="width: 396px">&nbsp;</td></tr>';
   		 } 
   		 rowTier  += "</table>"  ; 
   		 if(count!='')
   		 {
	   		 document.getElementById('keyRowhead').style.display = "block";
   		 } 
	   	 else
	   		 document.getElementById('keyRowhead').style.display = "none";	   	
   		 document.getElementById('keyRow').innerHTML = rowTier ;		
	}

	function getKeyRows_Edit(count)
	{ 
   		 var i ;
   		 var rowTier  = "<table width='100%' border='0'>";
   		 for(i=1;i<=count;i++)
   		 {		 	   
   		   //rowTier  += "	 <tr> <td class='left_label' width='30%' align='right'>KEY "+i+"</td><td align='left'><input type='text' name='keyvalue"+i+"' id='keyvalue"+i+"' size='10' style='width: 100px' class='style4'></td> </tr>";
			rowTier += '<tr><td style="width: 396px" class="style4">&nbsp;</td>';
			rowTier += '<td style="width: 396px" class="style4">';
			rowTier += '<strong>Key '+i+' </strong>';
			rowTier += '<input type="text" name="keyvalue'+i+'" id="keyvalue'+i+'" size="10" style="width: 100px" class="style4">';
			rowTier += '</td><td style="width: 396px">&nbsp;</td></tr>';
   		 } 
   		 rowTier  += "</table>"  ; 
   		 
   		  document.getElementById('keyRowhead_Edit').style.display = "none";	
   		  document.getElementById('editvalue').style.display = "none";	
   		     
   		 if(count!='')
   		 {
   		     document.getElementById('keyRowhead_Edit').style.display = "none";	
   		     document.getElementById('editvalue').style.display = "none";	
	   		 document.getElementById('keyRowhead').style.display = "block";	
   		 } 
	   	 else
	   		 document.getElementById('keyRowhead').style.display = "none";
	   	  	
   		 document.getElementById('keyRow').innerHTML = rowTier ;		
	}

	
	
	function shippingrates()
	{
		var filepath = document.location.href;
		var parts_path = findDocumentPath();
		//alert(parts_path);
		window.open(parts_path+"shippingrates.php",'shippingrates',"menubar=1,scrollbars=1,resizable=0,width=420,height=200,top=100,left=100");
	}
	
	

/*	function findDocumentPath() 
	{
	    var file_name = document.location.href; //http://192.168.0.1/ebkw/Parts/BrowseKeys.php/IBM
	    var file_path = file_name.split("/");   //[0] http:/ [1] / [2] / [3] /[4] /BrowseKeys.php/IBM
	    var fpath = "";
	    for(var i=0;i<5;i++){
	    	fpath += file_path[i] + "/";
	    }
	    return fpath;
	}
*/
//products page js END

//js for checkout page
function checkinfo()
	{
		var field_name   = new Array("firstname","lastname","email","address1","city","state","zip","country");
		var display_name = new Array("First Name","Last Name","Email","Address1","City","State","Zip","Country");
		var count_array  = 8;
		
		if(document.form3.email.value!="")
		{
			if(checkEmail(document.form3.email.value))
  			{		  			    
  				//return true;
  			}
  			else
  			{
  				return false;
  			}
		}
		
		if(check_fields('form3',field_name,display_name,count_array))
		{
			//return true;
		}
		else
		{
			return false;
		}
	}
	
//js for ebay order page
function checkinfoebay()
	{

		var field_name   = new Array("firstname","lastname","email","ebay_id","address1","city","state","zip","country");
		var display_name = new Array("First Name","Last Name","Email","Ebay ID","Address1","City","State","Zip","Country");
		var count_array  = 9;
		
		if(document.form3.email.value!="")
		{
			if(checkEmail(document.form3.email.value))
  			{		  			    
  				//return true;
  			}
  			else
  			{
  				return false;
  			}
		}
		
		if(check_fields('form3',field_name,display_name,count_array))
		{
			//return true;
		}
		else
		{
			return false;
		}
		
		
		for (i=0;i<document.form3.radmodelnum.length;i++)
		{
			if (document.form3.radmodelnum[i].checked==true)
				document.form3.modelnum.value =document.form3.radmodelnum[i].value; 
		}
		//alert("modelnum="+document.form3.modelnum.value);
		if(document.form3.modelnum.value=="")
		{
			if (document.form3.radmodelnum.checked==true)
			{
				document.form3.modelnum.value =document.form3.radmodelnum.value; 
			}
		}
		//alert("modelnum="+document.form3.modelnum.value);
		if(document.form3.modelnum.value=="")
		{
			alert("Please select a key model");
			return false;
		}
		else if(document.form3.keys.value=="")
		{
			alert("Select how many keys you want to order?");
			document.form3.keys.focus();
			return false;
		}
	    
		var i ;
		var flag = 0 ;
		for(i=1;i<=document.form3.keys.value;i++)
		{
		   if(document.getElementById('keyvalue'+i).value!="")
		   {
		      var flag = 1 ;
		   }
		}
		
		if(flag==0)
		{
		   alert("Please Enter Atleast One Key !!");
		   return false ;
		}

	
		checkCaptcha();
				
		
		
	}


function checkCaptcha(){
	ajax.requestFile 	= 	parts_path+'ajax_captcha.php?cryptcode='+document.form3.cryptcode.value;
	 ajax.onCompletion = checkResult;
	 ajax.runAJAX();
	 
}

function checkResult()
{
  
    var text       = ajax.response;
    if(text=='True')
		 document.form3.submit();
	else{
		alert('Wrong Captcha code');
		 return false;
	}
  
}

//for search page
function checksrch()
	{	
		d = document.frmSearch;
		
		String.prototype.trim = function () {
		    return this.replace(/^\s*/, "").replace(/\s*$/, "");
		}
		
		var srch1 = new String(d.srch.value);
		srch1=srch1.trim();
		
		if(srch1=="" || srch1=="Enter Model Number...")
		{
			alert("Please enter Search Key");
			d.srch.value = "";
			d.srch.focus();
			return false;
		}
	}
	
//for search links
function checksrch1()
	{	
		d = document.form1;
		
		String.prototype.trim = function () {
		    return this.replace(/^\s*/, "").replace(/\s*$/, "");
		}
		
		var srch1 = new String(d.srch1.value);
		srch1=srch1.trim();

		if(srch1=="" || srch1=="enter search term...")
		{
			alert("Please enter Search Key");
			d.srch1.value = "";
			d.srch1.focus();
			return false;
		}
	}
	function checksrchblog()
	{	
		d = document.form1;
		
		String.prototype.trim = function () {
		    return this.replace(/^\s*/, "").replace(/\s*$/, "");
		}
		
		var srch1 = new String(d.s.value);
		srch1=s.trim();

		if(srch1=="" || srch1=="enter search term...")
		{
			alert("Please enter Search Key");
			d.s.value = "";
			d.s.focus();
			return false;
		}
	}
	
function select_Radio(id){

//eval('document.getElementById("'+id+'").checked = true');
var rid;
rid = id.split("_");


var cnt = document.getElementById('img_cnt').value;
for(i=1; i<=cnt; i++){ 

document.getElementById('R'+i+'_1').className = "img_border";
document.getElementById('R'+i+'_2').className = "img_border";
document.getElementById('R'+i+'_3').className = "img_border";

}
//alert(document.getElementById(rid[0]).value);

document.getElementById(rid[0]).checked = true;
document.getElementById(id).className = "img_selected";



}


function select_Radio_Hinge(id){
  //  alert(id);
//eval('document.getElementById("'+id+'").checked = true');
var rid;
rid = id.split("_");


var cnt = document.getElementById('img_cnt_hinge').value;

for(i=1; i<=cnt; i++){ 

document.getElementById('RH'+i+'_1').className = "img_border";

}
//alert(document.getElementById(rid[0]).value);
document.getElementById(rid[0]).checked = true;
document.getElementById(id).className = "img_selected";



}



//functions required for hinges cart page
function checknewhinges()
	{
		 if(document.formSubmit.hinges.value=="")
		{
			alert("Please select how many hinge sets you want to order?");
			document.formSubmit.hinges.focus();
			return false;
		}
		

			var h ;
    		var flagh = 0 ;
    		for(h=1;h<=document.formSubmit.hinges.value;h++)
    		{
    		   if(document.getElementById('hingevalue'+h).value!="")
    		   {
    		      var flagh = 1 ;
    		   }
    		}
    		
    		if(flagh==0)
    		{
    		   alert("Please Enter Atleast One Set !!");
    		   return false ;
    		}
			
		
	 	
		return true;
	}

	
function check_number(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;
}


var parts_path = findDocumentPath() + 'Parts/';
	
	
	function findDocumentPath() 
	{
	var protocol = window.location.protocol;
    var host     = window.location.host;
    var pathname = window.location.pathname;
    var file_path = pathname.split("/");
    var pjtfolder = file_path[1];
    var locpath = file_path[2];
    
   // var full = protocol + "//" + host + "/" + pjtfolder + "/"; // in mindzap server
   //var full = protocol + "//" + host + "/" + pjtfolder + "/" + locpath + "/";  //in local 
    var full = protocol + "//" + host + "/" ; // in live server
    
    return full;
	}

	function getHingesRows(count)
	{
   		 var i ;
   		 var rowTier  = "<table width='100%' border='0'>";
   		 for(i=1;i<=count;i++)
   		 {		 	   
   		   //rowTier  += "	 <tr> <td class='left_label' width='30%' align='right'>KEY "+i+"</td><td align='left'><input type='text' name='keyvalue"+i+"' id='keyvalue"+i+"' size='10' style='width: 100px' class='style4'></td> </tr>";
			rowTier += '<tr><td style="width: 396px" class="style4">&nbsp;</td>';
			rowTier += '<td style="width: 396px" class="style4">';
			rowTier += '<strong>Set '+i+' </strong>';
			rowTier += '<input type="text" name="hingevalue'+i+'" id="hingevalue'+i+'" size="10" style="width: 100px" class="style4">';
			rowTier += '</td><td style="width: 450px">&nbsp;</td></tr>';
   		 } 
   		 rowTier  += "</table>"  ; 
   		 if(count!='')
	   		 document.getElementById('hingeRowhead').style.display = "block";
	   	 else
	   		 document.getElementById('hingeRowhead').style.display = "none";
   		 document.getElementById('hingeRow').innerHTML = rowTier ;		
	}
	
	function getHingesRows_Edit(count)
	{
   		 var i ;
   		 var rowTier  = "<table width='100%' border='0'>";
   		 for(i=1;i<=count;i++)
   		 {		 	   
   		   //rowTier  += "	 <tr> <td class='left_label' width='30%' align='right'>KEY "+i+"</td><td align='left'><input type='text' name='keyvalue"+i+"' id='keyvalue"+i+"' size='10' style='width: 100px' class='style4'></td> </tr>";
			rowTier += '<tr><td style="width: 396px" class="style4">&nbsp;</td>';
			rowTier += '<td style="width: 396px" class="style4">';
			rowTier += '<strong>Set '+i+' </strong>';
			rowTier += '<input type="text" name="hingevalue'+i+'" id="hingevalue'+i+'" size="10" style="width: 100px" class="style4">';
			rowTier += '</td><td style="width: 450px">&nbsp;</td></tr>';
   		 } 
   		 rowTier  += "</table>"  ; 
   		  
   		 document.getElementById('hingeRowhead_Edit').style.display = "none";	
   		 document.getElementById('editvalue_hinges').style.display = "none";
   		 
   		 if(count!='')
   		 {
   		     document.getElementById('hingeRowhead_Edit').style.display = "none";	
   		     document.getElementById('editvalue_hinges').style.display = "none";	
	   		 document.getElementById('hingeRowhead').style.display = "block";
   		 }
	   	 else
	   		 document.getElementById('hingeRowhead').style.display = "none";
	   	  
   		 document.getElementById('hingeRow').innerHTML = rowTier ;		
	}
	
	
