Cufon.replace('#content h2',{
	fontFamily: 'BadaBoom BB',
	textShadow: '1px 1px 1px #333, 2px 3px 3px #f42413'
	});

Cufon.replace('#content h3',{fontFamily: 'BadaBoom BB'});

Cufon.replace('.button',{
	hover: true,
	hoverables: { 
		color: '#f00'
	},
	fontFamily: 'BadaBoom BB',
	textShadow: '1px 1px 1px #333'
});


Cufon.replace('#nav a',{ 
	hover:{ 
		color: '#f42413'
	}
});

Cufon.replace('#sidebar .secondary-nav h3',{
	fontFamily: 'BadaBoom BB',
	textShadow: '1px 1px 1px #333, 2px 3px 3px #f42413'
});

Cufon.replace('#sidebar .secondary-nav a',{
	hover: {
		color: '#fff'
	}
});

Cufon.replace('.ui-widget-header a',{fontFamily: 'Immortal'});



Cufon.replace('#credits',{fontFamily: 'Immortal'});
Cufon.replace('#contact',{fontFamily: 'Immortal'});



$(document).ready(function(){
	
    //$('a[href^=mailto:]').unobfuscate({atstring: '[at]', dotstring: '[dot]'});

	HELL.variables.hasRequiredFlash = swfobject.hasFlashPlayerVersion("9.0.0");
	HELL.variables.isIE6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) && (navigator.userAgent.toLowerCase().indexOf('msie 7') == -1) && (navigator.userAgent.toLowerCase().indexOf('msie 8') == -1);
	
	if (navigator.appVersion.indexOf("Win")!=-1) HELL.variables.osType = "Windows";
	if (navigator.appVersion.indexOf("Mac")!=-1) HELL.variables.osType = "MacOS";
	if (navigator.appVersion.indexOf("X11")!=-1)  HELL.variables.osType = "UNIX";
	if (navigator.appVersion.indexOf("Linux")!=-1)  HELL.variables.osType = "Linux";
	


	if(!HELL.variables.isIE6){
		
		if(HELL.variables.dudes){
			HELL.ui.dudes = new $.hell.dudes({flashFile: HELL.settings.baseUrl+'/'+HELL.variables.dudes}, '#the-dudes');
		}
		
		HELL.ui.header = new $.hell.header({}, '#header');
		
		if(HELL.variables.girlLeft){
			HELL.ui.devilGirl1 = new $.hell.demons({flashLeft: HELL.settings.baseUrl+'/'+HELL.variables.girlLeft}, '#side-feature-2');
			HELL.ui.devilGirl1._create('left');
		}
		if(HELL.variables.girlRight){
			HELL.ui.devilGirl2 = new $.hell.demons({flashRight: HELL.settings.baseUrl+'/'+HELL.variables.girlRight}, '#side-feature-1');
			HELL.ui.devilGirl2._create('right');
		}

		$('#contact').append('<a id="flashToggle"></a>');	
		HELL.ui.flashToggle = new $.hell.flashToggle({}, '#flashToggle');
		
		if(HELL.variables.osType == 'Linux' || HELL.variables.osType == 'UNIX'){			
			//flash disabled by default in linux / UNIX as it is sometimes buggy
			HELL.ui.flashToggle.setEnabled(0);	
		}
	}
	

	setHorizontalScroll();

	
	$(window).resize(function() {
	 	setHorizontalScroll();
	});
	
	
	$("#featured").tabs({fx:{opacity: "toggle", duration: 600}}).tabs("rotate", 15000, true);
	
	$('.multi-menu').click(function(){
		
		link = $(this);
		
		dialog = $('<div></div>').dialog({
			title: 'Please select your region', 
			modal: 1, 
			width: 380, 
			height: 180
		}).html('<div class="loader" style="width: 330px; height: 80px;"></div>');
		
		
		Cufon.replace('.ui-dialog-title',{ 
			textShadow: "1px 2px 2px #333, 2px 3px 2px #f42413", hover:true
		});
		
		$.ajax({ 
			url: link.attr('href'),
			cache: false,
			dataType: 'html', 
			success: function(data){
		        dialog.html(data);			
				Cufon.refresh('.button');
				
				dialog.find('form').submit(function(){
					dialog.dialog('close');
				});

		    }
		});

		return false;
	});
		
	$('a.dialog-image').fancybox({
		
				'speedIn'		:	200, 
				'speedOut'		:	200,
				'padding'		: 	3, 
				'overlayShow'	:	true,
				'overlayColor'	:   '#000',
				'overlayOpacity':   0.7,
				'titleShow'		: false,
				'cyclic' : 1

			});
	
	$('a.html-lightbox').each(function(){
		
		width = parseInt($(this).attr('data-lightboxwidth'));
		height = parseInt($(this).attr('data-lightboxheight'));
		
		$(this).fancybox({
		
				'speedIn'		:	200, 
				'speedOut'		:	200,
				'padding'		: 	3, 
				'overlayShow'	:	true,
				'overlayColor'	:   '#000',
				'overlayOpacity':   0.7,
				'titleShow'		: false,
				'type'			: 'iframe',
				'width'			: width,
				'height'		: height

			});
	});

	
	$("a.youtube-link").click(function() {
       
			$.fancybox({
                 'padding'             : 0,
                 'autoScale'   : false,
                 'transitionIn'        : 'none',
                 'transitionOut'       : 'none',
                 'title'               : this.title,
                 'width'               : 680,
                 'height'              : 495,
                 'href'                : this.href.replace("watch?v=", 'v/'),
                 'type'                : 'swf',    // <--add a comma here
                 'swf'                 : {'allowfullscreen':'true'} // <-- flashvars here
                 });
                return false;

           });
	
	

	//$("input.date").datepicker({minDate: -20, maxDate: '+1M +10D'});
	
	/**
	 * fix for hell hole map so that text doesn't go behind other skulls
	 */
	$('#regions-map li').mouseover(function(){
		$(this).css('z-index', '100');
	}).mouseout(function(){
		$(this).css('z-index', '1');
	});
	
	Cufon.refresh('#contact');
	
	$(".accordion").accordion({
		event: "click",
		collapsible:true,
		active: 0,
		autoHeight: 0,
		active: false,
		changestart: function(event, ui) {
			$(this).addClass('active');			
			//.accordion('activate',-1) is buggy in all versions of IE disabling functionality in IE for now
			if(ui.options.active != -1 && !$.browser.msie){
				$(".accordion").not('.active').accordion('activate',-1);
			}
			$(".accordion").removeClass('active');

		}
	});
	
	$('#change-region select').change(function(){
		id = $(this).val();
		location.href=HELL.settings.baseUrl+"/"+HELL.variables.country+"/stores/set-region/region/"+id+"/";
	});
			
});

