/* ----------------------------------------------------------------------------------------------------
 *	Daonsoft Publishing.Div
 * Author	: 2008-08-02 by 2dea
 * Descript	: 2dea Common Script
 * Last Edit+	: 2009-06-14 by 2dea
 ---------------------------------------------------------------------------------------------------- */

//	top.document.title = "2dea.com";

function about(url,w,h,s) {
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	x = (windowWidth-w)/2
	y = (windowHeight-h)/1.25

	//window.open(url,"_blank","left="+x+",top="+y+",width="+w+",height="+h+",scrollbars="+s+",resizable=0,status=1");
	window.open(url,"_blank","width="+w+",height="+h+",scrollbars="+s+",resizable=0,status=1");
}

function aboutFull(url) {
	window.open(url,"_blank","fullscreen");
}

function flash(url,id,w,h) {
	var embed = "";
	embed = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="'+id+'" width="'+w+'" height="'+h+'">';
	embed += '	<param name="movie" value="'+url+'" \/>';
	embed += '	<param name="quality" value="high" \/>';
	embed += '	<param name="bgcolor" value="#FFFFFF" \/>';
	embed += '	<param name="wmode" value="transparent" \/>';
	embed += '	<param name="menu" value="false" \/>';
	embed += '	<param name="allowScriptAccess" value="sameDomain" \/>';
	embed += '	<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" name="'+id+'" src="'+url+'" width="'+w+'" height="'+h+'" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" allowScriptAccess="sameDomain"><\/embed>';
	embed += '<\/object>';

	document.write(embed);
}

function media(url,id,w,h,autostart) {
	var embed = "";
	embed = '<object type="application/x-oleobject" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=6,4,7,1112" id="'+id+'" name="'+id+'" width="'+w+'" height="'+h+'" standby="Loading Windows Media Player components...">';
	embed += '	<param name="url" value="'+url+'" \/>';
	embed += '	<param name="autostart" value="'+autostart+'" \/>';
	embed += '	<param name="autosize" value="0" \/>';
	embed += '	<embed type="application/x-mplayer2" name="'+id+'" id="'+id+'" src="'+url+'" width="'+w+'" height="'+h+'" autostart="'+autostart+'" autosize="0"><\/embed>';
	embed += '<\/object>';

	document.write(embed);
}

function E(param) {
	return document.getElementById(param);
}

function imgOvr(id) {
	var obj = document.getElementById(id);
	obj.src = obj.src.replace('.gif','_on.gif');
}

function imgOut(id) {
	var obj = document.getElementById(id);
	obj.src = obj.src.replace('_on.gif','.gif');
}

function imgRoll(obj) {
	if (obj != "undefined" && obj.tagName == "A") {
		var childObj = obj.childNodes;
		if (childObj[0].tagName == "IMG") {
			var tempSrc = childObj[0].src;
			if (tempSrc.indexOf('_or.gif') != -1) {
				childObj[0].src = tempSrc.replace('_or.', '_on.');
			}
			else {
				childObj[0].src = tempSrc.replace('_on.', '_or.');
			}
		}
	}
}

function imgElse(obj) {
	if (obj != "undefined" && obj.tagName == "A") {
		var childObj = obj.childNodes;
		if (childObj[0].tagName == "IMG") {
			var tempSrc = childObj[0].src;
			if (tempSrc.indexOf('_off.gif') != -1) {
				childObj[0].src = tempSrc.replace('_off.', '_on.');
			}
			else {
				childObj[0].src = tempSrc.replace('_on.', '_off.');
			}
		}
	}
}

function imgSwap(oImg) {
	var strOver  = "_on."
	var strOff = "_or."
	var strImg = oImg.src
	if (strImg.indexOf(strOver) != -1)
		oImg.src = strImg.replace(strOver,strOff)
	else
		oImg.src = strImg.replace(strOff,strOver)
}

function newSwap(obj) {
    if (obj != "undefined" && obj.tagName == "A") {
        var childObj = obj.childNodes;
        if (childObj[0].tagName == "IMG") {
            var strOn = "_on."
            var strOr = "_or."
            var tempSrc = childObj[0].src;
            if (tempSrc.indexOf(strOr) != -1) {
                childObj[0].src = tempSrc.replace(strOr, strOn);
            }
            else {
                childObj[0].src = tempSrc.replace(strOn, strOr);
            }
        }
    }
}

function tabMain(dotabid,num) {
	var inum=parseInt(num)-1;
	var linkTab=document.getElementById(dotabid).getElementsByTagName("h4");
	for (i=0;i<linkTab.length;i++) {
		var tabimg = linkTab.item(i).getElementsByTagName("img").item(0);
		var tabContents= document.getElementById(dotabid+(1+i));
		if (i==inum) {
			if(tabContents.style.display!="block") {
				tabimg.src=tabimg.src.replace(".gif","_on.gif");
				tabContents.style.display="block";
			}
		} else {
			tabimg.src=tabimg.src.replace("_on.gif",".gif");
			tabContents.style.display="none";
		}
	}
}

