
$(document).ready(function(){
	
	//calculates whicch image to show when loads a page. 
	//this will be done via php in the future.. but its for a demo purpose.
	//or not.. it actually does a good job.. 
	var start = Math.floor(Math.random() * 6);
	
	if(start <= 0) start =1 ;
	if(start>=5) start = 4;
	
	if(start==2){
		$("#image_1").attr("src", "images/intro2.jpg"); 
		$("#image_2").attr("src", "images/intro3.jpg");
		$("#image_3").attr("src", "images/intro4.jpg");
		$("#image_4").attr("src", "images/intro1.jpg");
	}
	else if(start==3){
		$("#image_1").attr("src", "images/intro3.jpg"); 
		$("#image_2").attr("src", "images/intro4.jpg");
		$("#image_3").attr("src", "images/intro1.jpg");
		$("#image_4").attr("src", "images/intro2.jpg");
	}
	else if(start==4){
		$("#image_1").attr("src", "images/intro4.jpg"); 
		$("#image_2").attr("src", "images/intro1.jpg");
		$("#image_3").attr("src", "images/intro2.jpg");
		$("#image_4").attr("src", "images/intro3.jpg");
	}
	else{
		$("#image_1").attr("src", "images/intro1.jpg"); 
		$("#image_2").attr("src", "images/intro2.jpg");
		$("#image_3").attr("src", "images/intro3.jpg");
		$("#image_4").attr("src", "images/intro4.jpg");
	}
	
	//** image source change ends here *///
	
	//define next_counter and next_id which will be changed when clicking four times on next button... 
	var next_counter = 0;
	var next_id = "#next"; 

	function onAfter(curr, next, opts) {
	    var index = opts.currSlide;
	    //$('#prev')[index == 0 ? 'hide' : 'show']();
	    //$('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
	}

	
	$('.sliding_text_wrapper .sliding_text').cycle({
	    fx:     'scrollLeft',
	    //prev:   '#prev',
	    next:   '#next',
	    after:   onAfter,
	    timeout: 0
	});
	
	
	$('.sliding_text_wrapper_2 .sliding_text').cycle({
	    fx:     'scrollUp',
	    //prev:   '#prev',
	    next:   next_id,
	    after:   onAfter,
	    timeout: 0
	});
	
	$('.sliding_text_wrapper_3 .sliding_text').cycle({
	    fx:     'blindZ',
	    //prev:   '#prev',
	    next:   '#next',
	    after:   onAfter,
	    timeout: 0
	});
 
	$('.home_content_image').cycle({
	    fx:     'fade',
	    //prev:   '#prev',
	    next:   next_id,
	    after:   onAfter,
	    timeout: 0,
	    //fix for IE so the PNG background will work.. Not for IE 6 though.
	    cleartypeNoBg: true
	});
	
	
	/* image next button hover */
	$("img#next").hover(function(){
		$(this).attr("src","images/next_hover.png");
	},
	function(){
		$(this).attr("src","images/next.png");
	});
	
	/* When someone clicks four times to next button.. it will go to home page*/
 
	$("img#next").click(function(){
		if(next_counter==3){
			next_id='#no_next'; 
			window.location = "home.html";
		}
		else{
			next_counter = next_counter + 1;
		}
	});  
	
	/** For LavaLamp Effect **/
	 $(".nav1").lavaLamp({ 
		 fx: "backout", 
		 speed: 700 });

	
}); 
