﻿/*
#################################################
# --------------- ISR Step One -----------------#
#################################################
#												#
# Javascript Methods based on Prototype			#
# Framework for the								#
# INTERSPORT RENT International 				#
# booking application							#
#											  	#
#################################################
#												#
# Last modified by Bernhard Rusch				#
# Date: 22 - 08 - 2006							#
# Version: 0.1									#
#												#
# (c) 2006 elements.at New Media Solutions GmbH #
#												#
#################################################

*/

var isrStepOne = Class.create();
isrStepOne.prototype = {

	
	initialize: function()
	{
		//alert("initialize");
	},
	
	maintabbing: function (showTab,showLink)
	{
		//alert(test);
		var tabs = new Array();
		tabs[0] = "search";
		tabs[1] = "azRegions";
		tabs[2] = "map";
		
		// Set the Contents in the Tabs display:none
		for(i=0;i<tabs.length;i++)
		{
			Element.setStyle(tabs[i],{display:'none'});
		}
		
		// Set the Tabs display:none
		links = helper.getByNameOverId("iic_tb_navigation","a");
		
		for(i=0;i<links.length;i++)
		{
			links[i].className = "";
		}
		
		showLink.className = "active";
		Element.setStyle(showTab,{display:'block'});
		
		// set the actual position in the tabs
		stepOnePosition = showTab;
		
		// Set all Result Boxes to display:none
		Element.setStyle('locations',{display:'none'});
		Element.setStyle('regionSearchInfo',{display:'none'});

		if(showTab == "map") {
			initNewGoogleMap();
		}

	},
	
	showRegionSearchInfo : function ()
	{
		// Show the Region Search box -> Muliple Match
		//helper.adjustContainerHeight('regionSearchInfo',300);
		// If the Locations Layer is visible, set it invisible
				
		if(div_locations)
		{
			Effect.BlindUp('locations',{afterFinish:function(){Effect.BlindDown('regionSearchInfo')}});
			div_locations = false;
		}
		else
		{
			Effect.BlindDown('regionSearchInfo');
		}
		div_regionSearchInfo = true;
	},
	
	showLocations : function ()
	{
		// Shows the Locations Search Box
		// helper.adjustContainerHeight('locations',300);
		// Is the regionSearchInfo Layer visible, set it invisible
		
		helper.adjustContainerHeight('iic_search_result',200);

		if(div_regionSearchInfo)
		{
			Element.setStyle('locations',{display:'none'});
			Effect.BlindUp('regionSearchInfo',{afterFinish:function(){Effect.BlindDown('locations')}});
			div_regionSearchInfo = false;
		}
		else
		{
			Effect.BlindDown('locations');
		}
		
		div_locations = true;
	},
	
	showAzList : function ()
	{
		// Shows the A-Z list in the Tab "Select by Region"
		Effect.BlindUp('locations',{afterFinish:function(){Effect.BlindDown('azResult')}});
		Element.setStyle('azButton',{display:'none'});
	},
	
	showAzResult : function ()
	{
		// Shows the Dealer Result from the A-Z List
		Effect.BlindUp('azResult',{afterFinish:function(){Effect.BlindDown('locations')}});
		Element.setStyle('azButton',{display:'block'});
	},
	
	showDateSelection : function ()
	{
		// Shows the date selection and set most of the search results invisible
		
		// Hide and show the elements in the search box
		
		helper.adjustContainerHeight('iic_select_store','auto');
				
		if(stepOnePosition != "map")
		{
			helper.adjustContainerHeight('iic_search_result','auto');
			
			locationLinks = helper.getByNameOverId("locations","div");
			
			for(ix=0;ix<locationLinks.length;ix++)
			{
				selected = "entry_" + selectedLocation;
				if(locationLinks[ix].className == selected || locationLinks[ix].className.indexOf("entry_") < 0)
				{}
				else
				{
					locationLinks[ix].style.display = 'none';
				}
			}
	
			
	
			locationLinks = document.getElementById('iic_dt_header');
			locationLinks.innerHTML = '';
			Element.setStyle('iic_dt_header',{height:'1px'});
			Element.setStyle('iic_dt_header',{overflow:'hidden'});
			
			Element.setStyle('backToSearch',{display:'block'});
		}
		
		if(openingTimeStatus != false)
		{
			//alert(openingTimeStatus);
			//Element.setStyle('openingTime_'+openingTimeStatus,{display:'none'});
			Effect.BlindUp('openingTime_'+openingTimeStatus);
		}
		
		Element.setStyle('dateSelection',{display:'block'});
		Element.setStyle('dateSelection',{marginTop:'20px'});
		Element.setStyle('iic_select_store',{display:'none'});
		Effect.BlindDown('dateRangeSelection');
		Element.setStyle('dateSelection',{marginTop:'20px'});
		
	}, 
	
	backToSearch : function ()
	{
		// Hide the Search box and set the Search Box visible
		locationLinks = helper.getByNameOverId("locations","div");
		
		for(ix=0;ix<locationLinks.length;ix++)
		{
			if(locationLinks[ix].className.indexOf("entry_") > -1)
			{
				locationLinks[ix].style.display = 'block';
			}
		}
		
		locationLinks = document.getElementById('iic_dt_header');
		locationLinks.innerHTML = 'Locations';
		
		Element.setStyle('backToSearch',{display:'none'});
		
		Effect.BlindUp('dateRangeSelection');
		Effect.BlindDown('iic_select_store');
		
		// Empty the actual Location Info Container
		if(actualLocationInfo.length > 1)
		{
			isrStepOne.deleteLocationInfo(actualLocationInfo);
		}
	},
	
	showLocationInfo : function (id)
	{
		// Shows the Location Infos  -> click on more Infos
		if(actualLocationInfo.length > 1)
		{
			isrStepOne.hideLocationInfo(actualLocationInfo);
			Effect.BlindDown(id);
			actualLocationInfo = id;
		}
		else
		{
			Effect.BlindDown(id);
			actualLocationInfo = id;
		}
	},
	
	hideLocationInfo : function (id)
	{
		// Set the Location Infoboy invisible
		Effect.BlindUp(id,{afterFinish:function(){isrStepOne.deleteLocationInfo(id)}});
	},
	
	deleteLocationInfo : function (id)
	{
		// Empty the Location Info Container
		// This is necessary because of a bug in MSIE 6.0 with Stylesheets
		document.getElementById(id).innerHTML = '';
	},
	
	showShopPricing : function (id)
	{
		// Show the pricing table from a Shop in the Lightbox
		id = "priceModel";
		//alert(id);
		lightboxcontent = document.getElementById('priceModel').innerHTML;
		common.showLightbox(lightboxcontent,780,450);
	}, 
	
	hideShopPricing : function ()
	{
		// Hide the Lightbox opend by Method: showShopPricing
		common.hideLightbox();
	},
	
	showErrorBox : function ()
	{
		error = document.getElementById('errorBox').innerHTML;
		common.showLightbox(error,250,140);
		helper.dontHideLightbox();
	},
	
	showOpeningTime : function (id)
	{
		Effect.BlindDown('openingTime_' + id);
		openingTimeStatus = id;
	}
}

var isrStepOne = new isrStepOne;

