// JavaScript Document
	var i = 0;
	var $autoplay = true;	
	var logo_pos = Array ("20", "110", "230", "350", "450", "560", "660","750","850");	
	var logo_text = Array ("Welcome to Shriram General Insurance.",
						   "Products to meet your requirement.", 
						   "Branch Locations with address.",
						   "Claims procedure and phone numbers.",
						   "Services to meet your requirement.",
						   "Join our community to share views.",
						   "Become an Agent for rewarding career.",
						  "Learn about our world class knowledge center.",
						  "Meet the management team or find jobs openings."
						   );		
	
//	var logo_pos = Array ("120","760",  "400", "515","240", "660",  "860");		

function fadeInLogo() {
		$(".img_bubble").fadeIn("slow");	
}

function fadeOutLogo() {
		$(".img_bubble").fadeOut("slow");	
}

function playLogo(ivar) {
	if( ivar < logo_pos.length && $autoplay == true ) {
		
//			alert(logo_pos[ivar]);
		$(".hover_content").animate({ left:logo_pos[ivar]+"px"  }, "1500");
		setTimeout("fadeInLogo()", 500);	
		
		$(".logoHoverText").html(logo_text[ivar]);
		
		setTimeout("fadeOutLogo()", 4500);			
		
		if(ivar > 4) {
			$(".img_bubble").removeClass("img_bubble_right");				
			$(".img_bubble").addClass("img_bubble_left");
			
			$(".logoHoverText").removeClass("logoHoverText_left");
			$(".logoHoverText").addClass("logoHoverText_right");						
		}
		else {
			$(".img_bubble").addClass("img_bubble_right");				
			$(".img_bubble").removeClass("img_bubble_left");
		
			$(".logoHoverText").addClass("logoHoverText_left");
			$(".logoHoverText").removeClass("logoHoverText_right");										
		}
		
		ivar = parseInt(ivar) + 1 ;			
		setTimeout("playLogo('"+ ivar + "')", 5000);	
	}
}



function playLogoHover(ivar) {
	
//			alert(logo_pos[ivar]);
		$(".hover_content").animate({ marginTop:"40px"  }, "1500", function() {
															$(".hover_content img").css("display", "none");
																			});
		setTimeout("fadeOutLogo()", 0);			
		$(".hover_content").animate({ left:logo_pos[ivar]+"px"  }, "1500", function() {
													$(".hover_content img").css("display", "block");
													$(".hover_content").animate({ marginTop:"-5px"  }, "1500");																					
																					
																					});
		setTimeout("fadeInLogo()", 500);	
		
		$(".logoHoverText").html( logo_text[ivar] );
		

		
		if(ivar > 4) {
			$(".img_bubble").removeClass("img_bubble_right");				
			$(".img_bubble").addClass("img_bubble_left");
			
			$(".logoHoverText").removeClass("logoHoverText_left");
			$(".logoHoverText").addClass("logoHoverText_right");						
		}
		else {
			$(".img_bubble").addClass("img_bubble_right");				
			$(".img_bubble").removeClass("img_bubble_left");
		
			$(".logoHoverText").addClass("logoHoverText_left");
			$(".logoHoverText").removeClass("logoHoverText_right");										
		}
		
		ivar = parseInt(ivar) + 1 ;			
}


$(document).ready(function(){
	var $timeid = "";					   
/*	$('#display_board').innerfade({
		animationtype: 'fade',
		speed: "slow",
		timeout: 4000,
		type: 'sequence',
		containerheight: '220px'
	});*/


	
//	$('#display_board').cycle({ fx:'fade', speed: 800, pause:3, random:  1 });	
						   
	//$("img").pngfix();						   

	
	
	setTimeout("playLogo('0')", 3500);
	
	
	
	$(".nav_link_name").bind("mouseover", function() {
//		alert( $(this). );
		$autoplay = false;
		$hovered_link = $(".nav_link_name").index( $(this)[0] );
		$timeid = setTimeout( "playLogoHover($hovered_link)", 500 );
			
//		$(".hover_content").animate({ left:logo_pos[ivar]+"px"  }, "1500");														   
   });
	
	$(".nav_link_name").bind("mouseout", function() {
		clearTimeout($timeid);							   
	});
	

	
	
	$(".nav_link .nav_link_name").bind("mouseover", function() {
			if( !$(this).hasClass("active_link") ) {												  
				$(".menu_items").css("visibility", "hidden");		
				$(this).find(".items").css({ marginTop:"-20px" });										
				$(this).parent().find(".items").css({ marginTop:"0px" });																			
				$h = $(this).parent().find(".items").height();				   	
				$(".nav_link_name").removeClass("hover_link");			
				$(this).addClass("hover_link");
					
				if ( !($(this).parent().find(".menu_items").hasClass("nomenu"))  ) {
					
	
					$(this).parent().find(".menu_items").css("visibility", "visible");
					$(this).parent().find(".menu_items").animate({ height:$h+'px' }, 100);
					i=1;
				}
			}
	});
	
	$(".nav_link .nav_link_name").bind("mouseout", function() {
		$id = $(this).parent(".nav_link");
		//alert($id);
		i=1;
		setTimeout("hide_menu($id)", 0);
	});
	
	$(".nav_link .menu_items").bind("mouseover", function() {
		$h = $(this).parent().find(".items").height();		
		//alert($h);		

		$(this).css({ height:$h + 'px' });
		i=0;
	});
	
	$(".nav_link .menu_items").bind("mouseout", function() {	
		$id = $(this).parent(".nav_link");
		i=1;
		setTimeout("hide_menu($id)", 0);													   
   });
	
	
/// FOR DEFAULT TEXT ON TEXTBOX	
	 $('.input_default').focus(function() {
		$dft = $(this).attr("title");
		if( $(this).val() == $dft )  {
		  $(this).removeClass("default_on");
		  $(this).addClass("default_off");	
		  $(this).val("");		  		  
		}
	  });
	 
	 $('.input_default').bind("keydown", function() {
		$dft = $(this).attr("title");
		if( $(this).val() == $dft )  {
		  $(this).removeClass("default_on");
		  $(this).addClass("default_off");	
		  $(this).val("");		  		  
		}
	  });	 
	 
	  $('.input_default').blur(function() {
		$dft = $(this).attr("title");
		if( $(this).val() == '' )  {
		  $(this).removeClass("default_off");
		  $(this).addClass("default_on");
		  $(this).val($dft);		  
		 }
	  });
	  

	 // FAQ 
	 $('.faq_question').bind("click", function() {	  
		$(this).parent().find('.faq_answer').animate( { height:"toggle" }, 300);
	  });
}); 

function hide_menu(thisa) {
//		$h = $(".thisa").find(".items").height() + 10;
	if( i == 1) {
		$(thisa).find(".menu_items").animate({ height:'0px' }, 10 , function() {
				$(thisa).children(".nav_link_name").removeClass("hover_link");
			});		
			$(thisa).find(".menu_items").css("visibility", "hidden");		
			$(thisa).find(".items").css({ marginTop:"-20px" });							

	}
}
