

/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/

var Base64 = {

    // private property
    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode : function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);

        while (i < input.length) {

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }

        return output;
    },

    // public method for decoding
    decode : function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

        while (i < input.length) {

            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }

        }

        output = Base64._utf8_decode(output);

        return output;

    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }
}

//End Base64



// Start Ajax functions
window.urlData=Array();


var xmlHttp = createXMLHttpRequest();

function createXMLHttpRequest() {
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   alert("XMLHttpRequest not supported");
   return null;
 }

var onLoadContentOverlibFunction=function(){
    if (xmlHttp.readyState == 4) {  changeOverlibContent(xmlHttp.responseText); }
    };





function loadOverlibContent(url, f){

  // Open a connection to the server
  xmlHttp.open("GET", url, true);

  if (!f) {
      f=onLoadContentOverlibFunction;
  }
  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = f;

  // Send the request
  xmlHttp.send(null);
}


function handleAJAXCallStateChange(){
    if (xmlHttp.readyState == 4) {  
        alert("I am a dummy function [handleAJAXCallStateChange].\nYou must override me.\n\nBy the way the ready state is " + xmlHttp.readyState); 
    }
}

function doAJAXPostCall(url, params, f){
    //You have to either pass your function or override the handleAJAXCallStateChange

  // Open a connection to the server
  xmlHttp.open("POST", url, true);

  if (!f) {
      f=handleAJAXCallStateChange;
  }
  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = f;
  xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");

  xmlHttp.send(params);
}

function doAJAXGetCall(url, f){
    //You have to either pass your function or override the handleAJAXCallStateChange

  // Open a connection to the server
  xmlHttp.open("GET", url, true);

  if (!f) {
      f=handleAJAXCallStateChange;
  }
  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = f;

  xmlHttp.send(null);
}



function changeOverlibContent(str){
    showOverlib(str);
    return false;


}


function showOverlib(data,caption){

        if (!caption) {
            if (window.overlibCaption){
                caption=window.overlibCaption;
            } else {
                caption="---";
            }
        }
        if (!window.overLibX) {
            window.overLibX=cursor.x;
        }
        if (!window.overLibY) {
            window.overLibY=cursor.y;
        }


        return overlib(data, 
                       CAPTION, caption,
                       FIXX, window.overLibX,
                       FIXY, window.overLibY,


                       STICKY, 
                       FGCOLOR , '#bce0ec', 
                       BGCOLOR, '#153A46', 
                       CAPCOLOR  , '#ffffff',
                       CLOSETEXT, '<img src=/images/close.gif border=0>',
                       CLOSECLICK);
}

// -- end ajax functions




function xoopsGetElementById(id){
	if (document.getElementById) {
		return (document.getElementById(id));
	} else if (document.all) {
		return (document.all[id]);
	} else {
		if ((navigator.appname.indexOf("Netscape") != -1) && parseInt(navigator.appversion == 4)) {
			return (document.layers[id]);
		}
	}
}

function xoopsSetElementProp(name, prop, val) {
	var elt=xoopsGetElementById(name);
	if (elt) elt[prop]=val;
}

function xoopsSetElementStyle(name, prop, val) {
	var elt=xoopsGetElementById(name);
	if (elt && elt.style) elt.style[prop]=val;
}


function getFormDataAsQueryString(fname){
    var frm=document.forms[fname];
    var text="";

    var els = frm.elements; 

    for(i=0; i<els.length; i++){ 
        _value=null;

        switch(els[i].type){
            case "select-one" :
                _value=els[i].options[els[i].selectedIndex].value;

            break;

            case "text":
                _value=els[i].value;
            break;

            case "hidden":
                _value=els[i].value;
            break;

            case "password":
                _value=els[i].value;
            break;
        }
        if (_value) {
            text+=els[i].name+"="+_value+"&"
        }
    }
        return text;

}
function xoopsGetFormElement(fname, ctlname) {
	var frm=document.forms[fname];
	return frm?frm.elements[ctlname]:null;
}

function justReturn() {
	return;
}

function openWithSelfMain(url,name,width,height,params) {
    if (!params) {
        params="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
    }
    var options = "width=" + width + ",height=" + height + "," + params;

	new_window = window.open(url, name, options);
	window.self.name = "main";
	new_window.focus();
}

