function encode(sValue) {
    var text = "", Ucode, ExitValue, s;
    for (var i = 0; i < sValue.length; i++) {
        s = sValue.charAt(i);
        Ucode = s.charCodeAt(0);
        var Acode = Ucode;
        if (Ucode > 1039 && Ucode < 1104) {
            Acode -= 848;
            ExitValue = "%" + Acode.toString(16);
        }
        else if (Ucode == 1025) {
            Acode = 168;
            ExitValue = "%" + Acode.toString(16);
        }
        else if (Ucode == 1105) {
            Acode = 184;
            ExitValue = "%" + Acode.toString(16);
        }
        else if (Ucode == 32) {
            Acode = 32;
            ExitValue = "%" + Acode.toString(16);
        }
        else if (Ucode == 10) {
            Acode = 10;
            ExitValue = "%0A";
        }
        else {
            ExitValue = s;
        }
        text = text + ExitValue;
    }
    return text;
}
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}
function openModal(modalName) {
    var modal = $find(modalName);
    var ver = getInternetExplorerVersion();

    if (modal) {
        var viewportwidth;
        var viewportheight;
        // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
        if (typeof window.innerWidth != 'undefined') {
            viewportwidth = window.innerWidth,
                  viewportheight = window.innerHeight
        }
        // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
        else if (typeof document.documentElement != 'undefined'
                 && typeof document.documentElement.clientWidth !=
                 'undefined' && document.documentElement.clientWidth != 0) {
            viewportwidth = document.documentElement.clientWidth,
                   viewportheight = document.documentElement.clientHeight
        }
        // older versions of IE
        else {
            viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
                   viewportheight = document.getElementsByTagName('body')[0].clientHeight
        }
        var headerHeight = 200;
        if (ver > 0 && ver <= 6)
            headerHeight += 40;
        if (ver == 7)
            headerHeight += 15;

        /*alert(headerHeight);*/
        var hh = (viewportheight - headerHeight - 20) + "px";
        var ww = (viewportwidth - 20) + "px";
        //alert(viewportheight);
        oldHeight = hh;
        // panel.style.width = ww;
        modal.show();
    }
}
// ThumbNails
function tabStripThumbNailSwitch(el) {
	
	if(el.className == "activated") return;
	_thumbNailGroup = el.parentNode;
	_tabStrip = _thumbNailGroup.parentNode;
	_index = el.id.substr( _tabStrip.id.length + 4 );
	_bodyId = _tabStrip.id + "_tb_" + _index;
	
	_thumbNails = _thumbNailGroup.getElementsByTagName("div");
	
	for(i=0; i<_thumbNails.length; i++) {
		if( _thumbNails[i].parentNode  == _thumbNailGroup) {
			if( _thumbNails[i] == el ){
				_thumbNails[i].className = "active"
				document.getElementById(_tabStrip.id + "_hidd").value = _index;
			}
			else {
				_thumbNails[i].className = "normal";
			}
		}
	}
	
	delete _thumbNails;
	_bodies = _tabStrip.childNodes;
	_bodyOld = null;
	_bodyNew = null;
	
	for(i=0; i<_bodies.length; i++) {
		if( typeof(_bodies[i].parentNode) ) {
			if( _bodies[i].tagName  == "DIV" ) {
				if( _bodies[i].style.display == "block" ) _bodyOld = _bodies[i];
				if( _bodies[i].id ==  _bodyId ) _bodyNew = _bodies[i];
				//alert("[1]: " +_bodies[i].id + " == [2]: " +_bodyId  );
			}
		}
	}
	
	if(_bodyOld != null) _bodyOld.style.display = "none"; 
	if(_bodyNew != null) _bodyNew.style.display = "block"; 
	delete _bodies;
}


// Select
function tabStripSelectSwitch(el) {
	_tabStrip = el.parentNode.parentNode.parentNode.parentNode;
	_bodyId = _tabStrip.id + "_tb_" + el.selectedIndex;
	
	_bodies = _tabStrip.childNodes;
	_bodyOld = null;
	_bodyNew = null;
	
	for(i=0; i<_bodies.length; i++) {
		if( typeof(_bodies[i].parentNode) )
		if( _bodies[i].tagName  == "DIV" ) {
			if( _bodies[i].style.display=="block" ) _bodyOld = _bodies[i];
			if( _bodies[i].id ==  _bodyId ) _bodyNew = _bodies[i];
		}
	}
	if(_bodyOld != null) _bodyOld.style.display = "none"; 
	if(_bodyNew != null) _bodyNew.style.display = "block"; 
	
	delete _bodies;			
}




function openChildWin(_fileName, _width, _height) {
	if(!_width) _width = "620px";
	if(!_height) _height = "700px";
	closeChildWin();
	newWin = window.open(_fileName,'_childWin', 'toolbar=no, height='+_height+', width=' + _width 
	+ ', left=10, top=10, menubar=no, scrollbars=yes, resizable=yes, status=no');
	newWin.focus();
	return false;
}

var newWin=null;
function closeChildWin(){
	if(newWin) newWin.close();
	}


function updateSelAuthors(_id1) {
	s1 = document.getElementById(_id1);
	v1 = document.getElementById(_id1+"Value");
	//alert(v1.value);
	o1 = s1.options;
	v1.value = "";
	for(i=0;i<o1.length;i++) {
		v1.value += "," + o1[i].value;

	}
	
	var arrTemp = new Array(o1.length);
	var arrTempVal = new Array(o1.length);
	var arr = new Array(o1.length);
	
	for(i=0;i<o1.length;i++) {
		
		arrTempVal[i]  = o1[i].value;
		arrTemp[i]  = o1[i].text.toLowerCase();
		arr[i] = o1[i].text;
	}
	
	arrTemp.sort();
	
	for(i=0;i<arrTemp.length;i++) {
			opt = new Option();			
			for(j=0;j<arrTemp.length;j++) {
				if(arrTemp[i] == arr[j].toLowerCase()) {
					opt.text  = arr[j];
					opt.value   = arrTempVal[j];
					o1[i] = opt;
				}
			}
	}
			
	//alert(v1.value);
}


function moveOpt(_id1, _id2){
	s1 = document.getElementById(_id1);
	s2 = document.getElementById(_id2);
	o1 = s1.options;
	o2 = s2.options;
	destIdx = o2.length;
	_ok = false;
	for(i=0;i<o1.length;) {
		if(o1[i].selected) {
			opt = new Option();
			opt.value  = o1[i].value;
			opt.text  = o1[i].text;
			//alert(opt);
			//alert(o1[i]);
			o2[destIdx++] = opt;;
			o1[i] = null;
			_ok = true;
		}
		else{
			i++;
		}
	}
	if(!_ok) alert('No option has been chosen!');
	
	var arrTemp = new Array(o2.length);
	var arrTempVal = new Array(o2.length);
	var arr = new Array(o2.length);
	
	for(i=0;i<o2.length;i++) {
		
		arrTempVal[i]  = o2[i].value;
		arrTemp[i]  = o2[i].text.toLowerCase();
		arr[i] = o2[i].text;
	}
	
	arrTemp.sort();
	
	for(i=0;i<arrTemp.length;i++) {
			opt = new Option();			
			for(j=0;j<arrTemp.length;j++) {
				if(arrTemp[i] == arr[j].toLowerCase()) {
					opt.text  = arr[j];
					opt.value   = arrTempVal[j];
					o2[i] = opt;
				}
			}
	}

}





