/* 

Modal Window (Popup Box)

This is to be used together with jquery-latest.pack.js and modal.css. 

*/

$(document).ready(function() {	

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(50);	
		$('#mask').fadeTo("fast",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(100); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});

function FormContact_Validator(Form){



if (Form.input_1.value == ""){

	alert("Please enter your First Name");

	Form.input_1.focus();

	return (false);

	}

if (Form.input_2.value == ""){

	alert("Please enter your Last Name");

	Form.input_2.focus();

	return (false);

	}


with (Form)
{

if ((input_3.value==null)||(input_3.value=="")){

		alert("Please Enter Your Email Address")

		input_3.focus()

		return false

	}

if (validate_email(input_3,"Your Email Address is Not Valid!")==false)

  {input_3.focus();return false}

}



if (Form.input_7.value == ""){

	alert("Please enter your message.");

	Form.input_7.focus();

	return (false);

	}

}

function FormQuote_Validator(Form){



if (Form.input_1.value == ""){

	alert("Please enter your First Name");

	Form.input_1.focus();

	return (false);

	}

if (Form.input_2.value == ""){

	alert("Please enter your Last Name");

	Form.input_2.focus();

	return (false);

	}


with (Form)
{

if ((input_3.value==null)||(input_3.value=="")){

		alert("Please Enter Your Email Address")

		input_3.focus()

		return false

	}

if (validate_email(input_3,"Your Email Address is Not Valid!")==false)

  {input_3.focus();return false}

}



if (Form.input_6.value == ""){

	alert("Please provide your Project Brief.");

	Form.input_6.focus();

	return (false);

	}

}


function validate_email(field,alerttxt){

with (field){

apos=value.indexOf("@")

dotpos=value.lastIndexOf(".")

   if (apos<1||dotpos-apos<2) 

     {alert(alerttxt);return false}

   else {return true}

   }

}

