/* Author:Gaurav Saparia Description: */

var divOptions=[
								{divId:"home-buy-online-content",backgroundImage:"url('/images/framework/homepage/buy-online-bg_one.jpg')"},
							 	{divId:"home-buy-online-content_two",backgroundImage:"url('/images/framework/homepage/buy-online-bg_two.jpg')"}
							 ];
							 
var oBuyTicketOptimization= {
															cookieName:"buyTicketOption",
															defaultDiv:divOptions[0],
															parentDivId:"home-buy-online",
															
															hideDefaultDiv:function(){																
																$(this.defaultDiv.divId).setStyle({display:'none'}).hide();
															},
															displayDiv:function(){
																this.getCookie()?this.displaySavedDiv():this.getRandomDivSaveItAndDisplayIt();
															},
															setCookie:function(divIndex){
																var expDate = new Date();
																expDate.setFullYear(2050);
																setCookie(this.cookieName, divIndex,expDate);
																//alert("cookieHasbeen Set");
															},
															getCookie:function()
															{
																return getCookie(this.cookieName);
															},
															displaySavedDiv:function(){
																	//alert("cookie has been found do something with that");
																var divObjectToDisplay = divOptions[this.getCookie()];
																$(this.parentDivId).setStyle({backgroundImage:divObjectToDisplay.backgroundImage});
																$(divObjectToDisplay.divId).show();
															},
															getRandomDivSaveItAndDisplayIt:function(){
																var randomDivIndex = this.getRandomNo(divOptions.length);
																var divObjectToDisplay = divOptions[randomDivIndex];
																//alert(randomDivIndex);
																this.setCookie(randomDivIndex);
																$(this.parentDivId).setStyle({backgroundImage:divObjectToDisplay.backgroundImage});
																$(divObjectToDisplay.divId).show();
															},
															getRandomNo:function(iLimit)
															{
																var	rand_no = Math.random();
																var randRef = Math.ceil((rand_no * iLimit)-1);
																return randRef;	
															},
															/*static function to rigister button clicks to webtrends
																function accepts an object with following property
																param:str
																paramValue:str
																URL:str
																openInNewWindow : (optional)true
															*/
															registerClick:function(ob)
															{
																//alert(ob.URL + "------" + ob.param + ":" + ob.paramValue);
															//dcsMultiTrack('WT.ti', 'MyFun Homepage - BuyTickets button click', 'DCS.dcsuri', '[URL being redirected to]', 'DCSext.MyFunHomepagePanel', '[Div1:BuyTickets]');

															  dcsMultiTrack('WT.ti', 'MyFun Homepage - BuyTickets button click', 'DCS.dcsuri', ob.URL, ob.param , ob.paramValue);

																ob.openInNewWindow && ob.URL  ? setTimeout("open('" + ob.URL +"')",2000):setTimeout("location.href='" + ob.URL + "'", 2000);
															}
															
														}
														
 