/* Function related to form submission */

var bookmarkurl="http://www.digite.com/customers/customer_login.htm"
var bookmarktitle="Digité Enterprise - Customer Login"

function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


function onFormSubmit(){

	if(document.loginForm.loginId.value == "")
	{
		alert("Please Enter the Login Id.");
		document.loginForm.loginId.focus();
		return false;
	}
	if(document.loginForm.password.value == "")
	{
		alert("Please Enter the Password.");
		document.loginForm.password.focus();
		return false;
	}
		protocol = window.location.protocol;
	emailID = document.loginForm.loginId.value;
	digitepw = document.loginForm.password.value;
	//window.location = "http://www.digite.com/names.nsf?login&username=" + emailID + "&password=" + digitepw;
	//self.opener.window.name = "myOpener";
	//return eval(window.close());
	return true;

}


	/* register*/

	<!--
function checkRegistration()
	{
		if (getCookie("registered") == "true")
		{
			document.forms[0].Name.value = getCookie("name");
			document.forms[0].email.value = getCookie("email");
			if(getCookie("phone") == null)
				document.forms[0].Phone.value = '';
			else
				document.forms[0].Phone.value = getCookie("phone");
			document.forms[0].Organization.value = getCookie("org");
			document.forms[0].region.value = getCookie("region");
		
			//document.forms[0].submit();

		}else{
			//alert ("not registered");

		}
	}

function getNextPath()
{
	var nextPath = location.search.substring(1, location.search.length);
	document.getElementById('goto').value="http://www.digite.com/"+nextPath
	document.getElementById('goto_document').value=document.getElementById('goto').value
	//alert (location.search.substring(1, location.search.length));
	//alert(document.getElementById('goto_document').value)
}

function validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+=' Please Enter valid Email address.\n\n';
		k = val.split('@');
		if (k[1] == "hotmail.com" || k[1] == "gmail.com" || k[1] == "yahoo.com" || k[1] == "mail.com" || k[1] == "rediffmail.com" || k[1] == "indiatimes.com" || k[1] == "a.com") errors+=' We do not accept emails addresses ending with: ' + k[1] + '.\n\n';
      } else if (test!='R') { num = parseFloat(val);
		
        if (isNaN(val)) errors+=' '+nm+' must contain a number.\n\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+=' '+nm+' must contain a number between '+min+' and '+max+'.\n\n';
    } } } else if (test.charAt(0) == 'R') errors += 'Please Enter '+nm+'.\n\n'; }
  } 
  //var selIndex = document.getElementById('region').selectedIndex;
	 if (isNaN(document.getElementById('phone').value)) {		 
  	errors += 'Phone must contain numbers.\n\n';
  }

  if (document.getElementById('region').value == "none") {
  	errors += 'Please Select a region.\n\n';
  } if (errors)
  {
  	alert(errors);
	}else{
	  setCookie("registered", "true", now);
	  setCookie("name", document.forms[0].Name.value, now);
	  setCookie("email", document.forms[0].email.value, now);
	  setCookie("phone", document.forms[0].Phone.value, now);
	  setCookie("org", document.forms[0].Organization.value, now);
	  setCookie("region", document.forms[0].region.value, now);
	  
	  }
  document.returnValue = (errors == '');
}

function validateContactForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=validateContactForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.returnValue = (errors == '');
}

function changeContactDetails(mySelection)
{
	//define an array with email id
	var contactEmails = [];
	contactEmails["General"] = "requestforinfo@digite.com";
	contactEmails["Sales"] = "sales@digite.com";
	contactEmails["Marketing"] = "marketing@digite.com";
	contactEmails["Support"] = "support@digite.com";
	contactEmails["Human Resources"] = "hr@digite.com";
	contactEmails["Webmaster"] = "webmaster@digite.com";
	contactEmails["Professional Services"] = "support@digite.com";
	contactEmails["Press Contact"] = "marketing@digite.com";
	mySelection.form.subject.value = 'Contact ' + mySelection.form.contact.value;
	mySelection.form.recipients.value = contactEmails[mySelection.form.contact.value];
		
	var seg1 = document.getElementById("supp01");
	var seg2 = document.getElementById("hr01");
		
	 if(mySelection.form.contact.value == "Support")
    {
		seg1.style.display = '';
		seg2.style.display = 'none';
	} else if(mySelection.form.contact.value == "Human Resources")
	{
		seg1.style.display = 'none';
		seg2.style.display = '';
	} else
	{
		seg1.style.display = 'none';
		seg2.style.display = 'none';
	}
		
}