var intervalObj;
var inc=0;
var animator;
var currentObj;
var totalPages;
var currBoxObj;
var boxTimer;
var animatetext;
var imgAnimateTimer=1400;
var rotateInterval=13000;
jQuery.noConflict();

jQuery(document).ready(function (){
	
	jQuery(".bodymore").each(function(index){
	  	if(index == 0){
		  jQuery(this).toggleClass("show");
		  return;
		}
	});
		
	
	
	/*  change the anchor image on mouseout */
	
	jQuery(".bodymore a").mouseout(function(){	    
		jQuery(this).addClass("visited");									 
	}).click(function(){
		jQuery(this).addClass("visited");
	  }).mouseover(function(){
		  jQuery(this).removeClass("visited");
		  jQuery(this).addClass("hover");
	  });
	
	
	
	jQuery('.pager').mouseover(function(){
	
	
	 if(jQuery(this).find(".smoverimg").css("visibility") != "visible"){
      
	jQuery('.smoverimg').css("visibility","hidden");
	jQuery(this).find(".smoverimg").css("visibility","visible");	
	jQuery(this).find(".smoverimg").children(".blackbox").css("opacity","0");
	jQuery(this).find(".smoverimg").children(".blackbox").animate({opacity:.2},300);
	
	 }
	
  }).mouseout(function(){

	  });
	
	
	jQuery(".webchip_gn").mouseover(function(event){
										
										
			if(jQuery(this).children(".webchip_gn_mid").css("width")=="165px"){	
			  currBoxObj=jQuery(this);
	    jQuery(this).children(".webchip_gn_mid").animate({"width":"185px","height":"97px"},250);
		  jQuery(this).children(".webchip_gn_top").animate({"width":"185px"},250);	 
	    jQuery(this).children(".webchip_gn_bot").animate({"width":"185px"},250);
		
		jQuery(this).find("#simplemic").hide();
		jQuery(this).find("#animic").show();
		   
			jQuery(this).find(".smbox").animate({opacity:0},100,"linear",function(){
												jQuery(this).hide();
												
			 });
	
						
						}
	});
	jQuery(".webchip_gn_top").mouseover(function(){
		     clearTimeout(boxTimer);
	});
	jQuery(".webchip_gn_mid").mouseover(function(){
		     clearTimeout(boxTimer);
	});
	jQuery(".webchip_gn_bot").mouseover(function(){
		     clearTimeout(boxTimer);
	});	
	jQuery(".webchip_gn").mouseout(function(event){
						
			if(jQuery(this).children(".webchip_gn_mid").css("width") =="185px" ){
				currBoxObj=jQuery(this);
	            boxTimer=setTimeout(animatechip,0);
			}
	});
	
	

});

function animatechip(){
	
    jQuery(currBoxObj).children(".webchip_gn_mid").animate({"width":"165px","height":"20px"},200,'linear',function(){
		          jQuery(currBoxObj).find("#animic").hide();
		          jQuery(currBoxObj).find("#simplemic").show();
				  jQuery(currBoxObj).find(".smbox").show();
		jQuery(currBoxObj).find(".smbox").animate({opacity:1},130);
		
		});
	    jQuery(currBoxObj).children(".webchip_gn_top").animate({"width":"165px"},200);	 
	    jQuery(currBoxObj).children(".webchip_gn_bot").animate({"width":"165px"},200);
	
}



function animatechipout(){
  jQuery(".smbox").show();
	jQuery(".smbox").css('opacity','0');
		    jQuery(".smbox").animate({opacity:1 },1000);
}

function changeDisplayContainer(){

    rotateInterval=13000;
     
   if(jQuery("#videoholder").width() !=990){
   
    jQuery(".flasharea").hide();
    jQuery(".flasharea").each(function(index){
			
			if(index==inc){
				jQuery(this).css("visibility", "visible");
				 jQuery(this).addClass("show");
			 jQuery(this).removeClass("hide");
			  jQuery(".story").css("visibility","hidden");
			jQuery(this).children(".inital").removeClass("hide");
			jQuery(this).children(".inital").addClass("show");
			jQuery(this).children(".final").removeClass("show");
			jQuery(this).children(".final").addClass("hide");
			
			jQuery(this).find(".bodyWrap").css("opacity","0");
			
			jQuery(this).children(".inital").css("opacity","0");
				
			  currentObj= jQuery(this);
			  animator=setTimeout(animateContainer, 50);
				
				
			}else{
			   jQuery(this).addClass("hide");
				 jQuery(this).removeClass("show");
			}
							 
   });
	
	jQuery('.pager').each(function(index){
	   
           if(index == inc){
               
			   jQuery('.smoverimg').css("visibility","hidden");
		       jQuery(this).find(".smoverimg").css("visibility","visible");
			  
		   }
	   
	 });

    inc++;
	
	if(inc==jQuery(".flasharea").length){
	   inc=0;
	}
	
    }
  
}


