//agenda
function showAgenda(sel)
{ 
	$(sel).dateinput();
}

//KillBox
function killBox(killListener,killContainer)
{
	$(killListener).click(function() {
		var i = $(killListener).index(this);	
		$(killListener).parents(killContainer + ":eq("+i+")").fadeOut('slow');
	});
}

//menuChild
function menuConfig(listener,container,menusToHideTab,ssMenusToShowTab)
{	$.each(menusToHideTab, function(index,value){
		if($.inArray(value,menusToHideTab)!=-1)
		{
			$(listener+":eq("+value+")").hide(0);
		}
	});
	
	$(listener).hover(function(){
		var i = $(listener).index(this);
		if ($(container+":eq("+i+")").is(":hidden") && $.inArray(i,ssMenusToShowTab)!=-1) 
		{
			$(container).hide('slow');
			$(container+':eq('+i+')').show('slow');
		}
	});
}
//showContent
function showThisContent(container)
{
	$(document).ready(function() {
		$(container).show('slow');
	});
}

//gallery
function showGallery(container,box)
{
	$(container).find("img").each(function(index) {
		$(this).overlay({
			effect: 'apple',
			target: box,
			mask: { maskId: 'mask' },
			onLoad: function() {
				$("#images").data("scrollable").seekTo(index, 0);
			}
		});
	});
	$("#images").scrollable();
	$("#images img").tooltip({
		position: "top center",
		offset: [-75, -30],
		opacity: 0.8,
		effect: 'fade',
		relative: true
	});
	$(container+" img").reflect({height: 0.5, opacity: 0.6});
}

function showOverlay()
{
	$("a[rel]").overlay({
		mask: 'black',
		effect: 'apple',
		onBeforeLoad: function() 
		{
			var wrap = this.getOverlay().find(".contentWrap");
			wrap.load(this.getTrigger().attr("href"));
		}
	});
}
function scrollEffect(sc_scrollbar, sc_status, sc_axis, sc_size, sc_sizethumb, sc_wheel)
{
	if($(sc_scrollbar).length)
	{
		$(sc_scrollbar).tinyscrollbar({
			scroll: sc_status,					   
			axis: sc_axis, 
			size: sc_size,
			sizethumb: sc_sizethumb,
			wheel: sc_wheel
		});
	}
}
function fancy(listener){
	$(listener).fancybox({
		'overlayShow'	: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
}

function pageBorder(listenerOpen, listenerClose, container){
	$(container).hide('slow');
	$(listenerOpen).click(function()
	{
		$(container).show('slow');
		$(listenerClose).click(function()
		{
			$(container).hide('slow');
		});
	});
}

function rightBorder(listenerOpen, listenerClose, container)
{
	$(container).hide(0);
	//if(delayValue!=0)
	//{
	//	$(container + ":eq(0)").delay(delayValue).show(2000);
	//}
	var pagesTab = Array(0,3,5,5,5,5,5,5,5);
	var delayValue = 2 * 1000;
	$.each(pagesTab,function(index,value)
	{
		if(document.location.href.indexOf('/page/'+index) != -1){delayValue = value * 1000;}
	});
	$(container + ":eq(0)").delay(delayValue).show('slow');
	$(listenerOpen).click(function()
	{
		var i       = $(listenerOpen).index(this);
		$(container+":eq("+i+")").toggle('slow');
		$.each(container,function(index,value)
		{
			if(index!=i)
			{
				$(container+":eq("+index+")").hide('slow');
			}
		});
	});
	$(listenerClose).click(function()
	{
		$(container).hide('slow');
	});
}

function rightBorder2(listenerOpen, listenerClose, container)
{
	if(document.location.href.indexOf('/page') != -1)
	{
		$(container).hide(0);
	}
	else
	{
		$(container).hide(0);
		$(container + ":eq(0)").delay(2000).show(1000);
	}
	$(listenerOpen).click(function()
	{
		var i       = $(listenerOpen).index(this);
		$(container+":eq("+i+")").toggle(1000);
		$.each(container,function(index,value)
		{
			if(index!=i)
			{
				$(container+":eq("+index+")").hide(1000);
			}
		});
	});
	$(listenerClose).click(function()
	{
		$(container).hide(1000);
	});	
}

function fadeToOpacity(selector, value)
{
	$(selector).fadeTo('slow', value);
}

//Google Map Fcts
function load()
{
	if (GBrowserIsCompatible())
	{

		var casa    = Array(Array(33.593531,-7.625456),Array());
		append(casa[1], Array("JMSH", "<h1 style='color:#000;font-size:14px;'>JM Suites Hotel</h1><span style='color:#000;font-size:10px;'>Adresse: 161 Angle Boulevard Rachidi Boulevard et Avenue Moulay Hassan 1er Quartier Moulay Youssef . Casablanca. 20 070 . Maroc<br/>Tel : +212 (0) 522 26 06 66<br/>Fax : + 212 (0) 522 20 97 11<br/>E-Mail : info@jmsuiteshotel.com<br/>GPS : N 33° 35' W 7° 37' </span>"));							

		var map = new GMap2(document.getElementById("map"),{size:new GSize(790,400)});
		var defaultPoint = new GLatLng(33.593531,-7.625456);
		var defaultZoom  = 16;
		
		map.addControl(new GLargeMapControl3D());
		map.setCenter(defaultPoint, defaultZoom);
		map.addControl(new GOverviewMapControl());

		loadCity(map, casa, true);
		
	}
}

function loadCity(map, city, opened)
{
	
	var point    = new GLatLng(city[0][0], city[0][1]);
	var marker   = new GMarker(point);
	var infoTabs = [];
	
	city[1].forEach(function(value){
		append(infoTabs, new GInfoWindowTab(value[0], value[1]));
	});

	GEvent.addListener(marker, "click", function() {marker.openInfoWindowTabsHtml(infoTabs); });
	map.addOverlay(marker);
	if(opened == true)
	{
		marker.openInfoWindowTabsHtml(infoTabs);
	}
}

function append(parent, child) {
	parent[parent.length] = child;
}