function setElementBackgroundColor(id, color){
	xoopsGetElementById(id).style.backgroundColor = "#" + color;
}

function setElementColor(id, color){
	xoopsGetElementById(id).style.color = "#" + color;
}

function setElementFont(id, font){
	xoopsGetElementById(id).style.fontFamily = font;
}

function setElementSize(id, size){
	xoopsGetElementById(id).style.fontSize = size;
}

function changeDisplay(id){
	var elestyle = xoopsGetElementById(id).style;
	if (elestyle.display == "") {
		elestyle.display = "none";
	} else {
		elestyle.display = "block";
	}
}

function setVisible(id){
	xoopsGetElementById(id).style.visibility = "visible";
}

function setHidden(id){
	xoopsGetElementById(id).style.visibility = "hidden";
}

function toggleVisibility(id){
	if (xoopsGetElementById(id).style.visibility == "hidden"){
		setVisible(id);
	} else {
		setHidden(id);
	}

}

function showHide(id){
	thisLayer=document.getElementById(id);

	if (thisLayer.style.display=="block") {
		thisLayer.style.display="none"
	} else {
		thisLayer.style.display="block"
	}

}

function resizeTextBox(e, d, n){
    element=document.getElementById(e);
        
        if (d=="height"){
            currHeight=parseInt(element.style.height);
            newHeight=currHeight+n;
            if (newHeight>0) {
                element.style.height=newHeight+"px";
            }
        }
        
    if (d=="width"){
        currWidth=parseInt(element.style.width);
        newWidth=currWidth+n;
        if (newWidth>0) {
            element.style.width=newWidth+"px";
        }
    }

}


function resizeSelectBox(e, n, d){
	element=xoopsGetElementById(e);
    if (!d) {
        d="height";
    }
    if (d=="height"){
    	currHeight=parseInt(element.style.height);
    	newHeight=currHeight+n;
    	if (newHeight>0) {
    		element.style.height=newHeight+"px";
    	}
    }

    if (d=="width"){
        currWidth=parseInt(element.style.width);
        newWidth=currWidth+n;

        if (newWidth>0) {
            element.style.width=newWidth+"px";
        }
    }

}


function makeBold(id){
	var eleStyle = xoopsGetElementById(id).style;
	if (eleStyle.fontWeight != "bold" && eleStyle.fontWeight != "700") {
		eleStyle.fontWeight = "bold";
	} else {
		eleStyle.fontWeight = "normal";
	}
}

function makeItalic(id){
	var eleStyle = xoopsGetElementById(id).style;
	if (eleStyle.fontStyle != "italic") {
		eleStyle.fontStyle = "italic";
	} else {
		eleStyle.fontStyle = "normal";
	}
}

function makeUnderline(id){
	var eleStyle = xoopsGetElementById(id).style;
	if (eleStyle.textDecoration != "underline") {
		eleStyle.textDecoration = "underline";
	} else {
		eleStyle.textDecoration = "none";
	}
}

function makeLineThrough(id){
	var eleStyle = xoopsGetElementById(id).style;
	if (eleStyle.textDecoration != "line-through") {
		eleStyle.textDecoration = "line-through";
	} else {
		eleStyle.textDecoration = "none";
	}
}

function appendSelectOption(selectMenuId, optionName, optionValue){
	var selectMenu = xoopsGetElementById(selectMenuId);
	var newoption = new Option(optionName, optionValue);
	selectMenu.options[selectMenu.length] = newoption;
	selectMenu.options[selectMenu.length].selected = true;
}

function disableElement(target){
	var targetDom = xoopsGetElementById(target);
	if (targetDom.disabled != true) {
		targetDom.disabled = true;
	} else {
		targetDom.disabled = false;
	}
}
function xoopsCheckAll(formname, switchid) {
	var ele = document.forms[formname].elements;
	var switch_cbox = xoopsGetElementById(switchid);
	for (var i = 0; i < ele.length; i++) {
		var e = ele[i];
		if ( (e.name != switch_cbox.name) && (e.type == 'checkbox') ) {
			e.checked = switch_cbox.checked;
		}
	}
}

