
// JavaScript Document

// common file names and paths.

var ZIKSURL = ''; // localserver.

var ZIKS_JS_PATH = ZIKSURL + "/js";
var ZIKS_CSS_PATH = ZIKSURL + "/css";
var ZIKS_IMAGE_PATH = ZIKSURL + "images";

function validateEmail( strEmailId )
{
	if( $.trim(strEmailId).length > 0 ){		
		var ret = 0;
		var filter = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
		$('#inputresult').show();
		if( !filter.test( strEmailId ) ){
			$('#inputresult').css("background-image", "url("+ZIKS_IMAGE_PATH+"/validNo.png)"); return false;
		} else {
			$('#inputresult').css("background-image", "url("+ZIKS_IMAGE_PATH+"/validYes.png)");return true;
		}
	} else {
		$('#inputresult').hide(); return false; 
	}
	strEmailId = '';
	return ret;
}

function getUpdates()
{
	var strEmailId = $("#emailid").val();
	if( validateEmail(strEmailId) ){
		$('#emailupdates').html('');
		$.ajax({			
			//onLoading: function(){$('#emailupdates').html("<div>Please wait...</div>");},
			url: 'sendmail.php',
			type: 'POST',
			timeout: 1000,
			data: { email: strEmailId, fromwhere: 'AJAXREQ' },			
			error: function(){
				$('#emailupdates').html('<div style="text-align: left; padding-left: 10px; padding-top: 18px;">Could not update your mail address. Try again after sometime.</div>');
			},
			success: function( iSentEmail ){
				if( iSentEmail ) {
					$('#emailupdates').html('<div style="text-align: left; padding-left: 10px; padding-top: 18px;">Successfully subscribed to recieve updates.</div>');
				}
			}
		});
	} else {
		alert("Please provide a valid email id to get updates");
		$("#emailid").focus();
		return false;
	}
}

function validateName( strName )
{
	return (/^[a-z]+ ?[a-z]+$/i).test( strName );
}


function validateForm1()
{
	if( validateName( $('#fullname').val() ) )
	{
		var strEmailId = $('#conemailid').val();
		if( validateEmail( strEmailId  ) )
		{			
			var confemail = $('#cemailid').val();			
			if( strEmailId  != confemail )
			{
				alert( "Email confirmation does not match" );		
				$('#cemailid').focus();
				return false;
			}
			else
			{
				if( $('#subject').val() == '' )
				{
					alert( "Please enter subject" );		
					$('#subject').focus();
					return false;
				}
				else
				{	
					if( $('#msg').val() == '' )
					{
						alert( "Please enter Message" );		
						$('#msg').focus();
						return false;
					}
					else
					{	
						document.contactusform.submit();
					}
				}
			}
		}
		else
		{
			alert( "Please enter a valid email id" );		
			$('#conemailid').focus();
			return false;
		}
	}
	else
	{
		alert( "Please enter name" );		
		$('#fullname').focus();
		return false;
	}
}


$(document).ready(function(){ 
	/*var length = $("#tips li").length;
	var ran = Math.floor(Math.random()*length) + 1;
	$("#tips li:nth-child(" + ran + ")").show();
	*/
	$("#tips").hide();
});

