// this function will validate a form
// a = the element and their values
function validateForm(a){
	/*// verify the form elements and error in red as needed
	failed = Array();
	required = Array(a['name'].value,a['email'].value,a['comment'].value);
	pass = false;
	for(i=0;i<required.length;i++){
		if(required[i] != ""){
			//pass = true;
		}else{
			pass = false;
			//failed[] = "";
		}
	  //pass = (required[i] != "" ? true:false);
	}
	if(a['countries'].value == "OU" && a['country'].value == ""){
		pass = false;	
	}
	
	// if no errors, run the ajax call to send the message
	if(pass == true){
		alert("Passed validation!!");
	}else{
		alert("Failed validation!!");	
	}
	
	// if no error sending the message, swap out the form for a thank you message!*/
}

// this function will validate the share link info
// a = the elements from the form
function validateShare(a){
	ret = 1;
	
	for(i=0;i<a.length;i++){
		//alert(i);
		if(document.forms['share'].elements[a[i]].value == ""){
			ret = 0;
			document.getElementById("label_"+a[i]).style.color = "#660000";
		}else{
			document.getElementById("label_"+a[i]).style.color = "#333333";
		}
		if(i == 3 && (document.forms['share'].elements[a[2]].value != document.forms['share'].elements[a[3]].value)){
			ret = 0;
			document.getElementById('label_sendto').style.color = "#660000";
			document.getElementById('label_verifysendto').style.color = "#660000";
			document.forms['share'].elements[a[3]].value = "";
		}
	}
	
	if(ret == 0){
		document.getElementById('sharemessages').innerHTML = "<span class='error'>Errors were Found in your submission.</span>";
	}
	return ret;
}

// this function will send a share email
function shareLink(){
	$.post('_libraries/php/library.sendlink.php',{'link':document.forms['share'].elements['sharelink'].value,'name':document.forms['share'].elements['name'].value,'from':document.forms['share'].elements['email'].value,'to':document.forms['share'].elements['sendto'].value},function(data){if(data == 1){document.getElementById('sharemessages').innerHTML="<span class='success'>Your message has been sent.</span>";}else{document.getElementById('sharemessages').innerHTML="<span class='error'>Error.  Please try again.</span>";}});
	setTimeout("shareThis(0);",3000);
}
