<!--

var menu_timer = setTimeout("hide_menu()", 1000);
var menu_timers = new Object();
var ua = navigator.userAgent.toLowerCase();
var isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1));
var ns4 = false;
var op5 = false;

function dbg()
{
  if (!("console" in window))
  {
    return;
  }

  if(navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1)
  {
    console.log('<<<');
    for (var i = 0; i < arguments.length; i++)
    {
      console.log(arguments[i]);
    }
    console.log('>>>');
  }
  else
  {
    console.log.apply(this, arguments);
  }
}

function dbge(m, err)
{
  if (!("console" in window))
  {
    return;
  }
  console.error(m + "\n", err.message+"\n"+err.fileName+":"+err.lineNumber + "\n", err);
}

function menu_over(id){
	show_menu(id);
	//if (menu_timer != undefined){
		clearTimeout(menu_timers[id]);
	//}
}

function menu_out(id, timeout){
	if (timeout == undefined){
		timeout = 500;
	}
	menu_timers[id] = setTimeout("hide_menu('"+id+"')", timeout);

}

function show_menu(id){
	if (!document.getElementById || !document.getElementById(id))
		return false;
	m = document.getElementById(id);
	m.style.visibility = 'visible';
	hideIESelects();
}

function hideIESelects(){
	if (isIE){
		selects = document.getElementsByTagName('select');
		for (var i in selects){
			if (selects[i] && selects[i].style)
				selects[i].style.visibility = 'hidden';
		}
	}
}

function hide_menu(id){
	if (!document.getElementById || !document.getElementById(id))
		return false;
	m = document.getElementById(id);
	m.style.visibility = 'hidden';
	showIESelects();
}

function showIESelects(){
	if (isIE){
		selects = document.getElementsByTagName('select');
		for (var i in selects){
			if (selects[i] && selects[i].style)
				selects[i].style.visibility = 'visible';
		}
	}
}
	
//shows el1 and hides el2 - or the other way round
function display_alternative(id, name){
	if (!document.getElementById
		|| document.getElementById(name+id) == undefined)
		return false;
	var el1, el2;
	el1 = document.getElementById(name+id);
	el2 = document.getElementById(name+'_s_'+id);

	if (el1 == undefined || el1.style == undefined || el1.style.display == undefined)
		return false;

	if (el2 == undefined || el2.style == undefined || el2.style.display == undefined)
		return false;

	if (el1.style.display == 'none'){
		el1.style.display = 'block';
		el2.style.display = 'none';
	} else {
		el1.style.display = 'none';
		el2.style.display = 'block';
	}
	return true;
}

var first_style = '';
function display_style_all(el_prefix, t_prefix, i_prefix, a_prefix, i_opened_src, i_closed_src){
	first_style = '';
	display_style(1, el_prefix, t_prefix, i_prefix, a_prefix, i_opened_src, i_closed_src, true);
	this_current_style = first_style;
	for (i = 2; i<1000; i++){
		if (document.getElementById(el_prefix+i)){
			display_style(i, el_prefix, t_prefix, i_prefix, a_prefix, i_opened_src, i_closed_src, this_current_style);
		} else {
			first_style = '';
			break;
		}
	}
}

function display_style(id, el_prefix, t_prefix, i_prefix, a_prefix, i_opened_src, i_closed_src, current_style){

	if (!document.getElementById
		|| document.getElementById(el_prefix+id) == undefined)
		return false;
	var el, t, i, a;
	el = document.getElementById(el_prefix+id);

	if (el == undefined || el.style == undefined || el.style.display == undefined)
		return false;

	if (t_prefix != undefined && t_prefix != '') t = document.getElementById('t'+id);
	if (i_prefix != undefined && i_prefix != '') i = document.getElementById(i_prefix+id);
	if (a_prefix != undefined && a_prefix != '') a = document.getElementById('a'+id);
	if (current_style != 'block' && (el.style.display == 'none' || current_style == 'none')){
		first_style = 'none';
		if (el != undefined) el.style.display = 'block';
		if (t != undefined) {
			t.style.backgroundColor = '#215aa5';
			t.style.color = 'white';
		}
		if (i != undefined) i.src = i_opened_src;
		if (a != undefined){
			a.style.backgroundColor = '#215aa5';
			a.style.color = 'white';
		}
	} else {
		first_style = 'block';
		if (el != undefined) el.style.display = 'none';
		if (t != undefined){
			t.style.backgroundColor = '#dddddd';
			t.style.color = '#333333';
		}
		if (i != undefined) i.src = i_closed_src;
		if (a != undefined){
			a.style.backgroundColor = '#dddddd';
			a.style.color = '#333333';
		}
	}
	return true;
}

