﻿// JScript File

var oImgSmall = null;
var oImgLarge = null;
var oVideo    = null;
var oMagnify  = null;
var isRunning = false;
var currentInfoPanel = null;
var isInfoPanelRunning = false;
var oOverlay = null;

//	store background images in objects to check dimensions?

$(document).ready(function() {
    if (document.getElementById("IsProductPage") && !document.getElementById("ajaxLoaded")) {
        run();
    }
});


$(document).mouseover(function(){

	if (document.getElementById("IsProductPage") && !document.getElementById("ajaxLoaded")) {
        run();
    }
});


function run() {
    
    $(".SearchPhoneView").each(function(){
		this.id = "ajaxLoaded";
		
	});
	
	//	TABS - set the selected "Active" tab onload
	$(".ProductInfo .ProductInfoTabs li.Active").each(function(){
		$("#" + this.id + "Content").show();
		currentInfoPanel = this.id;
	});
	
	//	TABS - toggle tabs
	$(".ProductInfo .ProductInfoTabs li, .ProductInfo .ProductInfoTabs li a").click(function(e){
		//	remove cursor marquee and stop event bubbling
		this.blur();

		if (window.event) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		} else if (e && e.preventDefault && e.stopPropagation) {
			e.preventDefault();
			e.stopPropagation();
		}
		
		//	get the id of the tab li tag
		var id = (this.tagName == "A") ? this.parentNode.id : this.id;	
		
		//	exit if:
		//	the current "Active" tab has not been set onload
		//	the id is the same as current tab
		//	if the info panel animation is already running
		if (currentInfoPanel == null || id == currentInfoPanel || isInfoPanelRunning == true) {
			return;
		}
		
		//	flag the info panel animation as running
		isInfoPanelRunning = true;
		
		//	hide current and show new current
		$("#" + currentInfoPanel).removeClass("Active");
		$("#" + id).addClass("Active");
		$("#" + currentInfoPanel + "Content").fadeOut(250, function() {
			$("#" + id + "Content").fadeIn(250);
			isInfoPanelRunning = false;
		});
		currentInfoPanel = id;
	});
	
};