function xoopsCheckGroup(formname, switchid, groupid) {
	var ele = document.forms[formname].elements;
	var switch_cbox = xoopsGetElementById(switchid);
	for (var i = 0; i < ele.length; i++) {
		var e = ele[i];
		if ( (e.type == 'checkbox') && (e.id == groupid) ) {
			e.checked = switch_cbox.checked;
			e.click(); e.click();  // Click to activate subgroups
			// Twice so we don't reverse effect
		}
	}
}

function xoopsCheckAllElements(elementIds, switchId) {
	var switch_cbox = xoopsGetElementById(switchId);
	for (var i = 0; i < elementIds.length; i++) {
		var e = xoopsGetElementById(elementIds[i]);
		if ((e.name != switch_cbox.name) && (e.type == 'checkbox')) {
			e.checked = switch_cbox.checked;
		}
	}
}

function xoopsSavePosition(id)
{
	var textareaDom = xoopsGetElementById(id);
	if (textareaDom.createTextRange) {
		textareaDom.caretPos = document.selection.createRange().duplicate();
	}
}

function xoopsInsertText(domobj, text)
{
	if (domobj.createTextRange && domobj.caretPos){
		var caretPos = domobj.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1)
		== ' ' ? text + ' ' : text;
	} else if (domobj.getSelection && domobj.caretPos){
		var caretPos = domobj.caretPos;
		caretPos.text = caretPos.text.charat(caretPos.text.length - 1)
		== ' ' ? text + ' ' : text;
	} else {
		domobj.value = domobj.value + text;
	}
}

function xoopsCodeSmilie(id, smilieCode) {
	var revisedMessage;
	var textareaDom = xoopsGetElementById(id);
	xoopsInsertText(textareaDom, smilieCode);
	textareaDom.focus();
	return;
}

function showImgSelected(imgId, selectId, imgDir, extra, xoopsUrl) {
	if (xoopsUrl == null) {
		xoopsUrl = "./";
	}
	imgDom = xoopsGetElementById(imgId);
	selectDom = xoopsGetElementById(selectId);
	imgDom.src = xoopsUrl + "/"+ imgDir + "/" + selectDom.options[selectDom.selectedIndex].value + extra;
}

function xoopsCodeUrl(id, enterUrlPhrase, enterWebsitePhrase){
	if (enterUrlPhrase == null) {
		enterUrlPhrase = "Enter the URL of the link you want to add:";
	}
	var text = prompt(enterUrlPhrase, "");
	var domobj = xoopsGetElementById(id);
	if ( text != null && text != "" ) {
		if (enterWebsitePhrase == null) {
			enterWebsitePhrase = "Enter the web site title:";
		}
		var text2 = prompt(enterWebsitePhrase, "");
		if ( text2 != null ) {
			if ( text2 == "" ) {
				var result = "[url=" + text + "]" + text + "[/url]";
			} else {
				var pos = text2.indexOf(unescape('%00'));
				if(0 < pos){
					text2 = text2.substr(0,pos);
				}
				var result = "[url=" + text + "]" + text2 + "[/url]";
			}
			xoopsInsertText(domobj, result);
		}
	}
	domobj.focus();
}

