/** javascript used in home tab **/
function save(url,form,msg_div,loader) {
	
	$("#"+msg_div).hide();
	$('#'+loader).show();
	
	$.ajax({
		type: "POST",
		url: url,
		data: $('#'+form).serialize(),
		success: function(output){						
			$('#'+loader).hide();
			$("#"+msg_div).show();
			$("#"+msg_div).html(output);
		}
	});
}

function getData(page,loader_div,response_div) {

	var url = page;
	$("#"+response_div).hide();
	$('#'+loader_div).show();
	
	$.ajax({
		url: url,
		type: "POST",
		data: ({flag : 1}),
		success: function(output){
			$('#'+loader_div).hide();
			$("#"+response_div).html(output);
			$("#"+response_div).show();
			return false;
		}
	})
}

function formatText(index, panel) {
	return index + "";
}
		
jQuery(document).ready(function($) { 

	// used to display pop-up on homepage using jquery thickbox
	// select the overlay element - and "make it an overlay"
	$("#announcement").overlay({

		// custom top position
		top: 10,
		// some expose tweaks suitable for facebox-looking dialogs
		expose: {

			// you might also consider a "transparent" color for the mask
			color: '#000',

			// load mask a little faster
			loadSpeed: 200,

			// highly transparent
			opacity: 0.5
		},

		// disable this for modal dialog-type of overlays
		closeOnClick: true,

		// we want to use the programming API
		api: true

	// load it immediately after the construction
	}).load();
	//end
	
	$("div.tabs").tabs(".images > div", {
		// enable "cross-fading" effect
		effect: 'fade',
		fadeOutSpeed: "slow",

		// start from the beginning after the last tab
		rotate: true

	// use the slideshow plugin. It accepts its own configuration
	}).slideshow({autoplay: true});
	
	$("#typewriter").scrambledWriter();
	$("#typewriter2").typewriter();
	
	$("ul.topnav li span").hover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('normal'); //When the mouse hovers out of the subnav, move it back up
		});

	//Following events are applied to the trigger (Hover events for the trigger)
	}).hover(function() { 
		$(this).addClass("subhover"); //On hover over, add class "subhover"
	});
	
	$(".follow_img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 100% when the page loads
		$(".follow_img").hover(function(){
		$(this).fadeTo("slow", 0.3); // This should set the opacity to 30% on hover
		},function(){
		$(this).fadeTo("slow", 1.0); // This should set the opacity back to 100% on mouseout
	});
	
	$('#left_content marquee').marquee('pointer').mouseover(function () {
		$(this).trigger('stop');
	}).mouseout(function () {
		$(this).trigger('start');
	})
	
	$('.boxgrid.thecombo').hover(function(){
		$(".cover", this).stop().animate({top:'200px', left:'200px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
	});
	
	$('.boxgrid.thecombo2').hover(function(){
		$(".cover", this).stop().animate({top:'200px', left:'-200px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
	});

	$('.boxgrid.slidedown').hover(function(){
		$(".cover", this).stop().animate({top:'200px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});
	
	$(document).pngFix(); 
	$("#right_container").pngFix(); 
	$("#slider-buttons").pngFix(); 
	
	$("a[rel]").overlay({

		// custom top position
		top: 10,
		// some expose tweaks suitable for facebox-looking dialogs
		expose: {
			// you might also consider a "transparent" color for the mask
			color: '#000',

			// load mask a little faster
			loadSpeed: 200,

			// highly transparent
			opacity: 0.5
		},
		// disable this for modal dialog-type of overlays
		closeOnClick: true,
		// we want to use the programming API
		api: true,
		onBeforeLoad: function() {
			$(".popup_content").html("<div style='text-align: center; margin: 50px;'><img src='public/images/common/loader4.gif' alt='loader' /></div>");
			// grab wrapper element inside content
			var wrap = this.getContent().find(".popup_content");
			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));
		}
	});
	
});
/** end **/