function tabMain2011(dotabid,num) {
	var inum=parseInt(num)-1;
	var linkTab=document.getElementById(dotabid).getElementsByTagName("h3");
	for (i=0;i<linkTab.length;i++) {
		var tabimg = linkTab.item(i).getElementsByTagName("img").item(0);
		var tabContents= document.getElementById(dotabid+(1+i));
		if (i==inum) {
			if(tabContents.style.display!="block") {
				tabimg.src=tabimg.src.replace(".gif","_on.gif");
				tabContents.style.display="block";
			}
		} else {
			tabimg.src=tabimg.src.replace("_on.gif",".gif");
			tabContents.style.display="none";
		}
	}
}

function tabMenu(dotabid,num) {
	var inum=parseInt(num)-1;
	var linkTab=document.getElementById(dotabid).getElementsByTagName("li");
	for (i=0;i<linkTab.length;i++) {
		var tabimg = linkTab.item(i).getElementsByTagName("img").item(0);
		var tabContents= document.getElementById(dotabid+(1+i));
		if (i==inum) {
			if(tabContents.style.display!="block") {
				tabimg.src=tabimg.src.replace(".gif","_on.gif");
				tabContents.style.display="block";
			}
		} else {
			tabimg.src=tabimg.src.replace("_on.gif",".gif");
			tabContents.style.display="none";
		}
	}
}

function txtMenu(dotabid,num) {
	var inum=parseInt(num)-1;
	var linkTab=document.getElementById(dotabid).getElementsByTagName("li");
	for (i=0;i<linkTab.length;i++) {
		var tabContents= document.getElementById(dotabid+(1+i));
		if (i==inum) {
			if(tabContents.style.display!="block") {
				linkTab.item(inum).className="focus";
				tabContents.style.display="block";
			}
		} else {
			linkTab.item(i).className="";
			tabContents.style.display="none";
		}
	}
}

function floatLayer(target,position,topLimit,btmLimit) {
	if (!target)
		return false;
	var obj = document.getElementById(target);
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;
	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;
	if (typeof(window.pageYOffset) == "number") {
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return document.documentElement.scrollTop;
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}
	if (self.innerHeight) {
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}
	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop() + obj.initTop;
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}
		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;
		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + "px";
	}, 10)
}

var elem = "tr";
var rClick;
function rowHiligh() {
	if(document.getElementsByTagName) {
		var el = document.getElementsByTagName(elem);
		for(var i=0; i<el.length; i++) {
			if(el[i].childNodes[0].tagName != "th"
			&& el[i].parentNode.parentNode.className.indexOf("list") != -1) {
				if (!(el[i].className == "notice" || el[i].className == "first-child notice")) {	//if (el[i].className != "notice") {
					if(i%2 == 1) {
						el[i].className = "first";
						el[i].oldClassName = "first";
						el[i].onmouseout  = function() {
							this.className = "first";
						}
					}
					else {
						el[i].className = "second";	//el[i].className = el[i].className+" second";
						el[i].oldClassName = "second";
						el[i].onmouseout  = function() {
							this.className = "second";
						}
					}
				}
				el[i].onmouseover = function() {
					if(!(this.className == "notice" || this.className == "first-child notice")) {	//if(this.className != "notice") {
						if(this.className == this.oldClassName) {
							this.className = "hover";
						}
						else if(this.onmouseout == null && this.className != "click") {
							this.onmouseout = function() {
								this.className = this.oldClassName;
							}
						}
					}
				}
/*				el[i].onclick = function() {
					if(!(this.className == "notice" || this.className == "first-child notice")) {	//if(this.className != "notice") {
						if(this.className != "click") {
							this.className = "click";
						}
						else {
							this.className = this.oldClassName;
						}
						this.onmouseout = null;
					}
				}*/
			}
		}
	}
}

var key = false;
function clearText(id) {
	if (!key) {
		document.getElementById(id).value='';
		key = true;
	}
}
function clearValue(id) {
	document.getElementById(id).style.backgroundImage='none';
}

function magicPop(id) {
	var obj = document.getElementById(id);
	if(obj) {
		if(obj.style.display == 'block') {
			document.getElementById('magic').className='none';
			obj.style.display='none';
		} else {
			document.getElementById('magic').className='show';
			obj.style.display='block';
		}
	}
}

function autoResize(i) {
	var iframeHeight=
	(i).contentWindow.document.body.scrollHeight;
	(i).height=iframeHeight+20;
}

function labelCheck(obj,id) {
    if (navigator.appVersion.indexOf('MSIE') != -1) {
        if (obj && obj.tagName == "LABEL") {
            var childObj = obj.childNodes;
            if (childObj[0].tagName == "IMG") {
                if (document.getElementById(id).type == "checkbox" || document.getElementById(id).type == "radio" || document.getElementById(id).type == "file") {
                    document.getElementById(id).click();
                }
                else {
                    document.getElementById(id).focus();
                }
            }
        }
    }
}

