// JavaScript Document ----------------------------------------------------*

// -----------------------------------------------------------------//
// -------------------- Daniel's js toolkits  ------------------//
// -------------------- dtdv.blogspot.com  ------------------//
// -----------------------------------------------------------------//

function dx(){}
dx.$=function(id){return document.getElementById(id)}
dx.$s=function(tn){return document.getElementsByTagName(tn)}
dx.$n=function(n){return document.getElementsByName(n)}
dx.show = function(id){dx.display(id,'block');}
dx.hide = function(id){dx.display(id,'none');}
dx.visible = function(id){dx.visibility(id,'visible');}
dx.invisible = function(id){dx.visibility(id,'hidden');}
dx.display = function(id,displayStyle){document.getElementById(id).style.display=displayStyle;}
dx.visibility = function(id,visibilityStyle){document.getElementById(id).style.visibility=visibilityStyle;}
dx.focus = function(id){document.getElementById(id).focus();}
dx.value = function(id,str){document.getElementById(id).value=str;}
dx.innerHTML = function(id, str){document.getElementById(id).innerHTML=str;}
dx.getValue = function(id){return document.getElementById(id).value;}
dx.getInner = function(id){return document.getElementById(id).innerHTML;}
dx.isKeyEnter = function(event){return (dx.getKey(event)==13);}
dx.getKey = function(event){return event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;}
dx.getQstr = function(iName){var regexS = "[\\?&]"+iName+"=([^&#]*)";var regex = new RegExp( regexS );var tmpURL=dx.getUrl();var results = regex.exec( tmpURL );if( results == null ) return "";else return results[1];}
dx.getUrl = function(){return window.location.href;}
dx.redirect = function(url){window.location=url;}
dx.winPop = function(url,w,h,features){var f;if(w&&h){f='width='+w+',height='+h;}else if(w){f=w}if(!features){features=',scrollbars=1,resizable';}else{features=','+features;}window.open(url,'',f+features);} // if only w then w = features
dx.winPopCenter = function (url,w,h,features){if (!w){w=600;}if(!h){h=500;}l=(screen.width)?(screen.width-w)/2:0;t=(screen.height)?(screen.height-h)/2:0;if (!features){features=',scrollbars=1,resizable';}else{features=','+features;}window.open(url,'','width='+w+',height='+h+',top='+t+',left='+l+features);}
dx.trim = function(str){return str.replace(/^\s+|\s+$/g, '');}
dx.isEmpty = function(str){return (dx.trim(str).length==0);}
dx.isIE = function(){return navigator.appName=='Microsoft Internet Explorer'}
dx.isSafari = function(){return navigator.vendor?navigator.vendor.indexOf("Apple")!=-1:false}
dx.ieTransparentPng = function(obj,pngPath){obj.style.background="none";obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+pngPath+"', sizingMethod='scale');";}
dx.jsstr=function(s){return s.replace(/\r\n|\r/g,'\n').replace(/\\/g,'\\\\').replace(/'/g,'\\\'').replace(/\n/g,'\\n')}
dx.gvBtnConfirm=function(obj, msg, bgColor){
	var bgc = obj.parentNode.parentNode.style.backgroundColor;
	if (bgColor) 
		obj.parentNode.parentNode.style.backgroundColor=bgColor;
	var cf = confirm(msg);
	obj.parentNode.parentNode.style.backgroundColor=bgc;
	return cf;
}
dx.jcall=function (src){
	var s = document.createElement("script");
	s.src = src;
	s.type = "text/javascript";
	s.id = "xscript";
	var h = document.getElementsByTagName('head')[0];
	var os = document.getElementById("xscript");
	if (os) h.removeChild(os);
	h.appendChild(s);
}

dx.jcallbc=function (src) { // dx.jcall bypass caching
	var q = src.indexOf("?") != -1 ? "&" : "?";
	dx.jcall(src+q+"t="+new Date().getTime());
} 
// Following codes require: Daniel modified motionpack.js
dx.slideV = function(id){if (document.getElementById(id).style.display!="block") slidedown(id); else slideup(id);} 
dx.slideH = function(id){if (document.getElementById(id).style.display!="block") slideright(id); else slideleft(id);} 
dx.slideUpAndDown = function(id){slideup(id, "down");}
dx.slideLeftAndRight = function(id){slideleft(id, "right");}
// Above codes require: Daniel modified motionpack.js

