
/******** Login form Validation ********/

function LoginValidation(thisForm){
	with(thisForm){
		if(txtLogin.value=="Email"){
			alert("Please Enter Email Id");
			txtLogin.focus();
			return false;
		}else if(emptyValidation(txtLogin,'Please Enter Email Id')==false){
			txtLogin.focus();
			return false;
		}else{
			if(emailValidation(txtLogin,'Invalid Email Id')==false){
				txtLogin.focus();
				return false;
			}
		}
		if(emptyValidation(txtPass,'Please Enter Password')==false){
			txtPass.focus();
			return false;
		}
	}
}


/*----------- Empty Field Validation -----------*/
function emptyValidation(obj,msg)
{
	with(obj)
	{
		if(value==null || value=="")
		{
			if(msg!=null) 
			{
				alert(msg);
				return false;
			}
		}
		else{
			return true;
		}
	}
}

/*----------- Email Validation -----------*/

function emailValidation(obj,msg){
	with(obj){
		apos=value.indexOf('@');
		dotpos=value.lastIndexOf('.');
		len=(value.length) - 1;
		if(apos<1||dotpos-apos<2||len-dotpos>3||len-dotpos<2){
			if(msg!=null){
				alert(msg);						
			}
			return false;
		}
		else{
			return true;
		}
	}
}


/******** For scrolling news starts ********/

	var headline_count;
	var headline_interval;
	var old_headline = 0;
	var current_headline = 0;

	/*var headline_count;
	var current_headline=0;*/

	$(document).ready(function(){
	  headline_count = $("div.headline").size();
	  $("div.headline:eq("+current_headline+")").css('top', '5px');
	 // setInterval(headline_rotate,5000); //time in milliseconds
	  headline_interval = setInterval(headline_rotate,5000);

	  $('#scrollup').hover(function() {
		 clearInterval(headline_interval);
		  }, function() {
		 headline_interval = setInterval(headline_rotate,5000);
		/* headline_rotate();*/
		  });
	});

	function headline_rotate() {
	
	 /* old_headline = current_headline % headline_count;
	  new_headline = ++current_headline % headline_count;
	  $("div.headline:eq(" + old_headline + ")").css('top', '210px');
	  $("div.headline:eq(" + new_headline + ")").show().animate({top: 5},"slow");     */

	  current_headline = (old_headline + 1) % headline_count;
		  $("div.headline:eq(" + old_headline + ")")
		 .animate({top: -205},"slow", function() {
		   $(this).css('top', '210px');
		 });
		  $("div.headline:eq(" + current_headline + ")")
		 .animate({top: 5},"slow");
		  old_headline = current_headline;
	}

	function back() {
	
		current_headline = (old_headline - 1) % headline_count;	
		//alert(current_headline);
		if(current_headline < 0){
			
			current_headline = headline_count-1;
		}
		  $("div.headline:eq(" + old_headline + ")")
		 .animate({top: -205},"slow", function() {
		   $(this).css('top', '210px');
		 });
		  $("div.headline:eq(" + current_headline + ")")
		 .animate({top: 5},"slow");
		  old_headline = current_headline;
		  
	}

	function forward() {	   	
		current_headline = (old_headline + 1) % headline_count;				
		  $("div.headline:eq(" + old_headline + ")")
		 .animate({top: -205},"slow", function() {
		   $(this).css('top', '210px');
		 });
		  $("div.headline:eq(" + current_headline + ")")
		 .animate({top: 5},"slow");
		  old_headline = current_headline;  
	}

//********** Scrolling News Ends *************//
