var fixpng = null;

function winOpen(f, n, w, h) {
  w = window.open(f,n,'width='+w+',height='+h+',left='+(screen.width/2-w/2)+',top='+(screen.height/2-h/2)+',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
  w.focus();
}
function winFlashOpen(f, n, w, h) {
  w = window.open(f,n,'width='+w+',height='+h+',left='+(screen.width/2-w/2)+',top='+(screen.height/2-h/2)+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');
  w.focus();
}

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 26 : 0;
var FFextraWidth=parseFloat(getFFVersion)>=0.1? 16 : 0;

function show_popup(a, n, w, h) {
	win = window.open(a.href+"&cb=1",n,'width='+w+',height='+h+',left='+(screen.width/2-w/2)+',top='+(screen.height/2-h/2)+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes');
	win.focus();		
}

document.loadedWindow = function(win) {
	var heightAdjust = 0;
	var widthAdjust = 0;
	
	if (win.contentDocument && win.contentDocument.body.offsetHeight) {
		heightAdjust = win.contentDocument.body.offsetHeight+FFextraHeight; 
	} else if (win.document && win.document.body.scrollHeight) {
		heightAdjust = win.document.body.scrollHeight+FFextraHeight;
	} else {
		heightAdjust = win.contentDocument.body.offsetHeight+FFextraHeight; 
	} 
	
	if (win.contentDocument && win.contentDocument.body.offsetHeight) {
		widthAdjust = win.contentDocument.body.offsetWidth;
	} else if (win.document && win.document.body.scrollHeight) {
		widthAdjust = win.document.body.scrollWidth;
	} else {
		widthAdjust = win.contentDocument.body.offsetWidth;
	} 			
	win.resizeTo(widthAdjust+FFextraWidth, heightAdjust+FFextraHeight);
}

// flash hack
var bo_ns_id = 0;
function startIeFix() {
    if (isIE()) {
        document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
    }
}

function endIeFix() {  
    if (isIE()) {
        document.write('</div>');
        var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
        var theCode = theObject.innerHTML;
        theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
        document.write(theCode);
    }
}

function isIE() {
    var strBrwsr= navigator.userAgent.toLowerCase();
    if (strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0) {
        if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6) {
            return false;
        }
        if (strBrwsr.indexOf("win98") > -1
        || strBrwsr.indexOf("win 9x 4.90") > -1
        || strBrwsr.indexOf("winnt4.0") > -1
        || strBrwsr.indexOf("windows nt 5.0") > -1) {
            return false;
        }
        return true;
    } else {
        return false;
    }
}

function change_class(element, className) {
	element.className = className;
}

function change_bg(element, bg) {
	element.style.backgroundColor = bg;
}

function send_form_ext(frmID, fld, val) {
	var eInput = document.createElement('input');
	eInput.type = 'hidden';
	eInput.name = fld;
	eInput.value = val;
	document.getElementById(frmID).appendChild(eInput);
	send_form(frmID);
}

function send_form(frmID) {
	document.getElementById(frmID).submit();
}

function do_send_form(frmID, e) {
	if(submitRequest(e))
		send_form(frmID);
}


function submitRequest(e) {
	var characterCode
	if(e && e.which){
	e = e;
	characterCode = e.which;
	}
	else{
	e = event;
	characterCode = e.keyCode;
	}
	return (characterCode == 13);
}
function save_scroll_link(a) {
	a.href=a.href + "&yscroll=" + getYScroll() + "&xscroll=" + getXScroll();
}

function save_scroll_form(form)  {
	if (navigator.appName == "Microsoft Internet Explorer") {
		scroll_top = document.body.scrollTop;
	} else{
		scroll_top = window.pageYOffset;          
	}
	
	$(form.id + "_yscroll").value = getYScroll();
	$(form.id + "_xscroll").value = getXScroll();
}

function loadScroll(x, y) {
	window.scrollTo(x,y);
}		

function getYScroll() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		return document.body.scrollTop;
	} else{
		return window.pageYOffset;          
	}			
}

function getXScroll() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		return document.body.scrollLeft;
	} else{
		return window.pageXOffset;          
	}			
}

function adjustScrollBy(xAdjust, yAdjust) {
	var xScroll = getXScroll();
	var yScroll = getYScroll();
	if(xAdjust>0)
		xScroll += xAdjust;
	if(yAdjust>0)
		yScroll += yAdjust;
		
	window.scrollTo(xScroll,yScroll);
}var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixpng() {
	if ((version >= 5.5) ) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      //alert(img.src);
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	      {	      
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
	}
}