
//To deal with home page masthead banner
//var max_rotation_count = <?=$event_count?>;
function promotionalDivAnimate(id)
{
	if(max_rotation_count <= 2)
		return;
	var div_id = "#dynamic-banner" + id;
	$(".dynamic-banner").hide();
	$("#dynamic-banner" + id).fadeIn("slow");
	$(".promotionalButton").removeClass("selected");
	$(".promotionalButton"+id).addClass("selected");
}
/*
function updateCalendarView(month_id,key)
{
	var url = site_path + "/eventcalendar";
	$(".left-column-month").removeClass("selected");
	$("#" + month_id).addClass("selected");
	
	window.location=url + "/2009/" + key;
}
*/
function updateCalendarView(month_id,key)
{
	var url = site_path + "/eventcalendar";
	var d = new Date();
	var year = d.getFullYear();
	$(".left-column-month").removeClass("selected");
	$("#" + month_id).addClass("selected");
	
	window.location=url + "/"+ year +"/" + key;
}

function promotionalDivRotate(id)
{

	//alert(max_rotation_count);
	//alert(id);
	var div_id = ".dynamic-banner" + id;
	//alert(div_id);
	$(".dynamic-banner").hide();
	$(div_id).fadeIn("medium");
	//console.log(id);
	id = id+1;
	var func_call = "promotionalDivRotate(";
	if(id>=max_rotation_count) //-1 is to solve empty zol
		func_call = func_call+1+")";
	else
		func_call = func_call+id+")";
	$(".promotionalButton").removeClass("selected");
	$(".promotionalButton"+id).addClass("selected");
	setTimeout(func_call,5000);	
}

$(document).ready(function(){
 if(max_rotation_count <= 2)
	return;
 else
 	setTimeout("promotionalDivRotate(2)",5000);
});



/** Javascript to deal with Menu/ navigation */

var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();
	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
	document.getElementById("maincolumn").style.zIndex = -1000;
}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	document.getElementById("maincolumn").style.zIndex = 0;
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 









$(function() {
	$("#button").click(function() {
		//$(".cssSelect").toggle();
		//document.getElementById("online-booking").style.zIndex = -1000;
		if(is_ie==1)
			//document.getElementById("online-booking").style.zIndex = "-1000";
			$("#online-booking").toggle();
		var selectedEffect = "fold";
		var options = {};
		if(selectedEffect == 'scale'){  options = {percent: 0}; }
		else if(selectedEffect == 'size'){ options = { to: {width: 200,height: 60} }; }
		$("#effect").toggle(selectedEffect,options,1000);
		return false;
	});

});

$(function() {
	function runEffect(){
		var selectedEffect = $('#effectTypes').val();
		var options = {};
		if(selectedEffect == 'scale'){  options = {percent: 100}; }
		else if(selectedEffect == 'transfer'){ options = { to: "#button", className: 'ui-effects-transfer' }; }
		else if(selectedEffect == 'size'){ options = { to: {width: 280,height: 185} }; }
		$("#effect").show(selectedEffect,options,500,callback);
	};

	function callback(){
		setTimeout(function(){
			$("#effect:visible").removeAttr('style').hide().fadeOut();
		}, 1000);
	};

	$("#button").click(function() {
		runEffect();
		$("#loader").show();
		$.ajax({
			type: "POST",
			url: site_path + "/eventcalendariframe",
			success: function(msg){
				$("#loader").hide();
				$("#results").html(msg); 
				$("#results").show();                                      
			},
			error: function(msg){
				$("#loader").hide();	
				$("#error_msg").html(msg);
				$("#error_msg").slideDown("slow");								  	
			}
		});
		return false;
	});

	$("#effect").hide();
});
$(document).ready(function(){
	$(".calendar").click(function(){
		var prev_month = $('span.date-prev a').attr('href');
		alert(prev_month);
		if( prev_month =='/eventcalendariframe/2011/11/all')	{
			$('span.date-next').html('<a id="nextMonthLinkCalendar" rel="nofollow" href="/eventcalendar/2012/01/all"><img src="http://www.ncpamumbai.com/themes/ncpa/images/next_button.jpg"></a>');
		}
	});
});
