﻿
var newwindow;
function launchStoreLocator(zipCode, storeID) {
	var w = 845;
	var h = 540;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+','; 
	settings +='left='+winl+',';
	settings +='scrollbars=no,';
	settings +='resizable=no';	
	var url = absoluteBasePath + '/store_locator.aspx';
	newwindow = window.open(url,'store_locator',settings);
	
	if(newwindow) setTimeout("newwindow.focus()",100);
}


function launchCardPrice()
{
    var w = 845;
    var h = 640;
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    var settings = 'height=' + h + ',';
    settings += 'width=' + w + ',';
    settings += 'top=' + wint + ',';
    settings += 'left=' + winl + ',';
    settings += 'scrollbars=no,';
    settings += 'resizable=no';
    var url = absoluteBasePath + '/album/CardPrice.aspx';
    newwindow = window.open(url, 'card_price', settings);

    if (newwindow) setTimeout("newwindow.focus()", 100);
}


function openwindow2(url) { 
	window.open(url,"new_window","toolbar=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=1020,height=613"); 
}	

function launchHelpPanel(frameUrl) {
	var w = 750;
	var h = 560;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no,';
	settings +='resizable=no';	
	var url = absoluteBasePath + '/help_panel/help/help_panel.htm';
	
	if(frameUrl)
	    url += '?activeframe=' + frameUrl;
	    
	newwindow = window.open(url,'store_locator',settings);
	
	if(newwindow) setTimeout("newwindow.focus()",100);
}

function launchSlideShowHelpPanel() {
	var w = 750;
	var h = 560;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no,';
	settings +='resizable=no';	
	var url = absoluteBasePath + '/help_panel/help/help_panel.htm?activeframe=slideshow.htm';
	newwindow = window.open(url,'store_locator',settings);
	
	if(newwindow)
	{
		 setTimeout("newwindow.focus()",100);
	}
}	

function setUserNameCookie(userName)
{
	// cookie expires in 2 weeks
	var expiry = new Date();
	expiry.setDate(expiry.getDate() + 14);
	document.cookie = "userName=" + userName + "; expires=" + expiry.toGMTString();
}

function setPasswordCookie(password) 
{
	// cookie expires in 2 weeks
	var expiry = new Date();
	expiry.setDate(expiry.getDate() + 14);
	document.cookie = "password=" + password + "; expires=" + expiry.toGMTString();
}


function setSignedInCookie(signedIn)
{
	// cookie expires in 2 weeks
	var expiry = new Date();
	expiry.setDate(expiry.getDate() + 14);
	document.cookie = "signedIn=" + signedIn + "; expires=" + expiry.toGMTString();
}

function signOut(){
	setSignedInCookie('');
	setPasswordCookie('');
	setUserNameCookie('');
}
if(navigator.userAgent.indexOf('MSIE 6.0') > -1 )
	cart_bubbleTop = 102;

var moveIntervalId;
function doCartUpdateInfo()
{
	var _sCartUpdated = null; 
	var inputs = document.getElementsByTagName('input');
	for(var i = 0; i < inputs.length; i++)
	{
		var id = inputs[i].id;
		if(id.indexOf('txtShowCartProgress') > -1)
		{
			_sCartUpdated = inputs[i];
		}
	}
	if(_sCartUpdated != null && _sCartUpdated.value != '')
	{
	    AnimateAddToCart();
		
		_sCartUpdated.value = '';
	}		
}

function getCookieValue( key )
{
	key += "=";
	// Cookies separated by ";"
	var ca = document.cookie.split(";");
	for (var i=0; i < ca.length; i++)
	{
		var c = ca[i];
		var keyPos = c.indexOf(key);
		if (keyPos >= 0)
		{
			// Key may be prefixed with space.
			var keyAtStart = true;
			for (var prefixPos=0; prefixPos < keyPos; prefixPos++)
				if (c.charCodeAt(prefixPos) != 32)
					keyAtStart = false;

			if (keyAtStart)
				return c.substr(keyPos + key.length);
		}
	}

	return "";
}


var cart_bubbleTop = 48;
function AnimateAddToCart()
{
	var maxTop = -8;
	if(navigator.userAgent.indexOf('MSIE 6.0') > -1 )
		maxTop = 56;
	
	if(cart_bubbleTop  > maxTop)
	{
		document.getElementById('cart_bubble').style.top = cart_bubbleTop + 'px';
		setTimeout('AnimateAddToCart()', 30);
		cart_bubbleTop = eval(cart_bubbleTop - 1);
		document.getElementById('bubble_CartUpdated').style.display = 'block';
	}
	else
	{
		setInterval('document.getElementById("bubble_CartUpdated").style.display="none";',4000);
		clearInterval(moveIntervalId);
		cart_bubbleTop = 48;
	}
}


function addLoadEvent(func) {
    var oldonload = window.onload;
	
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() 
		{
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