// Following codes for dd_window and dd_shadow
dx.getDdwindowTopbar = function(emt){var tr=emt.getElementsByTagName("tr");for (i=0;i<tr.length;i++) {if(tr[i].className=="dd_window_topbar")return tr[i];}return nothing;}
dx.makeWindows = function(){var w=document.getElementsByTagName("div");for(i=0;i<w.length;i++){if(w[i].getAttribute("name")=="ddwindow") dx.makeWindow(w[i]);}}
dx.makeWindow = function(obj){
			var lbl = document.getElementById("lbl");
			var w = obj.tagName?obj:document.getElementById(obj);			
			var wc = w.cloneNode(true);
			var windowFrameColor = wc.getAttribute("windowFrameColor")?wc.getAttribute("windowFrameColor"):null;
			var windowFrameOpacity = wc.getAttribute("windowFrameOpacity")?wc.getAttribute("windowFrameOpacity"):null;
			var windowHeaderClass = wc.getAttribute("headerClass")?wc.getAttribute("headerClass"):null;
			var windowContentClass = wc.getAttribute("contentClass")?wc.getAttribute("contentClass"):null;
			wc.removeAttribute("name");
			var f = document.createElement('div');
			var p = w.parentNode;
			f.className=w.getAttribute("frameClass")?w.getAttribute("frameClass"):"";
			f.id = w.id+"_ddwindow";
			f.innerHTML = dd_shadow2_temp;
			var cs = f.getElementsByTagName("td"); 
			for (j=0;j<cs.length;j++){
				if (cs[j].className=="dd_window_content") { // set content
					cs[j].innerHTML="";
					cs[j].appendChild(wc);
				}
				if (cs[j].className=="dd_window_top") { 
					cs[j].childNodes[0].innerHTML=w.getAttribute("header")?w.getAttribute("header"):""; // set header
					var cls = cs[j].childNodes[1]; // set close function
					cls.href="javascript:dx.hide('"+f.id+"')"; 
					w.getAttribute("closeButton")?w.getAttribute("closeButton")=="hide"?dx.isIE()?cls.style.display="none":cls.setAttribute("style", "display:none;"):null:null;
				}
				if (dx.isIE()) { // set CSS for IE
					if (cs[j].className=="dd_shadow_top") dx.ieTransparentPng(cs[j], "/images/shadows/shade_top.png");
					if (cs[j].className=="dd_shadow_left") dx.ieTransparentPng(cs[j], "/images/shadows/shade_left.png");
					if (cs[j].className=="dd_shadow_right") dx.ieTransparentPng(cs[j], "/images/shadows/shade_right.png");
					if (cs[j].className=="dd_shadow_bottom") dx.ieTransparentPng(cs[j], "/images/shadows/shade_bottom.png");
					if (cs[j].className=="dd_shadow_center") dx.ieTransparentPng(cs[j], "/images/shadows/shade_center.png");
					if (cs[j].className=="dd_shadow_topleft") dx.ieTransparentPng(cs[j], "/images/shadows/shade_topleft.png");
					if (cs[j].className=="dd_shadow_topright") dx.ieTransparentPng(cs[j], "/images/shadows/shade_topright.png");
					if (cs[j].className=="dd_shadow_bottomleft") dx.ieTransparentPng(cs[j], "/images/shadows/shade_bottomleft.png");
					if (cs[j].className=="dd_shadow_bottomright") dx.ieTransparentPng(cs[j], "/images/shadows/shade_bottomright.png");
				}
				
			}
			p.replaceChild(f, w);
			dx.isIE()?f.style.width=f.offsetWidth+"px":null; // dd_shadow's frame
			var e = f.childNodes[0].childNodes[0].childNodes[1].childNodes[1].childNodes[0]; // div.dd_shadow_content
			e.style.width= e.offsetWidth+"px";
			dx.isIE()?null:f.style.width=(e.offsetWidth+25)+"px"; // dd_shadow's frame
			var eh = e.childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[0]; //span header
			if (windowHeaderClass) eh.className = eh.className+" "+windowHeaderClass;
			var ec = e.childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[1]; //a close btn
			ec.style.right = "16px";
			var ei = e.childNodes[0].childNodes[0].childNodes[1].childNodes[1] // td window content
			if (windowContentClass) ei.className = ei.className+" "+windowContentClass;
			dx.setDdwindowFrameColor(e.childNodes[0].childNodes[0], windowFrameColor);
			dx.setDdwindowFrameOpacity(e.childNodes[0].childNodes[0], windowFrameOpacity);
			//lbl.innerHTML += (!obj.tagName)+";";			
}
dx.setDdwindowFrameColor = function(tbl, color){
	if (color) {
		tbl.childNodes[0].childNodes[0].style.background=color;
		tbl.childNodes[0].childNodes[1].style.background=color;
		tbl.childNodes[0].childNodes[2].style.background=color;
		tbl.childNodes[1].childNodes[0].style.background=color;
		tbl.childNodes[1].childNodes[2].style.background=color;
		tbl.childNodes[2].childNodes[0].style.background=color;
		tbl.childNodes[2].childNodes[1].style.background=color;
		tbl.childNodes[2].childNodes[2].style.background=color;
	}
}
dx.setDdwindowFrameOpacity = function(tbl, opacity){
	if (opacity) {
		tbl.childNodes[0].childNodes[0].style.opacity=opacity;
		tbl.childNodes[0].childNodes[1].style.opacity=opacity;
		tbl.childNodes[0].childNodes[2].style.opacity=opacity;
		tbl.childNodes[1].childNodes[0].style.opacity=opacity;
		tbl.childNodes[1].childNodes[2].style.opacity=opacity;
		tbl.childNodes[2].childNodes[0].style.opacity=opacity;
		tbl.childNodes[2].childNodes[1].style.opacity=opacity;
		tbl.childNodes[2].childNodes[2].style.opacity=opacity;
		
		tbl.childNodes[0].childNodes[0].style.mozopacity=opacity;
		tbl.childNodes[0].childNodes[1].style.mozopacity=opacity;
		tbl.childNodes[0].childNodes[2].style.mozopacity=opacity;
		tbl.childNodes[1].childNodes[0].style.mozopacity=opacity;
		tbl.childNodes[1].childNodes[2].style.mozopacity=opacity;
		tbl.childNodes[2].childNodes[0].style.mozopacity=opacity;
		tbl.childNodes[2].childNodes[1].style.mozopacity=opacity;
		tbl.childNodes[2].childNodes[2].style.mozopacity=opacity;
		
		var o = opacity*100;
		tbl.childNodes[0].childNodes[0].style.filter="alpha(opacity="+o+")";
		tbl.childNodes[0].childNodes[1].style.filter="alpha(opacity="+o+")";
		tbl.childNodes[0].childNodes[2].style.filter="alpha(opacity="+o+")";
		tbl.childNodes[1].childNodes[0].style.filter="alpha(opacity="+o+")";
		tbl.childNodes[1].childNodes[2].style.filter="alpha(opacity="+o+")";
		tbl.childNodes[2].childNodes[0].style.filter="alpha(opacity="+o+")";
		tbl.childNodes[2].childNodes[1].style.filter="alpha(opacity="+o+")";
		tbl.childNodes[2].childNodes[2].style.filter="alpha(opacity="+o+")";
	}
}
var dd_shadow2_temp = ''+
		'<table class="dd_shadow" cellpadding="0" cellspacing="0">' +
			'<tr>' +
				'<td class="dd_shadow_topleft"></td>' +
				'<td class="dd_shadow_top"></td>' +
				'<td class="dd_shadow_topright"></td>' +
			'</tr>' +
			'<tr>' +
				'<td class="dd_shadow_left"></td>' +
				'<td class="dd_shadow_center">' +
						'<div class="dd_shadow_content">' +
							'<table class="dd_window" cellpadding="0" cellspacing="0">' +
								'<tr class="dd_window_topbar">' +
									'<td class="dd_window_topleft"></td>' +
									'<td class="dd_window_top">' +
										'<span class="dd_window_header">my header</span>' +
										'<a href="javascript://" class="dd_window_close">x</a>' +
									'</td>' +
									'<td class="dd_window_topright"></td>' +
								'</tr>' +
								'<tr>' +
									'<td class="dd_window_left"></td>' +
									'<td class="dd_window_content">' +
										'<div id="inner" class="inner">' +
											'This is a dd_shadow2 template. Please do NOTE modify this file. Contact Danielli@belkin.com for detail.' +
										'</div>' +
									'</td>' +
									'<td class="dd_window_right"></td>' +
								'</tr>' +
								'<tr>' +
									'<td class="dd_window_bottomleft"></td>' +
									'<td class="dd_window_bottom"></td>' +
									'<td class="dd_window_bottomright"></td>' +
								'</tr>' +
							'</table>' +
						'</div>' +
				'</td>' +
				'<td class="dd_shadow_right"></td>' +
			'</tr>' +
			'<tr>' +
				'<td class="dd_shadow_bottomleft"></td>' +
				'<td class="dd_shadow_bottom"></td>' +
				'<td class="dd_shadow_bottomright"></td>' +
			'</tr>' +
		'</table>';
