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);
}
