function swapContact(cLink , newContact) {
	
	for(var i =1; i<=7; i++) {
		oldContact = document.getElementById("contact"+i);
		if (oldContact.style.display != "none")oldContact.style.display = "none";
		oldLink = document.getElementsByTagName("a");
		for (var x=0; x< oldLink.length; x++){
			var link1 = oldLink[x].getAttribute("class");
			if(link1 == "selected")oldLink[x].setAttribute("class","");
		}
		
	}
	Effect.Appear(newContact,{queue: 'start', duration: 0.3});
	document.getElementById(cLink).setAttribute("class","selected");
	Effect.Morph(cLink, {style: 'background:#fff; color:#000;', duration: 0.8});
	
	
}
function clearError(id) {
	er = document.getElementById(id);
	classExist = er.getAttribute("class");
	var cutpoint = classExist.indexOf(' error-message');
	if (cutpoint != -1)classExist = classExist.substring(0,cutpoint);
	
	er.setAttribute("class",classExist);
	
}
function formError(id) {
	er = document.getElementById(id);
	classExist = er.getAttribute("class");
	classExist += " error-message";
	er.setAttribute("class",classExist);
}
function shippingChange() {
	var shipMethod = document.sampleForm.shipping;
	toggle('shippingOptions');
	
}

function toggle(id) {
	
	elem = document.getElementById(id);
	if(elem.style.display == "none") Effect.SlideDown(id, {queue: 'start'});
	else Effect.SlideUp(id, {queue: 'start'});
}


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")
		   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
		 }

 		 return true					
	}

function ValidateForm() {
	var name=document.sampleForm.Name;
	var emailID=document.sampleForm.Email;
	var company=document.sampleForm.Project;
	var add1=document.sampleForm.Street1;
	var city=document.sampleForm.City;
	var state=document.sampleForm.State;
	var zip=document.sampleForm.Zip;
	var tel=document.sampleForm.Phone;
	var isClear = true;
	
	if ((emailID.value==null)||(emailID.value=="" || echeck(emailID.value)==false)){
		//alert("Please Enter your Email!")
		formError("Email");
		emailID.focus()
		isClear = false;
	} else clearError("Email");
	
	if ( company.value == "" ){
		//alert("Please enter your Company!")
		formError("Project");
		isClear = false;
	} else clearError("Project");

	if ( name.value == "" ){
		//alert("You must provide your Name!")
		formError("Name");
		isClear = false;
	} else clearError("Name");
	if ( add1.value == "" ){
		//alert("You must provide your street address!")
		formError("Street1");
		isClear = false;
	} else clearError("Street1");
	if ( city.value == "" ){
		//alert("Please provide your City")
		formError("City");
		isClear = false;
	} else clearError("City");
	if ( state.value == "DNS" ){
		//alert("Please provide your State/Province")
		formError("State");
		isClear = false;
	}	else clearError("State");
	if ( zip.value == "" ){
		//alert("Please provide your Zip/Postal Code")
		formError("Zip");
		isClear = false;
	}	else clearError("Zip");
	if ( tel.value == "" ){
		//alert("You must provide your phone number!")
		formError("Phone");
		isClear = false;
	}

	return isClear;
 } 