function move_option_up(s){
	List = s.options;
	index = List.selectedIndex ;
	if( index == -1 ) return ;

	if( index > 0 ) {
		prev = new Option( List[ index - 1 ].text,  List[ index - 1 ].value );
		prev.onclick = List[ index - 1 ].onclick;
		current = new Option( List[ index ].text, List[ index ].value );
		current.onclick = List[ index ].onclick;
		List[ index - 1 ] = current ;
		List[ index ] = prev ;
		List[ index - 1 ].selected = true;
	} // index > 0
}

function move_option_down(s){
	var List = s.options;
	index = List.selectedIndex ;
	if( index == -1 ) return ;
	
	if( index < List.length - 1 ) {
		next = new Option( List[ index + 1 ].text,  List[ index + 1 ].value );
		next.onclick = List[ index + 1 ].onclick;
		current = new Option( List[ index ].text, List[ index ].value );
		current.onclick = List[ index ].onclick;
		List[ index + 1 ] = current; 
		List[ index ] = next ; 
		List[ index + 1 ].selected = true;
	} // index < List.options.length
}

function general_build_all_values(gbav_f, gbav_s, gbav_h){
	separator = '|';
	allv_select = gbav_f[gbav_s];
	allv = allv_select.options;
	allValues = '';
	for (i=0; i<allv.length;i++){
		allValues += allv[i].value+separator;
		//alert(allv[i].value);
	}
	allValues = allValues.substring(0,allValues.length-1);
	gbav_f[gbav_h].value = allValues;
}

