/*POPOUT MENU*/
function mainmenu(){
	$(" #menu li").hover(function(){
			$(this).find('.subNav').show();
			$(this).find('a').addClass("hovered");
		},function(){
			$(this).find('.subNav').hide();
			$(this).find('a').removeClass("hovered");
		});
}

/*MAKES PADDING TO WRAP TEXT AROUND IRREGULAR SHAPRES*/
/*Call function immediatly before targeted content with line height in pixels, and pipe seperated array of widths to pad for each line*/
function wrapAround(lineHeight,arrPad) {
	var markup = '';
	Xvalues = arrPad.split('|');
	for(i=0; i < Xvalues.length; i++) {
		arrLinePad = Xvalues[i].split(',');
		markup += '<div style="float:left;clear:left;height:'+lineHeight+'px;width:'+ arrLinePad[0]+'px"></div>';
		markup += '<div style="float:right;clear:right;height:'+lineHeight+'px;width:'+ arrLinePad[1]+'px"></div>';
	}
	
	document.write(markup);
}

var flip = 0;
function showOrHideLoginBox() {
    $('#loginBox').toggle(flip++ % 2 == 0);
		
	/* On first click setup swfIR, and watermarks*/
	if(flip == 1){
		/*Watermark login box text inputs*/
		$("#email").watermark({watermarkText: "Email Address"});
	 	$("#password").watermark({watermarkText: "Password"});
		sIFR.replace(cityd, {
			selector: 'h2.textReplace',
			css: '.sIFR-root { background-color: #FFFFFF; color: #7CAE2F; }',  
			wmode: 'transparent'
		});
		/* Redraw dropshadow, in case SwfIR doesn't replace text in time */
		setTimeout ('$("#loginBox").redrawShadow(); $("#loginBox").css("zIndex", 1010);', 50);
		setTimeout ('$("#loginBox").redrawShadow(); $("#loginBox").css("zIndex", 1010);', 500);
	}
	
	
	/*Dropshadow for login box*/
	if(flip % 2 == 0){
		$("#loginBox").removeShadow();
	}else{
		$("#loginBox").dropShadow();
		$('#loginBox').css('zIndex', 1010);
	}
}

$(document).ready(function(){
	
	/*Show hide for login box*/
	$("#proButton").click(function(){
		showOrHideLoginBox();
	});
	
	mainmenu();		
	
	/*IE  z-index fix*/
	/*Only fixes for DIV elements, modify as needed*/
	$(function() {
		var zIndexNumber = 1000;
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
	});
	
	
	/*Rounded corners for login box*/
	$("#loginBox").corners("4px bottom top-right");
	
	/* Dropshadow for promopanel links */
	$(".promoPanel li a").dropShadow("2px");
	
	/*Fix IE PNG transparency bugs*/
	$(document).pngFix();
	
});



