var replaceSpaces = "";

function base(){
	// add shadows and set heights1
	$("div.wrapper").prepend("<div class='bg-shadow-bottom'></div>");
	
	if ( $("div.search").height() > $("div.spotlight").height() ){
		columnHeight = $("div.search").height();
		$("div.spotlight").css({height:columnHeight});
	}

	if ( $("div.spotlight").height() > $("div.search").height() ){
		columnHeight = $("div.spotlight").height();
		$("div.search").css({height:columnHeight});
	}
	
	if( $("div#phpworx_product_search").height()+40 > $("div.search").height() ){
		columnHeight = $("div#phpworx_product_search").height()+40;
		$("div.search").css({height:columnHeight});
		$("div.spotlight").css({height:columnHeight});
	}

	$("div.header ul li").hover(
		function () {
			$(this).addClass("active"); 
			$(this).children("ul").show();
		}, 
		function () {
			$(this).removeClass("active");
			$(this).children("ul").hide();
		}
	);
	
	// replace all neccessary spaces with &nbsp; (like for nav drop downs)
	$("div.header ul li ul li a").each(function(){
		replaceSpaces = $(this).text().replace(/ /g,'\u00a0');
		$(this).text(replaceSpaces);
	});

	$("a.more").append("&nbsp;&raquo;");
	
	$("table.chart tr:odd").addClass("odd");	
	$("table.chart tr:even").addClass("even");	
	$("table.chart tr").hover(
		function () { $(this).addClass("active"); }, 
		function () { $(this).removeClass("active"); }
	);


	
	//show and hide popup box (if cookied has not been set to 1)
	var doNotShowPopup = $.cookie('do-not-show-popup');
	if(doNotShowPopup == null) doNotShowPopup = '0';

	$.cookie('do-not-show-popup', doNotShowPopup, {expires: 365});
	
	if(doNotShowPopup != '1'){
	    $("div.popup-bg").fadeIn();
	    $("div.close").click(function(){
		    $("div.popup-bg").fadeOut();
	    });
	}
}

function form(){
	$('#signup').ajaxForm(function() { 
		 alert('Thank you!');					   
        $('div.popup-bg').fadeOut();
    }); 
	$('.email-form').ajaxForm(function() { 
		 alert('Thank you!');					   
       $('#signup-02').fadeOut();
    });
}

function innerfade(){
	if($("div.flash").height() > 0)
	{
		$("div.flash div.flash-innerfade img").css({ visibility:"visible" }); 
		$("div.flash div.flash-innerfade").innerfade({ speed: 750, timeout: 999999, type: 'random', containerheight: '267px' }); 
	}
	
	if($("div.spotlight").height() > 0)
	{
		$("div.spotlight div.spotlight-innerfade").innerfade({ speed: 750, timeout: 5000, type: 'random', containerheight: '189px' }); 
	}
}

function cycle(){
	$('ul.flash').before('<div id="nav" class="nav">').cycle({ 
    	speed: 300,
		timeout: 5000,
		pager: '#nav'
	});	
}