function setCookie(name, value, expires, path, domain, secure)
{
	document.cookie= name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else
	{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	{
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
	if (getCookie(name))
	{
		document.cookie = name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function sw_collapse(){
	setCookie('learn_more', 'n');
	if (!document.getElementById || !document.getElementById('x'))
		return false;
	document.getElementById('x').style.display='none';
	document.getElementById('y').style.display='block';
}

function sw_expand(){
	setCookie('learn_more', 'y');
	if (!document.getElementById || !document.getElementById('x'))
		return false;
	document.getElementById('y').style.display='none';
	document.getElementById('x').style.display='block';
}

function sw_check_state(){
	sw_expand();return;
	learn_more_cookie = getCookie('learn_more');
	if (learn_more_cookie == undefined || learn_more_cookie == 'y')
		sw_expand();
	else
		sw_collapse();
	return;
}

function win_open(url, name, win_maximize, win_focus, w, h){
	if (win_maximize == undefined) win_maximize = false;
	if (win_focus == undefined) win_focus = true;
	var default_width = 800;
	if (w != undefined){
		default_width = w;
	}

	var default_height = 550;
	if (h != undefined){
		default_height = h;
	}
	param = 'width='+default_width+', height='+default_height+', location=0, menubar=0, status=0, scrollbars=1, resizable=1';
	opened_win = window.open(url, name, param);

	if (win_focus)
		opened_win.focus();

    //alert(opened_win);
	if (win_maximize){
        maximizeWindow(opened_win);
	} else {
        centerWindow(opened_win);
	}
	return true;
}

function maximizeWindow(opened_win){
    var max_win_width = 1024;
    var win_width = (screen.width > max_win_width)?max_win_width:screen.width;
    var win_x = (screen.width - win_width)/2;
    opened_win.moveTo(win_x,0);
    opened_win.resizeTo(win_width, screen.height-30);
}
function centerWindow(opened_win){
    if (opened_win == undefined){
        opened_win = window;
    }
    var s = windowSize(opened_win);
    var win_x = (screen.width - s.w)/2;
    var win_y = (screen.height - s.h)/2;
    opened_win.moveTo(win_x,win_y);
}

function window_resize(new_w, new_h){
	var win_x = (screen.width - new_w)/2;
	var win_y = (screen.height - new_h)/2;
	window.moveTo(win_x,win_y);
	window.resizeTo(new_w,new_h);
}

function popup_close(new_location){
	if (window.opener && !window.opener.closed){
		window.close();
		window.opener.document.location = new_location;
		return true;
	} else {
		document.location = new_location;
		return false;
	}
}

function my_alert(){
	if (!document.getElementById('alerter_div')){
		alerter = document.createElement('div');
		alerter.id = 'alerter_div';
		document.body.appendChild(alerter);
	} else {
		var alerter = document.getElementById('alerter_div');
	}
	to_put = '';
	len = arguments.length;
	for (j=0; j<len && j < 5; j++){
		to_put+= '|'+arguments[j];
	}
	alerter.innerHTML = to_put+'\n<br>'+alerter.innerHTML;
}

function checkboxes_select(local_f, checker, to_check_name){
	if (checker.checked) new_val = true;
	else new_val = false;
	//my_alert(local_f.elements['delete_id[]'].length);
    if (local_f.elements[to_check_name] == undefined){
        for (i=0; i<local_f.elements.length; i++){
            if (local_f.elements[i].name.indexOf(to_check_name) != -1){
                local_f.elements[i].checked = new_val;
            }
        }
    } else {
        for (i=0; i<local_f.elements[to_check_name].length; i++){
            local_f.elements[to_check_name][i].checked = new_val;
        }
    }
}

function checkboxesAllWatch(local_f, checker, to_check_name){
	checker.backupOnClick = checker.onclick;
	checker.onclick = function(oc){
		if (!isIE){
			if (oc.backupOnClick != null){
				oc.backupOnClick.call();
			}
		} else {
			if (event.src.backupOnClick != null){
				event.src.backupOnClick.call();
			}
		}
		checkboxes_select(local_f, checker, to_check_name);
	}
	var els = local_f.elements[to_check_name];
	var l = els.length;
	for (var i = 0; i < l; i++){
		checker.backupOnClick = checker.onclick;
		els[i].onclick = function(oc){
			if (!isIE){
				if (oc.backupOnClick != null){
					oc.backupOnClick.call();
				}
			} else {
				if (event.src.backupOnClick != null){
					event.src.backupOnClick.call();
				}
			}
			checkIfAllRSelected(local_f, checker, els);
		}
	}

    if (checker.checked){
        for (var i = 0; i < l; i++){
            els[i].checked = true;
        }
    }
}

function checkIfAllRSelected(local_f, checker, els){
	var allSelected = true;
	var l = els.length;
	for (var i = 0; i < l; i++){
		if (!els[i].checked){
			allSelected = false;
			break;
		}
	}

	if (allSelected){
		checker.checked = true;
	} else {
		checker.checked = false;
	}
}

function overflow_handle(d){
	if (d.style.width == '1px'){
		//d.style.overflow = 'visible';
		d.style.width = '600px';
		d.style.height= '600px';
	} else {
		//d.style.overflow = 'scroll';
		d.style.width = '1px';
		d.style.height = '1px';
	}
}

function wb_slide_form(what_show, id){
	if (what_show == 'picture'){
		what_hide1 = 'url';
		what_hide2 = 'poll';
	} else if (what_show == 'url') {
		what_hide1 = 'picture';
		what_hide2 = 'poll';
	} else if (what_show == 'poll'){
		what_hide1 = 'picture';
		what_hide2 = 'url';
	}
	document.getElementById('tr'+id+what_hide1).style.display = "none";
	document.getElementById('tr'+id+what_hide2).style.display = "none";
	if (isIE){
		document.getElementById('tr'+id+what_show).style.display = "block";
	} else {
		document.getElementById('tr'+id+what_show).style.display = "table-row";
	}
}

function wb_change_slide_div(s){
	idx = s.selectedIndex;
	i = s[idx].value;
	d = document.getElementById('wb_slide_th');
	if (slide_type[i] == 'url'){
		d.innerHTML = '<a href"'+url[i]+'" target="_blank">'+url[i]+'</a>';
	} else if (slide_type[i] == 'picture') {
		d.innerHTML = '<img src="'+th_url[i]+'">';
	} else if (slide_type[i] == 'poll') {
		d.innerHTML = '';
	}
}

var ev_last_checked = 0;
function ev_check_refresh(){
	if (ev_last_checked == 0){
		ev_last_checked = window.setTimeout(ev_do_refresh, 1000*60*5);
	}
}

function ev_do_refresh(){
	r = document.getElementById('ev_refresher');
	//alert(r);
	for (i in r){
		//my_alert(i+'|'+r[i]);
	}
	if (r != undefined){
		r.src = 'refresh.php';
	}
	ev_last_checked = 0;
}


var refreshTimeout;
function sessionRefreshStart(){
  dbg('setTimeout '+document.location.href);
	refreshTimeout = window.setTimeout(function()
    {
      sessionRefreshAsk();
    }, 1000*60*110);
}
function sessionRefreshAsk(){
  dbg(arguments.callee.caller.caller);
  dbg('timeout expired (?) '+document.location);
  dbg(glsDbg.getStackTrace());
	if (window.confirm(sessionAskString)){
		xajax_refreshSession();
		sessionRefreshStart();
	} else {
		sessionRefreshStart();
	}
}
function sessionAnswer(username){
	if (username == ''){
		if (window.confirm(sessionLoggedOut)){
			clearTimeout(refreshTimeout);
			sessionCreateLoginIframe();
		}
	}
}
function sessionCreateLoginIframe(){
	if (document.body.scroll != undefined){
		document.body.scroll = "no";
	} else {
		document.body.style.overflow = 'hidden';
	}
	var d = document.getElementById('loginIfrDiv');
	d.style.visibility = 'visible';
	d.style.display = 'block';
	if (evUser){
		d.innerHTML = '<iframe style="position:absolute;" id="loginIfr" src="login.php?expired=1"></iframe>';
	} else {
		d.innerHTML = '<iframe style="position:absolute;" id="loginIfr" src="../login/index.php?expired=1"></iframe>';
	}
	d.style.top = document.body.scrollTop;
}

Array.prototype.inArray = function (value)
// Returns true if the passed value is found in the
// array.  Returns false if it is not.
{
    var i;
    for (i=0; i < this.length; i++) {
        // Matches identical (===), not just similar (==).
        if (this[i] === value) {
            return true;
        }
    }
    return false;
};

function writePlayerSWF(flvFile, autoPlay){
	var swfDiv = document.getElementById('playerDiv');
	if (flvFile != '' && flvFile != undefined){
		if (isIE){
			CreateControl('playerDiv', 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000', 'player', 323, 346, '../blogger/swf/player.swf', true);
				/*
			swfDiv.outerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="323" height="346" id="player" align="middle">'+
				'<param name="allowScriptAccess" value="sameDomain" />'+
				'<param name="movie" value="../blogger/swf/player.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'+
				'<embed FlashVars="flv_path='+flvFile+'&autoPlay='+autoPlay+'" src="../blogger/swf/player.swf" quality="high" bgcolor="#f4f3f3" width="340" height="346" name="player" align="middle" allowScriptAccess="sameDomain" swliveconnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
				'</object>'+
				'';
				*/
		} else {
			swfDiv.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="323" height="346" id="player" align="middle">'+
				'<param name="allowScriptAccess" value="sameDomain" />'+
				'<param name="movie" value="../blogger/swf/player.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'+
				'<embed FlashVars="flv_path='+flvFile+'&autoPlay='+autoPlay+'" src="../blogger/swf/player.swf" quality="high" bgcolor="#f4f3f3" width="340" height="346" name="player" align="middle" allowScriptAccess="sameDomain" swliveconnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
				'</object>'+
				'';
		}
	} else {
		swfDiv.innerHTML = '';
	}
		
}

function CreateControl(DivID, CLSID, ObjectID, WIDTH, HEIGHT, URL, AUTOSTART)
{
	var CCd = document.getElementById(DivID);
	var myObject = document.createElement('object');
	CCd.appendChild(myObject);
	myObject.width = WIDTH;
	myObject.height = HEIGHT;
	myObject.classid = CLSID;
	myObject.URL = URL;
	myObject.uiMode = "none";
	/*
	CCd.innerHTML = '<object classid=' + CLSID + ' id=' + ObjectID + 
		' width=' + WIDTH + ' height=' + HEIGHT +'>'+
		'<param name="URL" value=' + URL + '>'+
		'<param name="autoStart" value=' + AUTOSTART + '/>';
		*/
}

function setCSSProperty(name, property, value){
	var sCSSPN = document.getElementById(name);
	sCSSPN.style[property] = value;
}

function TextareaMaxLength(t){
	var max = t.getAttribute ? parseInt(t.getAttribute("maxlength")) : 0;
	if (t.getAttribute && t.value.length>max){
		t.value = t.value.substring(0,max);
	}

	if (document.getElementById){
		var b = document.getElementById(t.name+'_count');
		if (b == null){
			return;
		}
		b.innerHTML = max - t.value.length;
	}
}

function profilesHiddenUpdate(listID, formInput, prefix) {
	if (prefix == null){ prefix = 'f'; }
	var list = document.getElementById(listID);
	var items = list.getElementsByTagName("li");
	var itemIDs = "";
	var prefL = prefix.length;
	for (var i = 0; i < items.length; i++) {
		if (itemIDs.length > 0) itemIDs += "|";
		var thisID = items[i].getAttribute("id");
		if(thisID == undefined){
			continue;
		}
		thisID = thisID.slice(prefL);
		itemIDs += thisID;
	}
	formInput.value = itemIDs;
}

function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

function switchDisplay(n){
	var d = document.getElementById(n);
	if (d == undefined){
		return;
	}

	if (d.style.display == 'block'){
		d.style.display = 'none';
	} else {
		d.style.display = 'block';
	}
}

/* 
adds a new Table Row to the table with id = tableName (IMPORTANT!!! this should be the id of tbody)
after the row with id=afterTrId.
newTRContent is an array with the text inside of TDs of that row
*/
function addTRafter(tableId, afterTrId, newTRContent, newTRId){
	if (newTRId == null){
		newTRId = '';
	}

	var t = document.getElementById(tableId);
	if (t == null){ return false; }

	var trs = t.getElementsByTagName('tr');
	var trsl = trs.length - 1;//stop before the last line
	for (var i = 0; i < trsl; i++){
		if (trs[i].getAttribute('id') == afterTrId){
			var ibTR = document.getElementById(trs[i+1].getAttribute('id'));
			break;
		}
	}

	var nTR = document.createElement('tr');
	nTR.setAttribute('id', newTRId);

	var cl = newTRContent.length;
	for (var i = 0; i < cl; i++){
		var nTD = document.createElement('td');
		nTD.innerHTML = newTRContent[i];
		nTR.appendChild(nTD);
	}

	if (ibTR == null){
		t.appendChild(nTR);
	} else {
		t.insertBefore(nTR, ibTR);
	}
	return true;
}


function getXMLHttp(){
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser doesn't support AJAX");
				return false;
			}
		}
	}

	return xmlHttp;
}

function windowSize(win){
    if (win == undefined){
        win = window;
    }
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = win.innerWidth;
		myHeight = win.innerHeight;
	} else if( win.document.documentElement && ( win.document.documentElement.clientWidth || win.document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = win.document.documentElement.clientWidth;
		myHeight = win.document.documentElement.clientHeight;
	} else if(win.document.body && ( win.document.body.clientWidth || win.document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = win.document.body.clientWidth;
		myHeight = win.document.body.clientHeight;
	} else {
        return {w: 640, h: 480};
    }
	return {w: myWidth, h: myHeight};
}

function setWindowSize(w, h){
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		window.innerWidth = w;
		window.innerHeight = h;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		document.documentElement.clientWidth = w;
		document.documentElement.clientHeight = h;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		document.body.clientWidth = w;
		document.body.clientHeight = h;
	}
}


function windowWidth(){
	var wSize = windowSize();
	return wSize.w;
}
function windowHeight(){
	var wSize = windowSize();
	return wSize.h;
}
function printInputRadio(obj){
	var str = '';

	var customAttr = '';
	if (obj.customAttr != null){
		customAttr = obj.customAttr;
	}

	for (var i in obj.value){
		if (i != 'inArray'){
			var id = obj.name+'_'+i;
			if (obj.prefixId !== null){
				id = obj.prefixId + id;
			}
			var sel = '';
			if (obj.selected != null && obj.selected == obj.value[i]){
				sel = ' checked ';
			}
			str+= '<input '+
				'type="radio" '+
				'name="'+obj.name+'" '+
				'value="'+obj.value[i]+'" '+
				'id="'+id+'" '+
				customAttr+
				sel+
				'>'+
				'<label for="'+id+'">'+
				obj.option[i]+
				'</label>'+
				'</input><br>';
		}
	}

	return str;
}

function TextareaMaxLength_bm(t,max){
    var j= 0;
    var curLength=t.value.length;

	if (document.getElementById){
        var b = document.getElementById(t.name+'_count');
        var c = document.getElementById('sms_count');
        if (b == null)     	return;
        c.innerHTML = ((curLength/max)|0)+1;
        if(curLength>max){
            j=((curLength/max)|0)*160;
            curLength=curLength-j;
        }    
   		b.innerHTML = max - curLength;

        
    }

}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedRadio(radioObj) {
    if(!radioObj)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj;
        else
            return "";
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i];
        }
    }
    return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
    if(!radioObj)
        return;
    var radioLength = radioObj.length;
    if(radioLength == undefined) {
        radioObj.checked = (radioObj.value == newValue.toString());
        return;
    }
    for(var i = 0; i < radioLength; i++) {
        radioObj[i].checked = false;
        if(radioObj[i].value == newValue.toString()) {
            radioObj[i].checked = true;
        }
    }
}