function init_map_ajax(){
	$('#stores').css({'height' : 0, 'overflow' : 'hidden'});
	
	selector = $('#store-selector');
	
	selector.change(function(){
		var id = $(this).val();
		
		if(id != ''){
			loadStore(id);
		}else{
			$('#store-ajax-content').html('');
		}		
	});
	
	if(selector.val() != ''){
		loadStore(selector.val());
	}
	
	
}

function loadStore(id){

		if(id==null){
			return;
		}

		if ( typeof(inFocus) != "undefined" ) {
			markers[inFocus].setImage(HELL.settings.baseUrl+'/shared/images/skull-pin.png');
			markers[inFocus].closeInfoWindow();	
		}
		
		$('#store_detail').css("background-image","url("+HELL.settings.baseUrl+"/shared/images/loader.gif)");
		$('#store-ajax-content').html('');
		
		
		
	//	this._setLoading();
		$.ajax({
				type: "GET",

				url: HELL.settings.baseUrl+'/'+HELL.variables.country+'/stores/store-details/store/'+id+'/',
			  	dataType: "json",
			  	success: function(data){
					
					
					$('#store_detail').css("background-image","none");
					$('#store-ajax-content').html(data.content);
					HELL.ui.map.setCenter(latLngs[id], 14);
					
					
					storeName= data.storeName;
					storeAddress= data.storeAddress;
				
					markers[id].openInfoWindowHtml("<div style='color: #000;'><h4>"+storeName+"</h4>"
	                    +storeAddress+"</div>");
					
					markers[id].setImage(HELL.settings.baseUrl+'/shared/images/skull-pin-focus.png');
					
					
					inFocus = id;
					
				
					
					if(data.message){
						$("div.message-content").html(data.message);
						$("div.message").addClass('attention').show();
					}else{
						$("div.message-content").html('');
						$("div.message").removeClass('attention').hide();
					}
					
						Cufon.refresh('#content h2');
						Cufon.refresh('#content h3');
						Cufon.refresh('.button');
					
					
				},
			  	error: function(msg){
				 	alert('<p>Could not fetch information from server</p>');
			  	}
		});
}


function setHorizontalScroll(){
	if($(window).width() > 800){
		$('body').css('overflow-x', 'hidden');
	}else{
		$('body').css('overflow-x', 'visible');
	}
	
	
	if($(window).width() > 1024){
		$('#side-feature-1').show();
		$('#side-feature-2').show();
	}else{
		$('#side-feature-1').hide();
		$('#side-feature-2').hide();
	}
	

}

function flashSetDevilState(state){
	
	HELL.ui.dudes.setState(state);

	//if active pause all other and javascript flash animations to save cpu
	if(state=='active'){		
		$("#featured").tabs("rotate",0,true);  		
	}else{
		$("#featured").tabs("rotate",10000,true);  
	}

}

function flashSetDevilHeight(height, adjustment){
	HELL.ui.dudes.setHeight(height, adjustment);
}

function flashAlert(state){
	alert(state);
}

function flashDudesWidth(){
	return 800;
}
