// JavaScript Document

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}

	

function processRequest(){
	
	//var pn ="<% response.write(product_name) %>";
	
	var n = $('#name').val();
	var e = $('#email').val();
	var p = $('#phone').val();
	
	
	var error = '';
	if(n == 'name' || n == ''){ 
		error = 'Please enter your name.'; 
		bg = '#name';
	}
	
	if(!isValidEmailAddress(e)){  
		error = 'Please enter a valid email.' 
		bg = '#email';
	}
	
	if(p == 'phone'|| p == ''){ 
		error = 'Please please enter your phone.'; 
		bg = '#phone';
	}
	
	
	if(error == ''){
		$("#download_convert").submit();
	}else{
		$('#dl_copy').html(error);
		$('#dl_copy').css('background-color','#990000');
		$('#dl_copy').css('padding','4px');
	}

}

function clearInput(n){
	if(n.value == n.name){
		n.value = "";
	}
	$('.convert_note').html("Enter "+n.name);
	
}

function restoreInput(n){
	if(n.value == ''){n.value=n.name};
	$('.convert_note').html("* All Fields Required");
}

function expandWidget(){
	$('.expand_content').show();
}

function collapseWidget(){
	
	$('.expand_content').hide();
}

