jQuery.noConflict();
jQuery(document).ready(function($) {
	var searchvalue = $("#search").attr("class");;
	$("#search").attr('value', searchvalue+"...");
	
	$("#search").bind("click", function(){
		if($(this).attr('value') == searchvalue+"...")
			$(this).attr('value', '');//
	});
	$("#search").bind("blur", function(){
		if($(this).attr('value') == undefined)
			$(this).attr('value', searchvalue+"...");
	});
	
	$("#searchbutton").bind("click", function() {
		$('form').submit();
	});
	
	$("#lngLink").bind("click", function(){
		$("#messageDiv").animate({
		   height: 'show', width:'show', opacity: 'show'
		 }, 500, function() {
		   		$.post("scripts/mailer.php", function(data){ 
					var test = data.documentElement.childNodes[1].textContent;
					$("#messageDiv").html(test);
					bindSubmit();
				  //alert("Data Loaded: " + test); 
				});
		   });
		$("#close").bind("click", function(){
			$("#messageDiv").animate({
				height: 'hide', width:'hide', opacity: 'hide'
		 }, 500);
		});
	});
	
	bindSubmit();
 
function bindSubmit() {
 	 $("#submitbutton").bind("click", function(){
		
		//$.post("scripts/mailer.php", function(data){ 
		//	var test = data.documentElement.childNodes[1].textContent;
		//  alert("Data Loaded: " + test); 
		//});
		var email = $("#email").val();
		var form = $("#mailer");
		if(validateEmail(email))
			form.submit();
		else
			$("#alert").show();
	});

}

 });

function validateEmail(email)
{
 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
 return email.match(re)
} 

function popupWindow(url){	
  w=window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=400,height=470,screenX=100,screenY=100,top=100,left=100,menu=no')
}