/* png img transparent */
function setPng24(obj) {
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');

	obj.style.filter =

	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src='';
	return '';
}

/* flash link */
function render_flash(swf_name,swf_width,swf_height){
	var text ='';
	text ='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+swf_width+'" height="'+swf_height+'">';
	text +='<param name="movie" value="'+swf_name+'">';
	text +='<param name="allowScriptAccess" value="always">';
	text +='<param name="quality" value="high">';
	text +='<embed src="'+swf_name+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+swf_width+'" height="'+swf_height+'">';
	text +='<param name="wmode" value="transparent">';
    	text +='</embed>';
	text +='</object>';
	document.write(text);
}

/* menu flash */
function MenuFlash( id, flashUri, param, vWidth, vHeight, winMode ) {
	var _obj_ = "";
	_obj_ = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	_obj_ += '<param name="movie" value="' + flashUri + '" />';
	_obj_ += '<param name="quality" value="high" />';
	_obj_ += '<param name="wmode" value="' + winMode + '" />    ';
	_obj_ += '<param name="FlashVars" value="' + param + '" />    ';
	_obj_ += '<param name="bgcolor" value="#ffffff" />        ';
	_obj_ += '<embed src="' + flashUri + '" quality="high" wmode="' + winMode + '" bgcolor="#ffffff" width="' + vWidth +'" height="' + vHeight + '" id="' + id + '" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>    ';
	_obj_ += '</object>';
	document.writeln( _obj_ );
}

/* popup */
function windowOpen(url, name, width, height, scrollbars, top, left){
	window.open(url,name,'width='+width+',height='+height+',scrollbars='+scrollbars+',top='+top+',left='+left+',history=no,resizable=no,status=no,menubar=no');
}

/* change class */
function changeOverRowClass(elId, tagName, searchClass) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);

	for (i=0; i<el.length; i++) {
		if (el[i].className == searchClass || el[i].className == searchClass + " on") {
			el[i].onmouseover = changeOverRowClassOver;
			el[i].onmouseout = changeOverRowClassOut;
		}
	}
}
function changeOverRowClassOver() {
	if (this.className == "") {
		this.className = this.className + " on";
	} else {
		this.className = "on";
	}
}
function changeOverRowClassOut() {
	if (this.className == "on") {
		this.className = "";
	} else {
		this.className = this.className.replace(" on", "");
	}
}

/* rolloverimg */
function changeOverImg(elId,tagName) {
    var el = document.getElementById(elId).getElementsByTagName(tagName);
    for (i=0; i<el.length; i++) {
            if (el[i].src.substring(el[i].src.indexOf(".gif"))
                ||el[i].src.substring(el[i].src.indexOf("_on.gif"))) {
                el[i].onmouseover = changeOver;
                el[i].onmouseout = changeOut;
        }
    }
}
function changeOver() {
    this.src=this.src.replace(".gif", "_on.gif");
}
function changeOut() {
    this.src=this.src.replace("_on.gif", ".gif");
}

/* inline rolloverimg */
function menuOn(imgEl) {
    imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}
function menuOut(imgEl) {
    imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}

/* Tab Contents */
function initTabMenu(tabContainerID) {
    var tabContainer = document.getElementById(tabContainerID);
    var tabAnchor = tabContainer.getElementsByTagName('a');
    var i = 0;
    for(i=0; i<tabAnchor.length; i++) {
        if (tabAnchor.item(i).className == "tab")
            thismenu = tabAnchor.item(i);
        else
            continue;
        thismenu.container = tabContainer;
        thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
        thismenu.targetEl.style.display = "none";
        thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
        thismenu.onclick = function tabMenuClick() {
            currentmenu = this.container.current;
            if (currentmenu == this)
                return false;
            if (currentmenu) {
                currentmenu.targetEl.style.display = "none";
                if (currentmenu.imgEl) {
                    currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
                } else {
                    currentmenu.className = currentmenu.className.replace(" on", "");
                }
            }
            this.targetEl.style.display = "";
            if (this.imgEl) {
                this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
            } else {
                this.className += " on";
            }
            this.container.current = this;
            return false;
        };
        if (!thismenu.container.first)
            thismenu.container.first = thismenu;
    }
    if (tabContainer.first)
        tabContainer.first.onclick();
}

/* Tab Contents1 */
function initTabMenu1(tabContainerID) {
    var tabContainer = document.getElementById(tabContainerID);
    var tabAnchor = tabContainer.getElementsByTagName('a');
    var i = 0;
    for(i=0; i<tabAnchor.length; i++) {
        if (tabAnchor.item(i).className == "tab")
            thismenu = tabAnchor.item(i);
        else
            continue;
        thismenu.container = tabContainer;
        thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
        thismenu.targetEl.style.display = "none";
        thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
        thismenu.onclick = function tabMenuClick() {
            currentmenu = this.container.current;
            if (currentmenu == this)
                return false;
            if (currentmenu) {
                currentmenu.targetEl.style.display = "none";
                if (currentmenu.imgEl) {
                    currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
                } else {
                    currentmenu.className = currentmenu.className.replace(" on", "");
                }
            }
            this.targetEl.style.display = "";
            if (this.imgEl) {
                this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
            } else {
                this.className += " on";
            }
            this.container.current = this;
            return false;
        };
      //  if (!thismenu.container.first)
            thismenu.container.first = thismenu;
    }
    if (tabContainer.first)
        tabContainer.first.onclick();
}

/* displayToggle */
function displayToggle(arg) {
	obj = document.getElementById(arg);
	if(obj.style.display == "block") obj.style.display = "none";
	else obj.style.display = "block";
}

/* definition list toggle */
function initToggle(tabContainer) {
	triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		if (triggers.item(i).href.split("#")[1])
			triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);

		if (!triggers.item(i).targetEl)
			continue;

		triggers.item(i).targetEl.style.display = "none";
		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";
				}
				this.targetEl.style.display = "block";
				tabContainer.current = this;
			}
		}
	}
}

/* quickmenu */
function initMoving(target, position, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = 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;

		//var toggle = document.toggle_form.quick_toggle.value;
		var toggle = getCookie('toggle');

		if(toggle=='on'){
			obj.top = obj.top - interval / 3;
		}
		else if(toggle=='off'){
			obj.top = 66;
		}
		obj.style.top = obj.top + "px";
	}, 30)
}

function quickmenu_toggle(toggle){
	//document.toggle_form.quick_toggle.value = toggle;
	setCookie('toggle', toggle);
}


function setCookie(key, value, expiredays){
	var exdate = new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie = key + "=" + escape(value) +
	((expiredays==null)? "" : ";expires="+exdate.toGMTString());
}

function getCookie(key){
	if(document.cookie.length>0){
		var start = document.cookie.indexOf(key+"=");
		var end;
		if(start!=-1){
			start += key.length+1;
			end = document.cookie.indexOf(";", start);
			if(end==-1)end=document.cookie.length;
			return unescape(document.cookie.substring(start, end));
		}
	}
	return "";
}

function ReadCookie(name) {
	var label = name + "=";
	var labelLen = label.length;
	var cLen = document.cookie.length;
	var i = 0;

	while (i < cLen) {
	var j = i + labelLen;
	if (document.cookie.substring(i, j) == label) {
		var cEnd = document.cookie.indexOf(";", j);
		if (cEnd == -1) cEnd = document.cookie.length;
			return unescape(document.cookie.substring(j, cEnd));
		}
		i++;
	}
	return "";
}
function WriteCookie(name, value)
{
	 document.cookie = name + "=" + escape( value ) + "; path=/; ";
}