function xoopsCodeImg(id, enterImgUrlPhrase, enterImgPosPhrase, imgPosRorLPhrase, errorImgPosPhrase){
	if (enterImgUrlPhrase == null) {
		enterImgUrlPhrase = "Enter the URL of the image you want to add:";
	}
	var text = prompt(enterImgUrlPhrase, "");
	var domobj = xoopsGetElementById(id);
	if ( text != null && text != "" ) {
		if (enterImgPosPhrase == null) {
			enterImgPosPhrase = "Now, enter the position of the image.";
		}
		if (imgPosRorLPhrase == null) {
			imgPosRorLPhrase = "'R' or 'r' for right, 'L' or 'l' for left, or leave it blank.";
		}
		if (errorImgPosPhrase == null) {
			errorImgPosPhrase = "ERROR! Enter the position of the image:";
		}
		var text2 = prompt(enterImgPosPhrase + "\n" + imgPosRorLPhrase, "");
		while ( ( text2 != "" ) && ( text2 != "r" ) && ( text2 != "R" ) && ( text2 != "l" ) && ( text2 != "L" ) && ( text2 != null ) ) {
			text2 = prompt(errorImgPosPhrase + "\n" + imgPosRorLPhrase,"");
		}
		if ( text2 == "l" || text2 == "L" ) {
			text2 = " align=left";
		} else if ( text2 == "r" || text2 == "R" ) {
			text2 = " align=right";
		} else {
			text2 = "";
		}
		var result = "[img" + text2 + "]" + text + "[/img]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

function xoopsCodeEmail(id, enterEmailPhrase){
	if (enterEmailPhrase == null) {
		enterEmailPhrase = "Enter the email address you want to add:";
	}
	var text = prompt(enterEmailPhrase, "");
	var domobj = xoopsGetElementById(id);
	if ( text != null && text != "" ) {
		var result = "[email]" + text + "[/email]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

function xoopsCodeQuote(id, enterQuotePhrase){
	if (enterQuotePhrase == null) {
		enterQuotePhrase = "Enter the text that you want to be quoted:";
	}
	var text = prompt(enterQuotePhrase, "");
	var domobj = xoopsGetElementById(id);
	if ( text != null && text != "" ) {
		var pos = text.indexOf(unescape('%00'));
		if(0 < pos){
			text = text.substr(0,pos);
		}
		var result = "[quote]" + text + "[/quote]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

function xoopsCodeCode(id, enterCodePhrase){
	if (enterCodePhrase == null) {
		enterCodePhrase = "Enter the codes that you want to add.";
	}
	var text = prompt(enterCodePhrase, "");
	var domobj = xoopsGetElementById(id);
	if ( text != null && text != "" ) {
		var result = "[code]" + text + "[/code]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

function xoopsCodeText(id, hiddentext, enterTextboxPhrase){
	var textareaDom = xoopsGetElementById(id);
	var textDom = xoopsGetElementById(id + "Addtext");
	var fontDom = xoopsGetElementById(id + "Font");
	var colorDom = xoopsGetElementById(id + "Color");
	var sizeDom = xoopsGetElementById(id + "Size");
	var xoopsHiddenTextDomStyle = xoopsGetElementById(hiddentext).style;
	var textDomValue = textDom.value;
	var fontDomValue = fontDom.options[fontDom.options.selectedIndex].value;
	var colorDomValue = colorDom.options[colorDom.options.selectedIndex].value;
	var sizeDomValue = sizeDom.options[sizeDom.options.selectedIndex].value;
	if ( textDomValue == "" ) {
		if (enterTextboxPhrase == null) {
			enterTextboxPhrase = "Please input text into the textbox.";
		}
		alert(enterTextboxPhrase);
		textDom.focus();
	} else {
		if ( fontDomValue != "FONT") {
			textDomValue = "[font=" + fontDomValue + "]" + textDomValue + "[/font]";
			fontDom.options[0].selected = true;
		}
		if ( colorDomValue != "COLOR") {
			textDomValue = "[color=" + colorDomValue + "]" + textDomValue + "[/color]";
			colorDom.options[0].selected = true;
		}
		if ( sizeDomValue != "SIZE") {
			textDomValue = "[size=" + sizeDomValue + "]" + textDomValue + "[/size]";
			sizeDom.options[0].selected = true;
		}
		if (xoopsHiddenTextDomStyle.fontWeight == "bold" || xoopsHiddenTextDomStyle.fontWeight == "700") {
			textDomValue = "[b]" + textDomValue + "[/b]";
			xoopsHiddenTextDomStyle.fontWeight = "normal";
		}
		if (xoopsHiddenTextDomStyle.fontStyle == "italic") {
			textDomValue = "[i]" + textDomValue + "[/i]";
			xoopsHiddenTextDomStyle.fontStyle = "normal";
		}
		if (xoopsHiddenTextDomStyle.textDecoration == "underline") {
			textDomValue = "[u]" + textDomValue + "[/u]";
			xoopsHiddenTextDomStyle.textDecoration = "none";
		}
		if (xoopsHiddenTextDomStyle.textDecoration == "line-through") {
			textDomValue = "[d]" + textDomValue + "[/d]";
			xoopsHiddenTextDomStyle.textDecoration = "none";
		}
		xoopsInsertText(textareaDom, textDomValue);
		textDom.value = "";
		xoopsHiddenTextDomStyle.color = "#000000";
		xoopsHiddenTextDomStyle.fontFamily = "";
		xoopsHiddenTextDomStyle.fontSize = "12px";
		xoopsHiddenTextDomStyle.visibility = "hidden";
		textareaDom.focus();
	}
}

function IsNumeric(strString){
	//  check for valid numeric strings (integer)

	var strValidChars = "0123456789";
	var strChar;
	var isNum = true;

	if (strString.length == 0){
		return false;
	}

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && isNum == true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			isNum = false;
		}
	}
	return isNum;
}

function xoopsValidate(subjectId, textareaId, submitId, plzCompletePhrase, msgTooLongPhrase, allowedCharPhrase, currCharPhrase) {
	var maxchars = 65535;
	var subjectDom = xoopsGetElementById(subjectId);
	var textareaDom = xoopsGetElementById(textareaId);
	var submitDom = xoopsGetElementById(submitId);
	if (textareaDom.value == "" || subjectDom.value == "") {
		if (plzCompletePhrase == null) {
			plzCompletePhrase = "Please complete the subject and message fields.";
		}
		alert(plzCompletePhrase);
		return false;
	}
	if (maxchars != 0) {
		if (textareaDom.value.length > maxchars) {
			if (msgTooLongPhrase == null) {
				msgTooLongPhrase = "Your message is too long.";
			}
			if (allowedCharPhrase == null) {
				allowedCharPhrase = "Allowed max chars length: ";
			}
			if (currCharPhrase == null) {
				currCharPhrase = "Current chars length: ";
			}
			alert(msgTooLongPhrase + "\n\n" + allowedCharPhrase + maxchars + "\n" + currCharPhrase + textareaDom.value.length + "");
			textareaDom.focus();
			return false;
		} else {
			submitDom.disabled = true;
			return true;
		}
	} else {
		submitDom.disabled = true;
		return true;
	}
}



function printURL(){

	var pathname=self.location.pathname;
	var query=self.location.search;

	//  direct call for SEF startpage url (ie: http://{hostname}/)
	if (pathname == '/' && query == '') {
		return pathname+"index.php?layout=print";
	}

	var parameters=new Array();
	var params =new Array();
	var seenLayout=false;


	query = query.substr(1, query.length - 1);
	query = query.replace(/%26/,'&');
	params= query.split('&');

	for (i = 0; i < params.length; i++){
		if (params[i] != '') {
			parameters[i]=params[i].split('=');

			if (parameters[i][0]=="layout"){
				seenLayout=true;
				parameters[i][1]="print";
			}
		}
	}
	if (!seenLayout){
		parameters.push(new Array("layout", "print"));
	}
	params=new Array();
	for (i = 0; i < parameters.length; i++){
		params[i]=parameters[i][0]+"="+parameters[i][1];
	}
	query=params.join('&');
	if (pathname.match(/^\/\d+$/)){
	pathname +='/';
}

return pathname + "?" + query;
}

function replaceParamFromLocation(param2replace, replacement_value){
	// replaces value of a parameter from the URL

	var pathname=self.location.pathname;
	var query=self.location.search;

	var parameters=new Array();
	var params =new Array();
	var seenLayout=false;


	query = query.substr(1, query.length - 1);
	query = query.replace(/%26/,'&');
	params= query.split('&');

	for (i = 0; i < params.length; i++){
		parameters[i]=params[i].split('=');
	}


	params=new Array();
	for (i = 0; i < parameters.length; i++){
		if (parameters[i][0]==param2replace) {
			parameters[i][1]=replacement_value;
		}
		params[i]=parameters[i][0]+"="+parameters[i][1];
	}
	query=params.join('&');

	return pathname + "?" + query;

}

function getParamFromLocation(param2get){
	// get value of a parameter from the URL

	var query=self.location.search;

	var parameters=new Array();
	var params =new Array();
	var seenLayout=false;


	query = query.substr(1, query.length - 1);
	query = query.replace(/%26/,'&');
	params= query.split('&');

	for (i = 0; i < params.length; i++){
		parameters[i]=params[i].split('=');
	}


	params=new Array();
	for (i = 0; i < parameters.length; i++){
		if (parameters[i][0]==param2get) {
			return parameters[i][1];
		}

	}

	// parameter not found
	return false;

}

function openPrintWindow(){
	oNewWindow = window.open(printURL(), "_blank");
}


function gotoWsContentPage(pageId){

	var pathname=self.location.pathname;

	// Handle first page
	var gotoUrl=false;

	if (pathname=="/" ) {
		gotoUrl="/content/0/"+pageId+"/";
		//alert("First Page!\nGotoURL is "+gotoUrl);

	} else {
		path_tokens=pathname.split('/');
		if (typeof(path_tokens)=="object") {
			if (path_tokens[1]) {
				//alert(path_tokens[1]);
				if (path_tokens[1].match(/^\d\d*$/)) {
					gotoUrl="/content/"+path_tokens[1]+"/"+pageId+"/";
					//alert("This is a location id\nGotoURL is "+gotoUrl);
				} else if (path_tokens[1].match(/^content*$/)) {
					gotoUrl="/content/"+path_tokens[2]+"/"+pageId+"/";
					//alert("This is content\nGotURL is "+gotoUrl);
				} else if (path_tokens[1].match(/^modules*$/) && path_tokens[2].match(/^wsContent*$/)) {
					gotoUrl=replaceParamFromLocation("page", pageId);
					//alert("Module/wsContent.\nGotoURL is " + gotoUrl);
				}
			}
		}
	}

	if (!gotoUrl) {
		gotoUrl="/content/0/"+pageId+"/";
	}
	if (gotoUrl) {
		self.location=gotoUrl;
	}
	return false;






}



function downloadFile(fileId) {
	var location_id = getParamFromLocation('location_id') || 0 ;
	var page_id = getParamFromLocation('page');
	var hostname = self.location.host;

	var path_upload = '/modules/uploadmanager11/admin/index.php?action=file_download&file_id='+fileId;
	var href_file = 'http://'+hostname+path_upload+'&location_id='+location_id;

	window.open(href_file);
	//self.location.href =  href_file;
	//return false;
}



function scrollToTop(){
	window.scroll(0,0);
}


//window.onload=scrollToTop;
//window.attachEvent("onload", scrollToTop);



function argObject(name,value) {
	this.name=name;
	this.value=value;

}


function remoteCall (url,args){
	var n = args[0];
	var head = document.getElementsByTagName('head').item(0);

	var old  = document.getElementById(n.value);
	if (old) {
		head.removeChild(old);
	}

	script = document.createElement('script');

	script.type = 'text/javascript';
	script.defer = true;

	script.id = n.value; // Just call it somehow....
	var text="?";
	for(var i=0;i<args.length;++i){
		text=text + args[i].name + "=" + args[i].value + "&";
	}
	//alert(url+text);
	script.src = url+text;
	void(head.appendChild(script));

}


function showHideHelpText(id){
	showHide(id);

}

/*********************************************************************************
dw_cookies.js - cookie functions for www.dyn-web.com
Recycled from various sources
**********************************************************************************/

// Modified from Bill Dortch's Cookie Functions (hidaho.com)
// (found in JavaScript Bible)
function setCookie(name,value,days,path,domain,secure) {
	var expires, date;
	if (typeof days == "number") {
		date = new Date();
		date.setTime( date.getTime() + (days*24*60*60*1000) );
		expires = date.toGMTString();
	}
	document.cookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

// Modified from Jesse Chisholm or Scott Andrew Lepera ?
// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
function getCookie(name) {
	var nameq = name + "=";
	var c_ar = document.cookie.split(';');
	for (var i=0; i<c_ar.length; i++) {
		var c = c_ar[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
	}
	return null;
}

// from Bill Dortch's Cookie Functions (hidaho.com)
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 confirm2go(msg, url){
    if (confirm(msg)) {
        location.href=url;
    }
}

var cursor = {x:0, y:0};