function getSelectValue(s){
    return s.options[s.selectedIndex].value;
}
function getSelectText(s){
    return s.options[s.selectedIndex].text;
}

if (!("console" in window)) {
    (function()
         {
             window.console =
                 {
                    log: function()
                        {
                        }
                }
        }
        )()
}

function getElementHeight(Elem) {
    if (ns4) {
        var elem = getObjNN4(document, Elem);
        return elem.clip.height;
    } else {
        if(document.getElementById) {
            var elem = document.getElementById(Elem);
        } else if (document.all){
            var elem = document.all[Elem];
        }
        if (op5) { 
            xPos = elem.style.pixelHeight;
        } else {
            xPos = elem.offsetHeight;
        }
        return xPos;
    } 
}

function getElementWidth(Elem) {
    if (ns4) {
        var elem = getObjNN4(document, Elem);
        return elem.clip.width;
    } else {
        if(document.getElementById) {
            var elem = Elem;
        } else if (document.all){
            var elem = document.all[Elem];
        }
        if (op5) {
            xPos = elem.style.pixelWidth;
        } else {
            xPos = elem.offsetWidth;
        }
        return xPos;
    }
}

function accomodateContent(){
    var s = windowSize();
    var dw = getElementWidth(document.body);
    //setWindowSize(1024, 200);
    centerWindow();
}