// Above codes for dd_window and dd_shadow

// ----------------------------------------------------------------//
// ---------------- end Daniel's js toolkits ----------------//
// ----------------------------------------------------------------//

// pop up windows ---------------------------------------------------------*
function MM_openBrWindow(theURL,winName,features){window.open(theURL,winName,features);}	
// end pop up windows -----------------------------------------------------*

// ----------------------------------------------------------------//
// ---------------- Belkin Left Nav --------------------------//
// ----------------------------------------------------------------//
var delaySec = 130; // default, 360 = 1 sec.var cssName = "sub";var cssNameHide = "sub hide";var liOverDelay;var liOverDelay2;var x7S = "";
var x7S2 = "";
var x7depth = 3;
// -------------------- layer 1
function x7(str) {if(x7S!=""){window.clearTimeout(liOverDelay);liOverDelay=window.setTimeout('_s7("'+str+'")',delaySec);}else{document.getElementById(str).className=cssName;x7S=str;} }
function _s7(str){document.getElementById(x7S).className=cssNameHide;x7S=str;document.getElementById(x7S).className=cssName;}
function x7H(str){if(x7S!=""){window.clearTimeout(liOverDelay);liOverDelay=window.setTimeout('_h7()',delaySec);}}
function _h7(){document.getElementById(x7S).className=cssNameHide;x7S="";}
// -------------------- layer 2
function x72(str) {if(x7S2!=""){window.clearTimeout(liOverDelay2);liOverDelay2=window.setTimeout('_s72("'+str+'")',delaySec);}else{document.getElementById(str).className=cssName;x7S2=str;}}
function _s72(str){document.getElementById(x7S2).className=cssNameHide;x7S2=str;document.getElementById(x7S2).className=cssName;}
function x7H2(str){if(x7S2!=""){window.clearTimeout(liOverDelay2);liOverDelay2=window.setTimeout('_h72()',delaySec);}}
function _h72(){document.getElementById(x7S2).className=cssNameHide;x7S2="";}
// -------------------- share
function x7getUlDepth(myId, n){var nDepth=0;do{nDepth++;n=n.parentNode.parentNode;}while(n.id!=myId)return nDepth;}
// -------------------- init
function leftNav(myId) {//var txt = document.getElementById("txt");txt.innerHTML = "test";
	var ul7 = document.getElementById(myId); 
	var uls  = ul7.getElementsByTagName("ul"); 
	ul7.className=dx.trim(ul7.className.replace("cssHover", "")); 
    	var ds = ul7.getAttribute("delaySec");
    	delaySec=(ds>0 && ds<9)?ds*360:delaySec;
	for (var i=0;i<uls.length;i++) {
		uls[i].id=myId+(i+1);
		var nDepth=x7getUlDepth(myId, uls[i]);
		if (nDepth == 1){
			var n=uls[i].parentNode;
			var a=n.childNodes[0];
			n.onmouseover=function(){x7(this.getElementsByTagName("ul")[0].id);};
			n.onmouseout=function(){x7H(this.getElementsByTagName("ul")[0].id);};	
			if(!a.href){a.href="javascript://";a.className="cursorDefault";};
		}else if (nDepth == 2){
			uls[i].parentNode.onmouseover=function(){x72(this.getElementsByTagName("ul")[0].id);};
			uls[i].parentNode.onmouseout=function(){x7H2(this.getElementsByTagName("ul")[0].id);};
		}
	}
}
// ----------------------------------------------------------------//
// ---------------- end belkin left nav ----------------------//
// ----------------------------------------------------------------//
