function rotate(){
	$("div.rotate img").css({visibility:"visible"});
	$("div.rotate").innerfade({
		speed: 1500,
		timeout: 4000,
		type: 'sequence',
		containerheight: '330px'
	});
}

function email(){
	$("form.email input#email").val("Email");
	$("form.email input#email").focus(function(){
		var emailValue = $(this).val();
		if ( emailValue == "Email" ){
			$(this).val("");
		}
	});
	$("form.email input#email").blur(function(){
		var emailValue = $(this).val();
		if ( emailValue == "" ){
			$(this).val("Email");
		}
	});
}

function arrows(){
	$("a.arrow-01").after("<img class='arrow-01' src='/images/arrow_01_blue.png' width='6' height='6' alt='' />");
	$("div.page a.arrow-01").hover(
		function(){
			$(this).next("img.arrow-01").remove();
			$(this).after("<img class='arrow-01' src='/images/arrow_01_black.png' width='6' height='6' alt='' />");
		},
		function(){
			$(this).next("img.arrow-01").remove();
			$(this).after("<img class='arrow-01' src='/images/arrow_01_blue.png' width='6' height='6' alt='' />");
		}
	);
	$("div.footer a.arrow-01").hover(
		function(){
			$(this).next("img.arrow-01").remove();
			$(this).after("<img class='arrow-01' src='/images/arrow_01_white.png' width='6' height='6' alt='' />");
		},
		function(){
			$(this).next("img.arrow-01").remove();
			$(this).after("<img class='arrow-01' src='/images/arrow_01_blue.png' width='6' height='6' alt='' />");
		}
	);
	$("a.arrow-02").before("<img class='arrow-02' src='/images/arrow_02_blue.png' width='10' height='6' alt='' />");
	$("div.page a.arrow-02").hover(
		function(){
			$(this).prev("img.arrow-02").remove();
			$(this).before("<img class='arrow-02' src='/images/arrow_02_black.png' width='10' height='6' alt='' />");
		},
		function(){
			$(this).prev("img.arrow-02").remove();
			$(this).before("<img class='arrow-02' src='/images/arrow_02_blue.png' width='10' height='6' alt='' />");
		}
	);
}

function gallery(){
	$("div.gallery ul.thumbs li").hover(
		function(){
			$(this).addClass("active");
		},
		function(){
			$(this).removeClass("active");
		}
	);
	$("div.gallery ul.thumbs li").click(function(){
		$("div.gallery div.full img").attr({src:"/gallery/images/full/"+this.id+".jpg"});
	});
}

var keepOpen = false;
var whichRetailer = "";
function map(){
	$("div.map div.retailer div.hidden").prepend("<a class='close'>X</a>");
	
	//first set control if user interacts with map
	$("div.map div.retailer").hover(
		function(){
			$("div.retailer").css({zIndex:"8"});
			$(this).css({zIndex:"9"});
			$(this).animate({width:"265px"}, 100, function(){
				$(this).css({backgroundColor:"#FFF", height:"auto"});
				$(this).children("div.title").fadeIn(100);
			});
		},
		function(){
			$(this).stop();
			if ( keepOpen == false) {
				$("div.title").hide(1);
				$("div.hidden").hide(1);
				$(this).animate({width:"15px"}, 100, function(){
					$(this).css({backgroundColor:"#7399c6", height:"15px"});
				});
			}
		}
	);
	$("div.map div.retailer div.title").click(function(){
		keepOpen = true;
		$(this).parent("div.retailer").siblings("div.retailer").fadeOut(200);
		$(this).siblings("div.hidden").slideDown(200);
	});
	
	// next set control if user interacts with left hand navigation
	$("div.nav ul li a").hover(
		function(){
			if( keepOpen == false ) {
				whichRetailer = $(this).attr("name");
				$("div.retailer").css({zIndex:"8"});
				$("div.map div#" + whichRetailer).css({zIndex:"9"});
				$("div.map div#" + whichRetailer).animate({width:"265px"}, 100, function(){
					$("div.map div#" + whichRetailer).css({backgroundColor:"#FFF", height:"auto"});
					$("div.map div#" + whichRetailer).children("div.title").show(1);
				});
			}
		},
		function(){
			$("div.map div#" + whichRetailer).stop();
			if ( keepOpen == false) {
				$("div.title").hide(1);
				$("div.hidden").hide(1);
				$("div.map div#" + whichRetailer).css({backgroundColor:"#7399c6", height:"15px"});
				$("div.map div#" + whichRetailer).animate({width:"15px"}, 100);
			}
		}
	);
	
	$("div.nav ul li a").click(function(){
		if ( keepOpen == false ) {
			$("div.map div#" + whichRetailer).siblings("div.retailer").fadeOut(200);
			$("div.map div#" + whichRetailer).children("div.hidden").slideDown(200);
			keepOpen = true;
		}
	});
	
	// set close control
	$("div.map div.retailer div.hidden a.close").click(function(){
		keepOpen = false;
		$("div.retailer").fadeIn(200);
		$(this).parent("div.hidden").siblings("div.title").hide();
		$(this).parent("div.hidden").hide();
		$("div.retailer").animate({width:"15px"}, 100);
	});
	
}
