var $j=jQuery.noConflict();
$j(document).ready(function(){
// Contact us Portion Starts
	$j(".con-req").focus(function(){
		removeValidationImg($j(this));
		$j(this).after('<img src="img/write_icon.gif" align="absmiddle" alt="write"  title="Write" onmouseover="show(this)" help="write name" />');
	});
	$j(".con-req").blur(function(){
		removeValidationImg($j(this));
		if($j(this).isEmpty())
		{	
			$j(this).after('<img src="img/wrong_icon.gif" align="absmiddle" alt="wrong" />');
			$j(this).addClass('denied');
			
		}
		else if(!$j(this).emailCheck() && $j(this).attr('id') == 'contact_email')
		{   removeValidationImg($j(this));
			$j(this).after('<img src="img/wrong_icon.gif" align="absmiddle" alt="wrong" />');
			$j(this).addClass('denied');
		}
		else if($j(this).attr('id') == 'contact_mob' && !checkPhone($j('#'+$j(this).attr('id')).val()))
		{
			$j(this).after('<img src="img/wrong_icon.gif" align="absmiddle" alt="wrong" />');
			$j(this).addClass('denied');
		}
		else
		{
			//removeValidationImg($j(this));
			$j(this).after('<img src="img/correct_icon.gif" align="absmiddle" alt="correct" />');
			$j(this).next('img').fadeOut(3700);
			$j(this).removeClass('denied');
		}
	});
//Contact us Portion Ends
$j(".con-notreq").blur(function(){ 
removeValidationImg($j(this));
if(!$j(this).isEmpty())
{
		if($j(this).attr('id') == 'contact_phone' && !checkPhone($j('#'+$j(this).attr('id')).val()))
		{
			$j(this).after('<img src="img/wrong_icon.gif" align="absmiddle" alt="wrong" />');
			$j(this).addClass('denied');
		}
		else
		{
			removeValidationImg($j(this));
			$j(this).after('<img src="img/correct_icon.gif" align="absmiddle" alt="correct" />');
			$j(this).next('img').fadeOut(3700);
			$j(this).removeClass('denied');
		}
}
								
});
	$j(".reset").click(function(){
		$j(":input").next('img').attr('style','display:none;');
		$j("#contact_captcha").next('img').attr('style','display:none;');
		$j(":input").removeClass('denied');
	});


});


// Contact us Portion Starts
function recruitment(formID)
{
	$j(".con-req").blur();
	$j(".con-notreq").blur();
	if($j(".denied").length == 0){	
		var data=$j('#'+formID).serializeArray();
		$j(".contactus-block").html('<div style="width:400px; margin-top:20px; text-align:center;"><img src="img/ajax-loader.gif" border="0"></div>');
		
		$j.ajax({
				
				type:'POST',
				url:'contact_mail_send.php',
				data: data,
				dataType:'json',
				success:function(jData){
					if(jData.flag == 1)
					{
						//alert(jData.html);
						
						$j('.contactus').html(jData.html);
						//document.register_form.submit();
					}
					 if(jData.flag == 0)
					{
						$j('#contact_captcha').next('img').remove();
						$j('#contact_captcha').after('<img src="img/wrong_icon.gif" align="absmiddle" alt="wrong" />');
						
					}
					if(jData.flag == 2)
					{					
						$j('#duplicate_mesg').html(jData.html);
						//document.register_form.submit();
						
						$j('#register_email').after('<img src="img/wrong_icon.gif" align="absmiddle" alt="wrong">');
						$j(this).addClass('denied');
						
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					$j(".contactus-block").html("Some server error occoured. Please report to system administrator.</div>");
				}
		});
	}
}
//Contact us Portion Ends

function removeValidationImg(elem)
{
	jQuery(elem).next('img[@alt="write"]').remove();
	jQuery(elem).next('img[@alt="wrong"]').remove();
	jQuery(elem).removeClass('denied');
	jQuery(elem).next('img[@alt="correct"]').remove();
	jQuery(elem).removeClass('denied');
}


function checkPhone(elem)
{
	//alert(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}$/; 
var phoneRegExp = /^\(?[0-9]\d{2,3}[\)\.-]?\s?\d{3,4}[\s\.-]?\d{4,6}(\s|)$/
if (elem.match(phoneRegExp)) 
return true;
}
function show(elem)
{
	var a = '<div>dsfsddsfdfsdsdfsd</div>';
	//alert($j(elem).attr('help'));
	
	
}

