// ALTERNATIVE LIST BACKGROUNDS ON HOMEPAGE

$(document).ready(function() {
						   
	$('.box-child-quarter ul li:even').addClass('alt');	
	
	$('a[@rel$="external"]').click(function(){this.target = "_blank";});
	
	$('input.key-words').click(function(){
		if ($(this).val() == 'enter keywords') {
			$(this).val('');
		}
	});

	$('input.key-words').blur(function(){
		if ($(this).val() == '') {
			$(this).val('enter keywords');
		}
	});

	//scroll testimonial
	$('#featured-testimonials').cycle({ 
		cleartype:  1 ,
		timeout:  8000,
		speed: 900, 
		fx: 'scrollLeft'
	});

  //EMAIL REPLACEMENT
  $("span.safemail").each(function(){
    exp = $(this).text().search(/\((.*?)\)/) != -1 ? new RegExp(/(.*?) \((.*?)\)/) : new RegExp(/.*/);
    match = exp.exec($(this).text());
    addr = match[1] ? match[1].replace(/ at /,"@").replace(/ dot /g,".") : match[0].replace(/ at /,"@").replace(/ dot /g,".");
    emaillink = match[2] ? match[2] : addr;
    subject = $(this).attr('title') ? "?subject="+$(this).attr('title').replace(/ /g,"%20") : "";
     $(this).after('<a href="mailto:'+addr+subject+'">'+ emaillink + '</a>');
    $(this).remove();
  });
  $("input.safemail").each(function(){
    $(this).val($(this).val().replace(/ at /,"@").replace(/ dot /g,"."));
  });



});


// VALIDATE CONTACT FORM

function ValidateForm(f){

  with(f){
	 if (isEmpty(_10_Name.value)) {
		alert("Please enter your Name");
		_10_Name.focus();
		return false;
	 }

	 if (isEmpty(_15_Email_From.value)) {
		alert("Please enter your Email Address");
		_15_Email_From.focus();
		return false;
	 }

	 if ( !isEmail(_15_Email_From.value) ) {
		alert("Please enter a valid Email Address.");
		_15_Email_From.focus();
		return false;
	 }
	 
	 if (isEmpty(_20_Phone.value)) {
		alert("Please enter your Phone number");
		_20_Phone.focus();
		return false;
	 }
	 
	if (isEmpty(_25_Comments.value)) {
		alert("Please enter your query in the comments field");
		_25_Comments.focus();
		return false;
	 }
       
   	}
   return true;
 }
