var $jq = jQuery.noConflict();	

$jq(document).ready(function(){
	//function for contact form dropdown
	function contact() {
		if ($jq("#contactForm").is(":hidden")){
			//$jq("#contactForm").slideDown("slow");
			$jq("#contactForm").slideDown("slow");
			//$jq("#backgroundPopup").css({"opacity": "0.7"});
			$jq("#backgroundPopup").fadeIn("slow"); 
			/*Pranami-30nov09*/
			$jq(".contact").fadeOut("slow");
			///End
		}
		else{
			//alert("i m here");
			$jq("#contactForm").slideUp("slow");
			$jq("#backgroundPopup").fadeOut("slow"); 
			/*Pranami-30nov*/
			$jq(".contact").show(200);
			$jq(".contact").html('<div class="login_bt"></div>');
			///End
		}
	}
	 
	//run contact form when any contact link is clicked
	$jq(".contact").click(function(){contact()});
	$jq(".login_bt_down").click(function(){contact()});
	
	//animation for same page links #
	$jq('a[href*=#]').each(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname
		&& this.hash.replace(/#/,'') ) {
		  var $targetId = $jq(this.hash), $targetAnchor = $jq('[name=' + this.hash.slice(1) +']');
		  var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
			if ($jq(this.hash).length) {
				$jq(this).click(function(event) {
					var targetOffset = $jq(this.hash).offset().top;
					var target = this.hash;
					event.preventDefault();			   
					$jq('html, body').animate({scrollTop: targetOffset}, 500);
					return false;
				});
			}
		}
	});



   //submission scripts
  $jq('.contactForm').submit( function(){
		//statements to validate the form	
		if('' == document.getElementById('name').value)
		{
			alert("Please enter valid name");
			document.getElementById('name').focus();
			return false;
		}
		if('' == document.getElementById('company').value)
		{
			alert("Please enter Company name");
			document.getElementById('company').focus();
			return false;
		}
		if('' == document.getElementById('website').value)
		{
			alert("Please enter website");
			document.getElementById('website').focus();
			return false;
		}
		var emailval = document.getElementById('e-mail');
		if( !(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/).test(emailval.value) )
		{
			alert("Entered email address is blank or invalid");
			document.getElementById('e-mail').focus();
			return false;
		}
		
		if( "" == document.getElementById('phone').value )
		{
			alert("Please enter phone");
			document.getElementById('phone').focus();
			return false;
		}
		
		  $jq('.contactForm').submit();

		/*
			//send the ajax request
		$jq.post('mail.php',{name:$jq('#name').val(),
						  company:$jq('#company').val(),
						  email:$jq('#e-mail').val(),
						  website:$jq('#website').val(),
						  phone:$jq('#phone').val(),
						  submit:$jq('#submit').val()},
		
			//return the data
			//alert(data);
			function(data){
			  //hide the graphic
			if('1' == data)
			{
				$jq('.fpmng').html('Your form has been submitted. We will get back to you soon');
				
				$jq("#name").val("Name");
				$jq("#e-mail").val("eMail");
				$jq("#company").val("Company");
				$jq("#website").val("Website");
				$jq("#phone").val("Phone");
			}
			});
			
			//stay on the page
			return false; 			
		*/
  });

	//only need force for IE6  
	$jq("#backgroundPopup").css({  
		"height": document.documentElement.clientHeight 
	});  
});