/*------------------------------------
Copyright(c) 1999-2007 Topper Jewelers.
All rights reserved. Reproduction in whole or in part in any form or medium 
without express written permission of Topper Fine Jewelers is prohibited.
--------------------------------------*/

function browserIs(browserName){	
	if(navigator.appName==browserName){		
		return true;
	}else{
		return false;
	}
}
/**
 * uses Scriptaculous
 * wcc 2.20.2008
 * sample usage: http://dev.topperjewelers.com/watches/ball/interview
 */
function fadeAllExcept(id,limit) {
	var id_param = id + '';	
	limit++;
/*	new Effect.Appear(id_param);	*/
	document.getElementById(id_param).style.display = "block";

	document.getElementById("li_"+id).style.border = "2px solid #666666";
	document.getElementById("li_"+id).className = "active_link";
	for(var i = 1; i < limit; i++){
		if(i!=id){
			i_param = i + '';
			/*new Effect.Fade(i_param);*/
			document.getElementById(i_param).style.display = "none";
			document.getElementById("li_"+i).style.border = "2px solid #CCCCCC";
			document.getElementById("li_"+i).className = "";
		}
	}	
}

function openWindow(strUrl,strWindowName,strOptions){
	var newWindow = null; 

	if(newWindow == null || newWindow.closed)
	{
		if(strOptions == null) strOptions = "width=1020,height=700,top=0,left=0,resizable=yes,scrollbars=yes,toolbar=yes,location=no";
		newWindow = window.open(strUrl, strWindowName,strOptions);
	}
	else
	{
		newWindow.focus();
	};
}

function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

function imgSwap(imgSource,imgTarget) {
	if(document.images) {
		imgNew = eval(imgSource + ".src");
		document.images[imgTarget].src = imgNew;
	} else {
		return false;
	}
}

function changeImageSource(layer,imgName,imgObj) {
	if (document.images) {
		document.images[imgName].src = eval(imgObj+".src");
	} else if (document.layers && layer!=null) {
		eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
	}
}

function getStyleObject(objectId) {
	// cross-browser function to get an object's style object given its id
	if(document.getElementById && document.getElementById(objectId)) {
		// W3C DOM
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId) && !document.getElementById) {
		// MSIE 4 DOM
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
		// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
	} else {
		return false;
	}
}

function moveObject(objectId, newXCoordinate, newYCoordinate) {
	var styleObject = getStyleObject(objectId);
	if(styleObject) {
		styleObject.left = newXCoordinate;
		styleObject.top = newYCoordinate;
		return true;
	} else {
		return false;
	}
} 

function setStyle(prop,newValue) {
	var i, a;
	if(document.getElementById) {
		for(i=2; (a = getStyleObject(arguments[i]));i++) {
			a[prop] = newValue;
		}
	}
} //expected arugments > 2 are target object id 

function setArgument(arg,newValue) {
	var i, a;
	if (document.getElementById) {
		for(i=2; (a = document.getElementById(arguments[i])); i++) {
		  a[arg] = newValue;
		}
	}
} //expected arugments > 2 are target object id 

function setActiveStyleSheet(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

function sortNumber(a, b) {
	return b - a;
}

function getTallest() {
	var i, a;
	if (document.getElementById) {
		h = new Array();
		for(i=0; (a = document.getElementById(arguments[i])); i++) {
		  h[i] = a.offsetHeight;
		}
		h = h.sort(sortNumber)
		return h[0];
	}
} //expected arugments > 0 are obejct ids

function insertQTMovie(src,w,h) {
	if(src) {
		document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+w+'" height="'+h+'" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0 http://www.apple.com/qtactivex/qtplugin.cab" />\n');
		document.write('<param name="src" value="'+src+'" />\n');
		document.write('<param name="type" value="video/quicktime" />\n');
		document.write('<param name="controller" value="true" />\n');
		document.write('<param name="autoplay" value="true" />\n');
		document.write('<param name="target" value="myself" />\n');
		document.write('<param name="kioskmode" value="true" />\n');
		document.write('<param name="pluginspage" value="http://www.apple.com/quicktime/download/" />\n');
		document.write('<embed width="'+w+'" height="'+h+'" src="'+src+'" type="video/quicktime" controller="true" autoplay="true" target="myself" kioskmode="true" pluginspace="http://www.apple.com/quicktime/download/"></embed>\n');
		document.write('</object>\n');
	}
}

function popUp(URL,w,h) {
  remote = window.open(URL, 'popUp', 'status=no,width='+w+',height='+h+',resizable=yes,scrollbars=yes');
  remote.focus();
  return false;
}

function setAnchors() {
	var x = document.getElementById("content");
	if (!x) return;
	var y = x.getElementsByTagName("A");
	for (var i=0;i<y.length;i++) {
		switch (y[i].rel) {
		case "pricing" :
			y[i].onclick = function () {return popUp(this.href,350,420);}
			break;
		case "external" :
			y[i].target = "_blank";
			break;
		case "large_image" :
			y[i].onclick = showLarge;
			break;
		case "swatch" :
			y[i].onclick = swatch;
			break;
	/*	case "strap":		//commented because we dont want to use anchor tags no more. wcc.3.19.2008
			y[i].onclick = showStrap;
			break;*/
		case "switch_image"://wcc 3.05.2008
			y[i].onclick = switchImage;//wcc 3.05.2008
			break;	//wcc 3.05.2008
		case "dial":
			doToolTip(y[i]);
			break;

		}
	}
}
// Commented out by Erwin //
// Old Menu Pulldown Script
/* --------
sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(" over", "");
		}
	}
}

//Using IE only attachEvent to make sure only IE runs startList(), all other borwsers support CSS hover behavior
if (window.attachEvent) window.attachEvent("onload", sfHover);
-------- */

window.onload = setAnchors;

