function VersionNavigateur(Netscape, Explorer) {
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
else return false;
}

function openMovie(){
	window.open("winpop.html","flash","width=550,height=474,status=no,scrollbars=no,resizable=no,location=no,menubar=no,toolbar=no,top=30,left=100");
}

function remove_XS_whitespace(item)
{
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}


function chkAddress()
{
  if (document.business.txtAddr.value.length<10)
  {
    alert("Address seems to be wrong");
    document.business.txtAddr.focus();
    return false;
  }
  else
    return true;
}

//function to validate an Email
function checkEmail()
{
  var rc = true;
  if( document.business.txtEmail.value.length > 0 )
  {
  if( document.business.txtEmail.value.length < 6 )
  {
    rc = false; 
  } 
  else 
  {
    var parts = document.business.txtEmail.value.split( "@" );    // Not just one on @, or no length to parts
    if( parts.length != 2 || parts[0].length == 0 || parts[1].length < 3 ) 
    {
	rc = false; 
    } 
    else 
    {
	var subdom = parts[1].split( "." );
	//alert(eval("subdom.length"));
	if( subdom.length < 2 ) 
	{
	  rc = false; 
	} 
	else 
	{
	  for( var i = 0 ; i < subdom.length ; i++ ) 
	  {
	    if( subdom[i].length < 1 ) 
	    {
		rc = false; 
	    }
	  }
	}
    }
  }
  }
  return rc;		
}

function subm()
{
  if(event.keycode==13)
  {
	document.business.submit();
	return true;
  } 
}


function CheckMandatoryInput(objTextbox, strNameOfTheTextbox)
{
  var strValue // This will store the value of the textbox
  var intLength // This will store the length of the textbox
  var strMessage
  strValue = objTextbox.value
  intLength = strValue.length
  strMessage = "Supplying a value for '" + strNameOfTheTextbox + "' is mandatory."
  if (intLength==0)
  {
    alert(strMessage)
    objTextbox.focus()
    return false;
  }
}

function FocusOnFirstTextbox()
{
  document.business.txtName.focus()
} 	

//name, desig, country	special not allowed
function nochar(str1,str2)
{
  if ((event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97) || (event.keyCode > 122 && event.keyCode < 127))
	event.returnValue = false;
}

// phone, mobile, fax, pincode
function validateNumeric()
{
	if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 127)) 
		event.returnValue = false;
}

//pincode,fax,mob, phone	space not allowed, special chars nto allowed 
function nospacechar() 
{
  if ((event.keyCode > 31 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97) || (event.keyCode > 122 && event.keyCode < 127))
	event.returnValue = false;
}

//fax, mobile, email, message,pin not compulsory
//cmbfound, enquiry, name, desig, company, addr, country, phone compulsory
function ValidateEnquiry()
{
  if (CheckMandatoryInput(document.business.txtName, "Name")==false)
    return false
  if (CheckMandatoryInput(document.business.txtDesig, "Designation")==false)
    return false
  if (CheckMandatoryInput(document.business.txtCompany, "Company")==false)
    return false
  if (CheckMandatoryInput(document.business.txtAddr, "Address")==false)
    return false
  if (CheckMandatoryInput(document.business.txtCountry, "Country")==false)
    return false
  if (CheckMandatoryInput(document.business.txtPhone, "Phone")==false)
    return false
  if (CheckMandatoryInput(document.business.txtEnquiry, "Enquiry")==false)
    return false
  if (CheckMandatoryInput(document.business.cmbFound, "Found")==false)
    return false
  if (chkAddress()==false)
    return false
  if (checkEmail()==false)
  {
    alert("Invald Email Address");
    return false
  }
}

//fax, mobile,email,message,stationer, gift, others,pin not compulsory
//cmbproduct, cmbsell, cmbfound, name, desig, company, addr, country,  phone compulsory
function ValidateReseller()
{
  if (CheckMandatoryInput(document.business.txtName, "Name")==false)
    return false
  if (CheckMandatoryInput(document.business.txtDesig, "Designation")==false)
    return false
  if (CheckMandatoryInput(document.business.txtCompany, "Company")==false)
    return false
  if (CheckMandatoryInput(document.business.txtAddr, "Address")==false)
    return false
  if (CheckMandatoryInput(document.business.txtCountry, "Country")==false)
    return false
  if (CheckMandatoryInput(document.business.txtPhone, "Phone")==false)
    return false
  if (CheckMandatoryInput(document.business.cmbProduct, "Product")==false)
    return false
  if (CheckMandatoryInput(document.business.cmbSell, "Sell")==false)
    return false
  if (CheckMandatoryInput(document.business.cmbFound, "Found")==false)
    return false
  if (chkAddress()==false)
    return false
  if (checkEmail()==false)
  {
    alert("Invald Email Address");
    return false
  }
}

//cmproduct, cmbtime, cmbgifts,cmbquantity, name, desig, company, addr, country,  phone compulsory
//txtcustom, fax, mobile,email,message,pin not compulsory
function ValidateCorporate()
{
  if (CheckMandatoryInput(document.business.txtName, "Name")==false)
    return false
  if (CheckMandatoryInput(document.business.txtDesig, "Designation")==false)
    return false
  if (CheckMandatoryInput(document.business.txtCompany, "Company")==false)
    return false
  if (CheckMandatoryInput(document.business.txtAddr, "Address")==false)
    return false
  if (CheckMandatoryInput(document.business.txtCountry, "Country")==false)
    return false
  if (CheckMandatoryInput(document.business.txtPhone, "Phone")==false)
    return false
  if (CheckMandatoryInput(document.business.cmbProduct, "Product")==false)
    return false
  if (CheckMandatoryInput(document.business.cmbTime, "Time")==false)
    return false
  if (CheckMandatoryInput(document.business.cmbGifts, "Gifts")==false)
    return false
  if (CheckMandatoryInput(document.business.cmbQuantity, "Quantity")==false)
    return false
  if (chkAddress()==false)
    return false
  if (checkEmail()==false)
  {
    alert("Invald Email Address");
    return false
  }
}
