var menuhover = {
	resetZindex: function() {
		if(document.body.id) alert(document.body.id);
		var i = document.getElementsByTagName('img');
		for(var j=0;j<i.length;j++) {
			i[j].style.zIndex=1;
		}
	},
	registerMouseHover: function(obj) {
		if(document.getElementById('contentTreasuresVideoWin')) {
			var videoWin = document.getElementById('contentTreasuresVideoWin');
			videoWin.style.zIndex = 1;
		}
		if(document.getElementById('othercatselected')) {
			var secondDropDown = document.getElementById('othercatselected')
		}
		for(var i=0;i<obj.childNodes.length;i++) {
			obj.childNodes[i].onmouseover=function() {
				this.style.zIndex = 900;
				this.className += ' hover';
			}
			obj.childNodes[i].onmouseout=function() {
				this.style.zIndex = 1;
				this.className -= ' hover';
			}
		}
	},
	setLeftZindex: function(el) {
		var initZ = 500;
		initZ = 500;
		if(el.className.indexOf('indentHoverShown')<0) el.className += ' indentHoverShown';
		var c = el.childNodes;
		for(var i=0;i<c.length;i++) {
			initZ++;
			c[i].style.zIndex=initZ;
			if(c[i].childNodes.length) {
				var cc = c[i].childNodes;
				for(var ii=0;ii<cc.length;ii++) {
					initZ++;
					cc[ii].style.zIndex=initZ;
				}
			}
		}
	},
	init: function() {
		var self = menuhover;
		if(!document.getElementById || !document.getElementsByTagName) return;
		if(!document.all) return;
		if(document.getElementById('topmenulist')) {
			var t = document.getElementById('topmenulist');
			self.registerMouseHover(t);
		}
		if(document.getElementById('detailLinksShipping')) {
			var c = document.getElementById('detailLinksShipping');
			self.registerMouseHover(c);
		}
		if(document.getElementById('othercatselected')) {
			var o = document.getElementById('othercatselected');
			self.registerMouseHover(o);
		}
		/*
		if(document.getElementById('cntrNavLeft')) {
			var c = document.getElementById('cntrNavLeft');
			var l = c.getElementsByTagName('li');
			for(var i=0;i<l.length;i++) {
				if(l[i].className.indexOf('indentHover')>=0) {
					l[i].onmouseover=function() {
						this.className += 'hoveringIndent';
					}
					l[i].onmouseout=function() {
						this.className -= 'hoveringIndent';
					}
				}
			}
		}
		*/
	}
};
function sendEvent(swf,typ,prm) {
	try {
		thisMovie(swf).sendEvent(typ,prm); 
	} catch(e) {
		doNothing = true;
	}
};
function thisMovie(swf) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
    	return window[swf];
	} else {
		return document[swf];
	}
};
var movieisplaying = false;
var moviecurrentcue = 0;
function getUpdate(typ,pr1,pr2,swf) {
	if(typ == "state") {
		if(pr1==2) movieisplaying = true;
		else movieisplaying = false;
	} 
	if(typ == "time") {
		moviecurrentcue = pr1;
	}
};
// default video data
var treasuresVideoDataDefault = {
	playerPath: "http://cdn.liveclicker.net/player/mediaplayer.swf",
	playerName: "keepersvid",
	impactDivId: "contentTreasuresVideoWin",
	aditionalFlashvars: "",
	videoWidth: 320,
	videoHeight: 240,
	displayWidth: 320,
	displayHeight: 240,
	autostart: "true"
};
var treasuresOfTheWorld = {
	defineAndSet: function() {
		var self = treasuresOfTheWorld;
		var tvVars = treasuresVideoDataDefault;
		var tvData = treasuresVideoData;
		var tvFlashvars = "file=" + tvData.videoPath + "&image=" + tvData.thumbnailPath + "&autostart=" + tvVars.autostart + "&enablejs=true&width=" + tvVars.videoWidth + "&height=" + tvVars.videoHeight + "&displaywidth=" + tvVars.displayWidth + "&displayheight=" + tvVars.displayHeight + "&showdigits=true&showfsbutton=false&javascriptid=" + tvVars.playerName;
		var so = new SWFObject(tvVars.playerPath,tvVars.playerName,tvVars.displayWidth,tvVars.displayHeight,'8');
		so.addParam('build', '0');	
		so.addParam('allowfullscreen','true');
		so.addParam('allowscriptaccess','always');
		so.addParam('wmode','transparent');
		so.addParam('flashvars',tvFlashvars);
		//so.addVariable('javascriptid',tvVars.playerName);
		//so.addVariable('enablejs','true');
		so.write(tvVars.impactDivId);
		self.vidInstanceCreated = true;
	},
	toggleVideoWin: function(onoff) {
		var self = treasuresOfTheWorld;
		if(!document.getElementById('contentTreasuresVideo')) return;
		var v = document.getElementById('contentTreasuresVideo');
		v.style.zIndex = 1;
		if(!self.vidInstanceCreated) {
			self.defineAndSet();
		}
		if(onoff==1) {
			v.style.display = 'block';
			if(!movieisplaying) {
				sendEvent(treasuresVideoDataDefault.playerName,"playpause");
				if(navigator.appName.indexOf("Microsoft") < 0 && moviecurrentcue>0) {
					sendEvent(treasuresVideoDataDefault.playerName,"scrub",moviecurrentcue-2);
				}
				
			}
		} else {
			if(movieisplaying) {
				sendEvent(treasuresVideoDataDefault.playerName,"playpause");
			}
			v.style.display = 'none';
		}
	},
	displayVideo: function(jsonData) {
		var jsonObj = eval('('+jsonData.responseText+')');
		if(document.getElementById('cntrKeepers')) {
			h=document.getElementById('cntrKeepers');
		} else {
			h=document.createElement("div");
			h.id="cntrKeepers";
			h.setAttribute("id","cntrKeepers");
		}
		h.innerHTML = jsonObj.content;
		var XYpos = locator.getit();
		Xpos = (XYpos[0]-480)/2;
		h.style.left = Xpos+"px";
		document.getElementsByTagName("body")[0].appendChild(h);
		messaging.showprogress(0);
		//alert(jsonObj.content);
	},
	createWindow: function() {
		var self = treasuresOfTheWorld;
		if(treasureVideoID) {
			messaging.showprogress(1);
			var data = "";
			var keepersUrl = "/commonDSP/dspKeepersInline.cfm?jsview=1&videoID="+treasureVideoID+"&"+getDateString.init();
			var myAjax = new Ajax.Request(keepersUrl,{asynchronous:true, method: 'get', parameters: data, onComplete: self.displayVideo, onFailure: ajaxResultError});
		}
	},
	closeWindow: function() {
		var self = treasuresOfTheWorld;
		var d = document.getElementsByTagName("body")[0];
		for(var i=0;i<d.childNodes.length;i++) {
			if(d.childNodes[i].id=='cntrKeepers') {
				d.childNodes[i].style.display='none';
				d.removeChild(d.childNodes[i]);
				break;
			}
		}
	},
	init: function() {
		var self = treasuresOfTheWorld;
		var vl = document.getElementsByTagName('a');
		for(var i=0;i<vl.length;i++) {
			if(vl[i].className.indexOf('vlinkcategory')>=0) {
				vl[i].onclick=function() {
					self.createWindow();
					return false;;
				}
			}
			if(vl[i].className.indexOf('vlinkshutoff')>=0) {
				vl[i].onclick=function() {
					self.closeWindow();
					return false;
				}
			}
		}
		if(typeof videoAutoPlay != 'undefined') {
			if(videoAutoPlay==1) {
				self.createWindow();
			}
		}
	}
};