// JavaScript Document

function GoToSectionTwo(){
	document.getElementById('rhsBodyTwo').style.display = "block";
	document.getElementById('rhsBodyOne').style.display = "none";
}

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){
	   return false
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}
	
	 if (str.indexOf(at,(lat+1))!=-1){
		return false
	 }
	
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	 }
	
	 if (str.indexOf(dot,(lat+2))==-1){
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false
	 }
	 return true					
}

function ValidateSectionOne(){
   var val = "";  
   var temp = "";
   var count = 0;
   var blanks = new Array(); 

   if(document.LTBRegistrationForm2010REVAMP.Salutation.selectedIndex == 0){
      blanks.push(count+1 + ". " + "Salutation\n");
	  count++;
   }
	if (document.LTBRegistrationForm2010REVAMP.LastName.value == ""){
      blanks.push(count+1 + ". " + "Last Name\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.Telephone.value == ""){
      blanks.push(count+1 + ". " + "Telephone\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.Mobile.value == ""){
      blanks.push(count+1 + ". " + "Mobile\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.EmailAddress.value == "" || echeck(document.LTBRegistrationForm2010REVAMP.EmailAddress.value)==false){
      blanks.push(count+1 + ". " + "Email Address\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.JobTitle.value == ""){
      blanks.push(count+1 + ". " + "Job Title\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.JobFunction.selectedIndex == 0){
      blanks.push(count+1 + ". " + "Job Function\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.BusinessName.value == ""){
      blanks.push(count+1 + ". " + "Business Name\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.StreetAddress.value == ""){
      blanks.push(count+1 + ". " + "Street Address\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.Suburb.value == ""){
      blanks.push(count+1 + ". " + "Suburb\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.State.value == ""){
      blanks.push(count+1 + ". " + "State\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.PostCode.value == ""){
      blanks.push(count+1 + ". " + "PostCode\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.Country.value == ""){
      blanks.push(count+1 + ". " + "Country\n");
	  count++;
	}


   temp = blanks.toString();
   if(temp){
      for(var i=0; i<count; i++){
	     temp=temp.replace(",", "");
	  }
      alert("Please fill out the following fields: \n\n" + temp);
      return false;
   }
   else{
	GoToSectionTwo();
   }
}

function ValidateSectionTwo(){
   var val = "";  
   var temp = "";
   var count = 0;
   var blanks = new Array(); 

    if(document.LTBRegistrationForm2010REVAMP.BusinessModel.selectedIndex == 0){
	  blanks.push(count+1 + ". " + "Business Model\n");
	  count++;
    }
	if (document.LTBRegistrationForm2010REVAMP.DoYouHaveShopfront[0].checked == false && document.LTBRegistrationForm2010REVAMP.DoYouHaveShopfront[1].checked == false){
      blanks.push(count+1 + ". " + "Do you have shopfront?\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.DoYouHaveShopfront[0].checked == true){
      if(document.LTBRegistrationForm2010REVAMP.NumOfShopfronts.selectedIndex == 0){
		blanks.push(count+1 + ". " + "How many shopfronts do you have?\n");
	  	count++;
	  }
	}
	if (document.LTBRegistrationForm2010REVAMP.MemberOfICP[0].checked == false && document.LTBRegistrationForm2010REVAMP.MemberOfICP[1].checked == false){
      blanks.push(count+1 + ". " + "Are you a member of the Intel Channel Partner Program?\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.DesktopsNumber.value == "" && document.LTBRegistrationForm2010REVAMP.NotebooksNumber.value == "" && document.LTBRegistrationForm2010REVAMP.ServersNumber.value == ""){
      blanks.push(count+1 + ". " + "Indicate how many units/month you sell on average\n");
	  count++;
	}
    if(document.LTBRegistrationForm2010REVAMP.PercentageOfSalesFromSmallBusiness.selectedIndex == 0){
	  blanks.push(count+1 + ". " + "Percentage of sales from small business\n");
	  count++;
    }
    if(document.LTBRegistrationForm2010REVAMP.NumberOfStaff.selectedIndex == 0){
	  blanks.push(count+1 + ". " + "How many sales staff in your company\n");
	  count++;
    }
	if (document.LTBRegistrationForm2010REVAMP.DoYouMakeYourOwnPCsOrServers[0].checked == false && document.LTBRegistrationForm2010REVAMP.DoYouMakeYourOwnPCsOrServers[1].checked == false){
      blanks.push(count+1 + ". " + "Do you make your own PCs or Servers?\n");
	  count++;
	}
	if (document.LTBRegistrationForm2010REVAMP.DoYouMakeYourOwnPCsOrServers[0].checked == true){
		if(document.LTBRegistrationForm2010REVAMP.YourOption[0].checked == false && document.LTBRegistrationForm2010REVAMP.YourOption[1].checked == false && document.LTBRegistrationForm2010REVAMP.YourOption[2].checked == false ){
			blanks.push(count+1 + ". " + "Specify which PCs & servers you make\n");
	  		count++;
		}
	}

   temp = blanks.toString();
   if(temp){
      for(var i=0; i<count; i++){
	     temp=temp.replace(",", "");
	  }
      alert("Please fill out the following fields: \n\n" + temp);
      return false;
   }
   else{
	return true;
   }
}

function HaveShopfront(){
	if (document.LTBRegistrationForm2010REVAMP.DoYouHaveShopfront[0].checked == true){
		document.getElementById('HowManyShopfronts').style.display = "block";
	}
	else{
		document.getElementById('HowManyShopfronts').style.display = "none";		
	}	
}

function DoYouMakeOwnPC(){
	if (document.LTBRegistrationForm2010REVAMP.DoYouMakeYourOwnPCsOrServers[0].checked == true){
		document.getElementById('DoYouMakeOwnPC').style.display = "block";
	}
	else{
	  	 for(var i=0; i<document.LTBRegistrationForm2010REVAMP.YourOption.length; i++){
	        document.LTBRegistrationForm2010REVAMP.YourOption[i].checked = false;
	     }
		 document.getElementById('DoYouMakeOwnPC').style.display = "none";		
	}	
}

function redirect(){
   var member = document.AreYouALTBMember.MemberOfLTB;
   var email = document.AreYouALTBMember.Email;
   var val = "";
   
   for(var i=0; i<member.length; i++){
      if(member[i].checked){
	     val = member[i].value;
	  }
   }
   if(val == 'No'){
	  window.location = 'http://intelletstalkbiz.com/forms/registration2010test';
   }  
}

function showLTB(){
	document.getElementById('LTB').style.display = 'block';
}

function validate(){
   var member = document.AreYouALTBMember.MemberOfLTB;
   var email = document.AreYouALTBMember.Email;
   var val = "";

   if(document.AreYouALTBMember.MemberOfLTB[0].checked == true ){
      if(email.value == ""){
	     alert("Please enter your email address.");
		 return false;
	  }
	  if(!echeck(email.value)){
         email.value = "";
		 alert("Please enter valid email address.");
	     email.focus();
	     return false;
      }
   }   
}

function load(address) {
var load = window.open(address,'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}