function setContainer(containerNum,obj,event){
	
	
	if (intervalObj) {
	
		clearInterval(intervalObj);
		intervalObj = null;
		rotateInterval=13000;
		if(jQuery("#videoholder").width() !=990){

			 if(jQuery(obj).find(".smoverimg").css("visibility") != "visible"){
				  jQuery(".story").css("visibility","hidden");
				imgAnimateTimer=1000;	 
				clearTimeout(animator);

				clearTimeout(animatetext); 
				jQuery(".flasharea").hide();
				jQuery(".flasharea").each(function(index) {

					if(index==parseInt(containerNum)){

						 jQuery(this).addClass("show");
						 jQuery(this).removeClass("hide");
                                                
                                              
                                                
						jQuery(this).children(".inital").removeClass("hide");
						jQuery(this).children(".inital").addClass("show");
						jQuery(this).children(".final").removeClass("show");
						jQuery(this).children(".final").addClass("hide");

						jQuery(this).find(".bodyWrap").css("opacity","0");

						jQuery(this).children(".inital").css("opacity","0");

						currentObj= jQuery(this);
						animator=setTimeout(animateContainer, 200);
						inc=parseInt(containerNum)+1;


						if(inc==jQuery(".flasharea").length){
							inc=0;
						}
					}else{
					   jQuery(this).addClass("hide");
						 jQuery(this).removeClass("show");
					}

				});

			}

		}
	}
	
}

function initateDefault(){

	if (!intervalObj)
	intervalObj = setInterval(changeDisplayContainer, rotateInterval);	
}

function animateContainer(){
	
	jQuery(currentObj).find("a").removeClass("hover");
	jQuery(currentObj).find("a").removeClass("visited");
	jQuery(currentObj).find(".bodyWrap").animate({opacity:.5 }, imgAnimateTimer,'linear',function(){
	                 jQuery(this).animate({opacity:1},600);
	  });
	jQuery(currentObj).children(".inital").animate({opacity:.2 }, 1800);
	animatetext=setTimeout(animateinnertext,200);
}

function animateinnertext(){
	
	jQuery(currentObj).children(".inital").removeClass("show");
	jQuery(currentObj).children(".inital").addClass("hide");
	jQuery(currentObj).children(".final").removeClass("hide");
	jQuery(currentObj).children(".final").addClass("show");
	setTimeout(animatepagetext ,200);
	
}
function animatepagetext(){
	
	jQuery(".story").css("visibility","visible");
	jQuery(".story").css("opacity","0");
	jQuery(".story").animate({opacity:0.85 },500,'linear',function(){
	       
				jQuery(this).css("opacity","1");
	});
	
	imgAnimateTimer=1400;	 
}
var initate=0;
function loadanimation(){
	
	jQuery(".pager").each(function(index){
	   	if(index==initate){
			 jQuery(this).css('visibility','visible');
		
			jQuery(this).find(".smoverimg").children("div:first-child").css("opacity","0");
			jQuery(this).find(".smoverimg").children("div:last-child").css("opacity","0");
			jQuery(this).find(".smoverimg").children("div:first-child").animate({opacity:0.3 },200);
			jQuery(this).find(".smoverimg").children("div:last-child").animate({opacity:1 },200);
			
			
			
			 jQuery(this).animate({opacity:.5},300,"linear",function(){
			       		
						initate++;
						 jQuery(this).animate({opacity:1},950);
						if(initate < jQuery(".pager").length){
							
						  loadanimation();
						}
						if(initate == jQuery(".pager").length){  
							 setTimeout(animatewebchip ,700);
						}
						
					
			 });
			
			if (version.indexOf("MSIE 6.0") != -1)
				jQuery(this).animate({marginRight:"2px"},600);
			else 
				jQuery(this).animate({marginRight:"5px"},600);
			   	 
		 } // if ends
			
	});
}

function animatewebchip() {

	jQuery(".webchip").removeClass("hide");
	jQuery(".webchip").css("opacity","0");
	jQuery(".webchip").animate({opacity:1},500);
}