$(document).ready(function(){
	//Dropdown function
	$("#nav li:last").css("display","none");
	$('#nav').droppy();
	
	
	$("a[href*=.pdf]").click(function()	{
		$(this).attr({"target":"_self"});
		return false;
	});
	
	$('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
	
	$("a[href*=/contact-us.html]").click(function()	{
		window.open( $(this).attr('href') );
        return false;
	});
	
	
	$('a[rel="send_to_friend"]').click(openSendFriendPop);

	$('input[type="text"]').addClass("idleField");
	$('input[type="text"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	// for the contact textarea	
	$('#comment').addClass("idleField");
	$('#comment').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('#comment').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	
	//$("#searchSend").corner("bottom"); .css("display", "none")


// VALIDATE : CONTACT FORM
	$("#contactForm").validate({
		rules: {
			fullName: "required",
			companyName: "required",
			address: "required",
			phoneNumber: "required",
			userEmail: "required",
			comment: "required"
		},
		messages: {
			fullName: "",
			companyName: "",
			address: "",
			phoneNumber: "",
			userEmail: "",
			comment: ""
		}
	});
	
	
	
});


function openSendFriendPop()
{
	var linkURL = $('a[rel="send_to_friend"]').attr("href");
	window.open(linkURL,"Send to a Friend","menubar=no,width=580,height=240,toolbar=no" );
	return false;
}
function popUp(URL)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=580,height=240,left = 350,top = 392');");
}
