﻿// Block 1
menu_status = new Array();

function showHide(theid){
	if (document.getElementById) {
	var switch_id = document.getElementById(theid);

		if(menu_status[theid] != 'show') {
			switch_id.className = 'show';
			menu_status[theid] = 'show';
		}else{
			switch_id.className = 'hide';
			menu_status[theid] = 'hide';
		}
	}
}

function showDropdown(x,id) {
	var v = 'none';
	if (x) v = 'block';
	document.getElementById('dropdown').style.display = v;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image;
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i = 0; i < changeImages.arguments.length; i += 2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i + 1];
		}
	}
}

function get_win_props(thewidth,theheight)
{
	theprops = '';
	if(screen.width)
	{
		theprops = 'left=' + (screen.width - thewidth) / 2;
		theprops = theprops + ', top=' + (screen.height - theheight) / 2;
		theprops = theprops + ', ';		
	}
	theprops = theprops + 'width='+thewidth+',height='+theheight+',resizable=yes,status=0';
	return theprops;
}

function popup(filename,width,height)
{
	thedefinitionWindow = open(filename, "deWin"+width+height, get_win_props(width,height));
	thedefinitionWindow.focus();
}	

function open_tell_a_friend_window() {
	popup("tellafriend.html", 600, 420);
}

	function pop_product(popURL, popW, popH, scrollbars) {
		var agt = navigator.userAgent.toLowerCase();
		var is_mac = agt.indexOf("mac") != -1;
		var is_op = agt.indexOf("opera") != -1;
		var is_ie = is_op == false && agt.indexOf("msie") != -1;
		if (is_mac && is_ie) {
			popW = popW - 17;
		}
		window.open("productshot.html", "pop", "location=no,status=no,scrollbars=" + scrollbars + ",toolbar=no,height=" + popH + ",width=" + popW);
	}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		medium1 = newImage("images/pi1-355x355.jpg");
		medium2 = newImage("images/pi2-355x355.jpg");
		medium3 = newImage("images/pi3-355x355.jpg");
		medium4 = newImage("images/pi4-355x355.jpg");
		pdpBgCell = newImage("images/prod_thumb_border.gif");
		pdpBgCellWithSelector = newImage("images/prod_thumb_border_with_selector.gif");
		preloadFlag = true;
	}
}

var largeImgSrc='images/pi1-600x600.jpg';
var bg_with_selector = 'images/prod_thumb_border_with_selector.gif';
var bg_without_selector = 'images/prod_thumb_border.gif';
var activeCell = 'imgBorderCell0';

/* +++++++++++++++++++++++++++++++ */
/* 
MODAL WINDOW EMBED
*/
/* +++++++++++++++++++++++++++++++ */

function closeBtn(btn,cont) {
	$("#bgl").click(function(){
		$("#shellenclosure").html("");	
	});
	
	$(".close").click(function(){
		$("#shellenclosure").html("");	
	});
}

// LOAD GALLERY
function loadGallery(cont,ref) {
	$(cont).load(ref, function() {
		
		//alert("hit");/*
		closeBtn();
		
		$(".fofSingleItem").click(function(event){
			// alert("hit");
			event.preventDefault();
			loadItem("#fofenclosure",$(this).attr("href"));
		});
	});
}

// LOAD GALLERY ITEM
function loadItem(cont,ref) {
	$(cont).load(ref, function() {
		closeBtn();
		
		// GO BACK TO GALLERY
		$(".backBtn").click(function(event){
			// alert("hit");
			event.preventDefault();
			loadGallery("#fofenclosure",$(this).attr("href"));
		});
		
		taf();		
	});
}

function taf() {
	// GO BACK TO GALLERY
	$(".taf").click(function(event){
		//alert("hit");
		event.preventDefault();
		popup($(this).attr("href"),600,370)
	})
}

