if (themeStyle == 'dark'){
	Cufon.replace('.page-content h2,.grid-buynow,.grid-info strong,.panel-info strong,.panel-info .price,.slide-text .text-block h2,.slide-text .text-block .price,.nivo-html-caption h2,.column h2,.view-switcher .title', {textShadow: '#1e1e1e 1px 1px 0',fontFamily:'Junction'});
	Cufon.replace('.date .month,.date .day,.date .year',{textShadow: '#1e1e1e 1px 1px 0',fontFamily:'BebasNeue'});
} else {
	Cufon.replace('.page-content h2,.grid-buynow,.grid-info strong,.panel-info strong,.panel-info .price,.slide-text .text-block h2,.slide-text .text-block .price,.nivo-html-caption h2,.column h2,.view-switcher .title', {textShadow: '#fff 1px 1px 0',fontFamily:'Junction'});
	Cufon.replace('.date .month,.date .day,.date .year',{textShadow: '#fff 1px 1px 0',fontFamily:'BebasNeue'});
}

(function($) {

	$(function() {
	
		var currentView = defaultView;
	
		if (Modernizr.localstorage) {
			if (localStorage.getItem('themetheater_view_type') == null){
				if (defaultView && !defaultViewHidden){
					localStorage.setItem('themetheater_view_type', defaultView);
					var currentView = defaultView;
				} else if (defaultViewHidden) {
					var currentView = $('.view-switcher').find('a:first-child').attr('rel');
					localStorage.setItem('themetheater_view_type', currentView);
				} else {
					localStorage.setItem('themetheater_view_type', 'slider');
					var currentView = 'slider';
				}
			} else {
				var currentView = defaultView;
			}
		} else {
			if (getCookie('themetheater_view_type') == ''){
				setCookie('themetheater_view_type','slider',30);
			} else if (defaultViewHidden) {
				var currentView = $('.view-switcher').find('a:first-child').attr('rel');
				setCookie('themetheater_view_type',currentView,30);
			} else {
				var currentView = getCookie('themetheater_view_type');
			}
		}
		
		if (defaultViewHidden || !currentView){
			var currentView = $('.view-switcher').find('a:first').attr('rel');
			if (Modernizr.localstorage) {
				localStorage.setItem('themetheater_view_type', currentView);
			} else {
				setCookie('themetheater_view_type',currentView,30);
			}
		}
		
	  	if (window.location.hash){
	  		hashVariable = window.location.hash;
	  		hashVariable = hashVariable.split('#');
	  		var currentView = hashVariable[1];
	  	} else if (!currentView){
	  		$('#loading-zone').hide();
	  	}

		if(currentView && isHome) { $('.view-switcher a.'+currentView+'-view').addClass('active'); }
	
		$('#loading-zone').empty().load(themePath+'/view_'+currentView+'.php',function(){
			Cufon.refresh();
			$(this).removeClass('loading');
		});
		
		/* View Switcher */
		if (isHome){
			$('.view-switcher a').click(function(){
				
				var currentView = $('#loading-zone').find('div:first').attr('id');
				var switchTo = $(this).attr('rel');
				
				if (switchTo != currentView){
					$('.view-switcher a').removeClass('active');
					$(this).addClass('active');
					
					if (Modernizr.localstorage) {
						localStorage.setItem('themetheater_view_type', switchTo);
						var currentView = localStorage.getItem('themetheater_view_type');
					} else {
						setCookie('themetheater_view_type',switchTo,30);
						var currentView = getCookie('themetheater_view_type');
					}
					
					$('#loading-zone').empty().addClass('loading').load(themePath+'/view_'+switchTo+'.php',function(){
						Cufon.refresh();
						$(this).removeClass('loading');
					});
					
				}
				
				return false;
				
			});
		}
		
		if ($.browser.msie) {
			if ($.browser.version > 6) {
				$('nav ul ul').animate({'top':43},0);
				$('nav ul ul ul.sub-menu').animate({'top':-10},0);
				
				$('nav li').has('ul').hover(function(){
					if ($(this).parent('ul').hasClass('sub-menu')){
						$(this).find('ul:first').show().animate({'top':0},150);
					} else {
						$(this).find('ul:first').show().animate({'top':43},150);
					}
				},function(){
					if ($(this).parent('ul').hasClass('sub-menu')){
						$(this).find('ul:first').hide().animate({'top':-10},0);
					} else {
						$(this).find('ul:first').hide().animate({'top':20},0);
					}
				});		
			};
		} else {
			$('nav ul ul').animate({'opacity':0,'top':43},0);
			$('nav ul ul ul.sub-menu').animate({'opacity':0,'top':-10},0);
			
			$('nav li').has('ul').hover(function(){
				if ($(this).parent('ul').hasClass('sub-menu')){
					$(this).find('ul:first').show().animate({'opacity':1,'top':0},150);
				} else {
					$(this).find('ul:first').show().animate({'opacity':1,'top':43},150);
				}
			},function(){
				if ($(this).parent('ul').hasClass('sub-menu')){
					$(this).find('ul:first').hide().animate({'opacity':0,'top':-10},0);
				} else {
					$(this).find('ul:first').hide().animate({'opacity':0,'top':20},0);
				}
			});
		}

	});
	
})(jQuery);

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    {
	    c_start=c_start + c_name.length+1;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    }
	  }
	return "";
}
