var $j=jQuery.noConflict();
$j(document).ready(function(){
// Contact us Portion Starts
	
	$j(".con-req").focus(function(){
			$j(this).attr('style','border:1px solid #999999');
			if($j(this).attr('tagName') == "SELECT")
				$j(this).css({'width':'40px'});
				
			if($j(this).attr('id') == "booking_start_date")
				$j(this).css({'width':'220px'});
			if($j(this).attr('id') == "booking_end_date")
				$j(this).css({'width':'220px'});
	});
	
	$j(".con-req").blur(function(){
		if($j(this).isEmpty())
		{	
			$j(this).attr('style','border:1px solid #FF0000');
			$j(this).addClass('denied');
			
			if($j(this).attr('tagName') == "SELECT")
			{
					$j(this).css({'width':'40px','color':'#FF0000'});
			}
			if($j(this).attr('id') == "booking_start_date")
				$j(this).css({'width':'220px','border':'1px solid #FF0000'});
			if($j(this).attr('id') == "booking_end_date")
				$j(this).css({'width':'220px','border':'1px solid #FF0000'});
		}
		else if(!$j(this).emailCheck() && $j(this).attr('id') == 'email')
		{   
			$j(this).attr('style','border:1px solid #FF0000');
			$j(this).addClass('denied');
		}
		else if($j(this).attr('id') == 'phone' && !checkPhone($j('#'+$j(this).attr('id')).val()))
		{
			$j(this).attr('style','border:1px solid #FF0000');
			$j(this).addClass('denied');
		}
		
		else if(($j(this).attr('id') == 'booking_start_date' || $j(this).attr('id') == 'booking_end_date') && (!$j("#booking_start_date").isEmpty() && !$j("#booking_end_date").isEmpty()) && !DateCompare($j("#booking_start_date").val(),$j("#booking_end_date").val()))
		{   
			$j(this).attr('style','border:1px solid #FF0000');
			$j(this).addClass('denied');
		}

		else
		{
			$j(this).attr('style','border:1px solid #347C17');
			$j(this).removeClass('denied');
			
			if($j(this).attr('tagName') == "SELECT")
					$j(this).css({'width':'40px','color':'#347C17'});
		}
	});

$j("#reset").click(function()
{
	if($j(this).attr('tagName') == "SELECT")
			$j(this).css({'width':'40px','color':'#000000'});
	$j('.con-req').css({'border':'1px solid #C2DAF1','display:':'block','color':'#000000'});
});

});
// Contact us Portion Starts
function booking(formID)
{
	$j(".con-req").blur();
	if($j(".denied").length == 0)
	{
		var data=$j('#'+formID).serializeArray();		
		$j.ajax({
				type:'POST',
				url:'contact_mail_send.php',
				data: data,
				dataType:'json',
				success:function(jData){
					if(jData.flag == 1)
					{
						$j('#contact').html(jData.html);
					}
					else if(jData.flag == 2)
					{
						$j('#err').html(jData.html);
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					$j(".contactus-block").html("Some server error occoured. Please report to system administrator.</div>");
				}
		});
	
	}
	
	
}
//Contact us Portion Ends
function checkPhone(elem)
{
var phoneRegExp =/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,13})(-| )?(\d{1})(( x| ext)\d{1,5}){0,1}$/; 
if (elem.match(phoneRegExp)) 
return true;
}
/* this is for number only check starts */
function numCheck(val)
{
	var number =/^(\d){1,}$/; 
	if (val.match(number)) 
	{
			return true;
	} 
	else 
	{
			return false;
	}
}