$(document).ready(function(){
	$(".fofbtn").click(function(event){
		event.preventDefault();
		//alert($(this).attr("href"));
		var ref = $(this).attr("href");
		
		$("#shellenclosure").load("fof-shell.html", function() {
			loadGallery("#fofenclosure",ref);			
		});
	});
	 
	$(".tvBox").click(function(event){
		event.preventDefault();
		//alert($(this).attr("href"));
		var f = $(this).attr("href");
		var t = $(this).attr("title");
		var c = $(this).attr("caption");
		var r = $(this).attr("rel");
		
		// alert(f + ", " + t + ", " + c);
		$("#shellenclosure").load("tv_window.html", function() {
			//alert(f + ", " + t + ", " + c);
			var horizOffset = 300;
			var vertOffset = 0;
			
			var pageWidth = document.documentElement.offsetWidth;
			var pageHeight = document.documentElement.offsetHeight;  // Center the dialog
			//alert(pageWidth + ", " + pageHeight);
			var divWidth = $("#pu").width();
			
			horizOffset = (pageWidth / 2) - (divWidth / 2);
			vertOffset = pageHeight / 2;
			//alert(horizOffset);
			
			//alert($("#pu").width());
			
			ts = parseInt(new Date().getTime().toString().substring(0, 10)); // timestamp
			//alert("The Time is" + ts);
			
			$("#addtocart").attr("href","NEEDURL?itemNo=" + r + "&action=add&tsn=" + ts);
			$("#moreinfo").attr("href", "NEEDURL" + r);
			
			$("#pu").css("position", "fixed");
			$("#pu").css("left", horizOffset + "px");
			// $("#pu").css("top", vertOffset + "px");
		
			closeBtn();
			
			$("#puCaption").replaceWith("<strong>" + t + "</strong>, " + c);
			
			//alert(f);
			sp(f,400);
			taf();
		});
	});
	 
	$("select#media").change(function(event){
		
		var o = this.value;
		
		//alert(o);
		if (o == "video") {
			//alert("hit");
			$("#fineprint").css("background-color","#fff");
			$("#fineprint").load("tandc-video.html");
		} else if(o == "picture") {
			$("#fineprint").css("background-color","#fff");
			$("#fineprint").load("tandc-image.html");			
		} /* else if(o == ""){
			$("#fineprint").load("");	
			$("#fineprint").css("background-color","#ccc");
		} */
	});
	 
	$(".vidBox").click(function(event){
		event.preventDefault();
		//alert($(this).attr("href"));
		var f = $(this).attr("href");
		var t = $(this).attr("title");
		var i = $(this).attr("id");
		var c = $(this).attr("caption");
		var r = $(this).attr("rel");
		
		// alert(f + ", " + t + ", " + c);
		$("#shellenclosure").load("video_window.html", function() {
			//alert(f + ", " + t + ", " + i + ", " + c  + ", " + r);
			closeBtn();			
			
			$("#pu_proddescr").replaceWith("<a href='product/" + r + "'><strong>" + t + "</strong></a>, " + c);

			$("#pu_thumb").attr("src","images/" + r + "-1s-low.jpg");
						
			ts = parseInt(new Date().getTime().toString().substring(0, 10)); // timestamp
			//alert("The Time is" + ts);
			
			$("#addtocart").attr("href","NEEDURL?itemNo=" + r + "&action=add&tsn=" + ts);
			$("#moreinfo").attr("href", "NEEDURL" + r);
			
			var horizOffset = 300;
			var vertOffset = 0;
			
			var pageWidth = document.documentElement.offsetWidth;
			var pageHeight = document.documentElement.offsetHeight;  // Center the dialog
			
			var divWidth = $("#pu").width();
			
			horizOffset = (pageWidth / 2) - (divWidth / 2);
			vertOffset = pageHeight / 2;
			//alert(horizOffset);
			
			//alert($("#pu").width());
			
			$("#pu").css("position", "fixed");
			$("#pu").css("left", horizOffset + "px");
			//$("#pu").css("top", 120 + "px");
			
			sp(f,340);
			//alert(f);
			taf();
		});
	});
	
	function sp(f,h) {
		
		// use flashembed to place flowplayer into HTML element 
		api = flashembed("videoPlayer", 
			// first argument supplies standard Flash parameters. See full list:
			// http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701
			{
				src:"swf/FlowPlayerLight.swf",
				width: 550,
				height: h
			},
					
			// second argument is Flowplayer specific configuration. See full list:
			// http://flowplayer.org/player/configuration.html
			{ config: {
				initialScale: 'scale',
				autoRewind: true,
				loop: false,
				autoPlay: true,
				videoFile: f,
				showMuteVolumeButton: false,
				showMenu: false,
				showStopButton: false,
				showFullScreenButton: false,
				showVolumeSlider: false
			}}
		);
	}
});	

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}


// document.getElementById('pu').style.top = 20 + f_scrollTop();
// document.getElementById('pu').style.display = 'block';

/* +++++++++++++++++++++++++++++++ */
/* 
PRODUCT TAB CONTROLS
*/
/* +++++++++++++++++++++++++++++++ */

// Jquery code to handle tabs
// Revised 5.5.09 Antics Digital Marketing
$(document).ready(function(){
	var $selectedTab = $("#tab1"); // Set the initial selected tab
	var $selectedTabContent = $("#tab1content"); // Set the initial selected tab content
	$(".tabs li a").click(function() { // Handle clicks to the tabs
		$selectedTab.removeClass("selected"); // Clear the old selected tab
		$selectedTab = $(this);
		$(this).addClass("selected"); // Highlight the new selected tab
	
		$selectedTabContent.hide(); // Hide the old tab content
		var thisTabContent = "#" + $(this).attr("id") + "content";
		$selectedTabContent = $(thisTabContent);
		$selectedTabContent.show(); // Show the tab new content
	});	
});