var mfMaxes = {};
function addMultipleFile(baseId, max){
    var divF = document.getElementById('d_'+baseId);
    var divFD = document.getElementById('fd_'+baseId);
    //divF.innerHTML += '<br />'+divFD.innerHTML;
    var dprototype = $('d_'+baseId);
    Element.insert($('d_'+baseId), '<br />'+divFD.innerHTML);

    if (mfMaxes[baseId] == undefined){
        mfMaxes[baseId] = 1;
    }

    mfMaxes[baseId]++;
    
    if (mfMaxes[baseId] >= max){
        var af = document.getElementById('a_'+baseId);
        af.style.display = 'none';
    }
}

function lmExamCheckIfEmpty(frm){
    try {
        var els = {};
        for (var i = 0; i < frm.elements.length; i++){
            var el = frm.elements[i];
            if (el.type == 'radio' || el.type == 'checkbox'){
                var internalName = el.name;
                if (el.type == 'checkbox'){
                    var names = el.name.split('[');
                    names.pop();

                    var n = names.join('[');
                    internalName = n;
                }
                //console.log(el.checked+' - '+el.name);
                if (els[internalName] == undefined){
                    els[internalName] = el.checked;
                } else {
                    els[internalName] = els[internalName] || el.checked;
                }
            }
        }

        var moveOn = true;
        for (i in els){
            moveOn = moveOn && els[i];
        }

        return moveOn;

    } catch (err){ 
    }

    return false;
}
var gurl, ecifr;
var ecih = '';
function openExternalContent(url, w, h){
  try
  {
    var wwidth = jQuery(window).width() - 100;
    if (w != undefined){ wwidth = w; }
    if (wwidth > jQuery(window).width()){ wwidth = jQuery(window).width() - 10; }

    var wheight = jQuery(window).height() - 50;
    if (h != undefined){ wheight = h; }
    if (wheight > jQuery(window).height()){ wheight = jQuery(window).height() - 10; }

    var wtop = (jQuery(window).height() - wheight) /2;
    var wleft = (jQuery(window).width() - wwidth) /2;

    jQuery.blockUI({
        message: $('#externalContent'), 
        css: {
        border: 'none', 
        backgroundColor: 'transparent',
        cursor: 'default',
        top:  wtop + 'px', 
        left: wleft + 'px', 
        width: wwidth+'px',
        height: wheight+'px'
        }
        });

    var ecifr = document.createElement('iframe');
    ecifr.style.width = wwidth - 20;
    ecifr.style.height = wheight - 20;
    ecifr.id = 'externalContentIframe';
    ecifr.name = 'externalContentIframe';
    ecifr.frameBorder = 0;
    ecifr.src = url;
    jQuery('#externalContent').append(ecifr);
  }
  catch (e)
  {
    dbge('error', e);
  }
}
function closeExternalContent(){
    if ($('#externalContentIframe').length > 0){
        $('#externalContentIframe').remove();
    }
    jQuery.unblockUI();
}

