function cv()
{
 window.open('./pub/cv.doc','popupwin');
}
//---------------------email validation--------------------------------//
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
	}

//---------show downloads-------------//
function showDownloads(name)
{
 window.open('system/docs/'+name,'popupwin');
}

//--------career validation-------------//
function careerValidation()
{

  var name      =   window.document.career.name.value;
  var dob       =   window.document.career.dob.value;
  var address   =   window.document.career.address.value;
  var voice     =   window.document.career.voice.value;
  var email     =   window.document.career.email.value;
  var noyears   =   window.document.career.noyears.value;
  var userfile  =   window.document.career.userfile.value;
  
  if(name == '' || dob == '' || address == '' || voice == ''|| email == '' || noyears == ''|| userfile == '')
  {
    alert("Fields marked with an * need to be complete in full.")
    return false;
  }
  if(echeck(email) != false){
        return true;
    }
  return false;
}

//---------------------only typing numbers---------------------//
function validChars(e, goods) {
	var key, keychar;
	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if (key == null) return true;

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();

	if (goods.indexOf(keychar) != -1)
		return true;

	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27)
		return true;

	return false;
}

//-------------- Contact us validation-----------------//
function contactUsValidation()
{
  var realname  =   window.document.contact.realname.value;
  var address   =   window.document.contact.address.value;
  var phone     =   window.document.contact.phone.value;
  var fax       =   window.document.contact.fax.value;
  var email     =   window.document.contact.email.value;
  var enquiry   =   window.document.contact.enquiry.value;
  
  if(realname == '' || phone == '' || address == '' || fax == ''|| email == '' || enquiry == '')
  {
    alert("Fields maked with an *  need to be complete in full.")
    return false;
  }
  if(echeck(email) != false){
        return true;
    }
  return false;

}

//----------supplier login---------------//
function supLogin()
{
  var email  =   window.document.login.email.value;
  var pw   =   window.document.login.pword.value;
  
  if(email== '' || pw == '')
  {
    alert("All fields need to be complete in full.")
    return false;
  }
  if(echeck(email) != false){
        return true;
    }
  return false;
}

//-------------- validation-----------------//
function registerValidation()
{

  var name          =   window.document.regSUP.name.value;
  var company       =   window.document.regSUP.company.value;
  var address       =   window.document.regSUP.address.value;
  var voice         =   window.document.regSUP.voice.value;
  var fax           =   window.document.regSUP.fax.value;
  var email         =   window.document.regSUP.email.value;
  var password         =   window.document.regSUP.password.value;
  var confirmation  =   window.document.regSUP.confirmation.value;


  if(name == '' || voice == '' || address == '' || fax == ''|| email == '' || company == ''|| confirmation == ''|| password == '')
  {
    alert("All fields need to be complete in full.")
    return false;
  }
  if(echeck(email) != false){

if(checkpsw2(password ,confirmation))
 {
  return true;
 }

    }
  return false;

}


//-------------- validation-----------------//
function profileValidation()
{

  var name          =   window.document.profile.name.value;
  var company       =   window.document.profile.company.value;
  var address       =   window.document.profile.address.value;
  var voice         =   window.document.profile.voice.value;
  var fax           =   window.document.profile.fax.value;
  var email         =   window.document.profile.email.value;
  var pword         =   window.document.profile.pword.value;
  var confirmation  =   window.document.profile.confirmation.value;


  if(name == '' || voice == '' || address == '' || fax == ''|| email == '' || company == ''|| confirmation == ''|| pword == '')
  {
    alert("All fields need to be complete in full.")
    return false;
  }
  if(echeck(email) != false){

if(checkpsw2(pword ,confirmation))
 {
  return true;
 }

    }
  return false;

}

//---------------------only typing numbers---------------------//
function validChars(e, goods) {
	var key, keychar;
	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if (key == null) return true;

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();

	if (goods.indexOf(keychar) != -1)
		return true;

	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27)
		return true;

	return false;
}
//------------------check two passwords---------------------------//
function checkpsw2(pw1,cpw1){
var pw =  pw1;
var cpw =  cpw1;

if(pw  != cpw ){
	alert("Password and Confirm Password fields must be identical.");
	return false;
}
return true;
}

