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



   //submission scripts
  $('.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;
		}
		
		  $('.contactForm').submit();

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

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