var glss_current_ul = null;
var glss_timeout = null;
function glss_menuover(ulid){
    if (glss_current_ul){
        glss_hide();
    }
    var ul2s = document.getElementById('l'+ulid);
    ul2s.style.display = 'block';
    glss_current_ul = ul2s;
    if (glss_timeout){
        clearTimeout(glss_timeout);
    }
    hideIESelects();
}

function glss_menuout(ulid){
    glss_timeout = setTimeout(glss_hide, 500);
}

function glss_hide(){
    showIESelects();
    glss_current_ul.style.display = 'none';
    glss_current_ul = null;
}

glsDbg = {};
glsDbg.getStackTrace = function() {

var mode;
try {(0)()} catch (e) {
    mode = e.stack ? 'Firefox' : window.opera ? 'Opera' : 'Other';
}

switch (mode) {
    case 'Firefox' : return function () {
        try {(0)()} catch (e) {
            return e.stack.replace(/^.*?\n/,'').
                           replace(/(?:\n@:0)?\s+$/m,'').
                           replace(/^\(/gm,'{anonymous}(').
                           split("\n");
        }
    };

    case 'Opera' : return function () {
        try {(0)()} catch (e) {
            var lines = e.message.split("\n"),
                ANON = '{anonymous}',
                lineRE = /Line\s+(\d+).*?in\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i,
                i,j,len;

            for (i=4,j=0,len=lines.length; i<len; i+=2) {
                if (lineRE.test(lines[i])) {
                    lines[j++] = (RegExp.$3 ?
                        RegExp.$3 + '()@' + RegExp.$2 + RegExp.$1 :
                        ANON + RegExp.$2 + ':' + RegExp.$1) +
                        ' -- ' + lines[i+1].replace(/^\s+/,'');
                }
            }

            lines.splice(j,lines.length-j);
            return lines;
        }
    };

    default : 
        var curr  = arguments.callee.caller,
            FUNC  = 'function', ANON = "{anonymous}",
            fnRE  = /function\s*([\w\-$]+)?\s*\(/i,
            stack = [],j=0,
            fn,args,i;

        while (curr) {
            fn    = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON;
            args  = stack.slice.call(curr.arguments);
            i     = args.length;

            while (i--) {
                switch (typeof args[i]) {
                    case 'string'  : args[i] = '"'+args[i].replace(/"/g,'\\"')+'"'; break;
                    case 'function': args[i] = FUNC; break;
                }
            }

            stack[j++] = fn + '(' + args.join() + ')';
            curr = curr.caller;
        }

        return stack;
}

}

function my_textfield_focused(t, defaultvalue)
{
  if (t.value == defaultvalue)
  {
    t.value = '';
    t.className = '';
  }
}

function my_textfield_blurred(t, defaultvalue)
{
  if (t.value == '')
  {
    t.value = defaultvalue;
    t.className = 'inactive';
  }
}

-->
