/**
 * @author johnhardy
 */

var _zindex=900;
$(document).ready(function() {

	//PRELOAD IMAGES

	var img=Array();

	img[1]=new Image();
	img[1].src="../../img/revitol_09/feat-aas.jpg";

	img[2]=new Image();
	img[2].src="../../img/revitol_09/feat-aat.jpg";

	img[3]=new Image();
	img[3].src="../../img/revitol_09/feat-cs.jpg";

	img[4]=new Image();
	img[4].src="../../img/revitol_09/feat-sp.jpg";

	img[5]=new Image();
	img[5].src="../../img/revitol_09/feat-hrc.jpg";

	img[6]=new Image();
	img[6].src="../../img/revitol_09/feat-sb.jpg";

	img[7]=new Image();
	img[7].src="../../img/revitol_09/feat-se.jpgIRST PANEL BUTTON AS SELECTED

	$(".front_nav_button:eq(0)").css({"background-image":"url(/img/revitol_09/front_nav_over.png)"});

	//FRONT NAV HOVERS & CLICKS
	$(".front_nav_button").hover(

		function() {

			//MARK ALL THE CURRENT IMAGE

			$("#front_img_panel .wrapper .img_tile").attr({"rel":"remove"});

			$(this).css({"background-image":"url(/img/revitol_09/front_nav_over.png)"});

			var tile="/img/revitol_09/feat-"+$(this).attr("rel")+".jpg";

			$("#front_img_panel .wrapper").append("<img id='img_"+_zindex+"' src='"+tile+"' class='img_tile' style='z-index:"+_zindex+"' />");

			$("#img_"+_zindex).fadeIn('normal',function() {   $(".img_tile[rel=remove]").remove();     });

			_zindex++;

		},
		function() {

			$(this).css({"background-image":""});

		}
	).click(

		function() {

			var ref=$(this).find("a").attr("href");

			document.location.href=ref;

		}

	);


	//PRODUCT TILE HOVERS & Clicks

	$(".front_page_product").hover(

		function() {

			$(this).css(

				{
						"background-image":"url(/img/revitol_09/front_prod_over.jpg)"

				}

			).find(".prod_img").css(
				{

					"border-color":"#999999"

				}

			);

		},
		function() {

			$(this).css(

				{
					"background-image":""

				}

			).find(".prod_img").css({"border-color":"none"});

		}

	).click(

		function() {

			var ref=$(this).find("a").attr("href");

			document.location.href=ref;
		}

	);


			$(".front_page_product .product_img").each(

					function() {

						var ref=$(this).find("img").attr("src");

						$(this).find("img").remove();

						var i = new Image();



						$(this).append($(i));

						i.src=ref;

						i.onload=function() {

								var h=$(this).height();
								var offset=(80-h)/2 | 0;

								$(this).css({"margin":"auto","margin-top":offset+"px","text-align":"center"}).show();

						};

					}

			);



});


$(window).ready(

	function() {








	}

);
