

var baseurl;

function version(){

var ievs = (/MSIE 8.0(\d+\.\d+);/.test(navigator.userAgent));

    // IF BROWSER IS IE 6 LOAD IE6 STYLE

    if (ievs){

    var iev=new Number(RegExp.$1);

    if (iev==6) {

       // window.location.replace(baseurl+"/index/version");


    }

    

    }
    return iev;

}

function controllaDominio()
{
    name='id_pacchetto';
    radioObj=document.registrati.id_pacchetto;
    $("dom_err").hide();
    if(!(radioObj[0].checked) && !(radioObj[3].checked) && !(radioObj[1].checked))
    {
    
    if($F('dominio')=="" || !$F('tld')){

                   $("dom_err").update("Attenzione devi scegliere un tuo dominio!!!");
                $("dom_err").show();
                alert("ATTENZIONE!!\n Devi scegliere un dominio");
    }
    else{
    new Ajax.Request(baseurl+'/account/dominio',{
        method:"post",
        parameters:$("dominio").serialize()+"&"+$("tld").serialize(),
        onSuccess:function(x){
            var risp=x.responseText.evalJSON(true);
            $("ch_dom").update(risp.msg);
            if(risp.errore=="no")
            {

                $("dom_err").update("ATTENZIONE!!\n Scegli un altro dominio poichè non è disponibile");
                $("dom_err").show();
                alert("ATTENZIONE!!\n Scegli un altro dominio poichè non è disponibile");
            }
            else $("registrati").submit();
        }
    });}}
else $("registrati").submit();
}



function voceSelezionata(tipo,classe,testoON,sfondoON,testoOFF,sfondoOFF,id)
{
   /* $$(tipo+"."+classe).each(function(s){
          s.firstChild.style.color=testoOFF;
          s.style.background=sfondoOFF;
          
          if(s.id==id)
          {
              s.firstChild.style.color=testoON;
              s.style.background=sfondoON;
          }
        }
    );*/
}

function relocation(){
    var loc=window.location;
    var x=loc.hostname;
    if(x.substring(0,3)!="www")
        loc.replace("http://www."+x);
}

function rollover(id,param) {


if(document.all)
    $(id).setAttribute('className',id+'_'+param);
else
    $(id).setAttribute('class',id+'_'+param);
}

function updater(target,action)
{
    
    new Ajax.Updater(target,action,
            {
                evalScripts:true
			});
    $(target).update('<img src='+baseurl+'/include/images/indicator_medium.gif />');
}

function mouseover(element)
{
    element.style.background="rgb(80,145,173)";
    element.style.color="white";
}

function mouseout(element)
{
    element.style.background="white";
    element.style.color="rgb(80,145,173)";
}

function isEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
return 1;
else
return 0;
}


	// public method for url encoding
	 function encode(string) {
		return escape(_utf8_encode(string));
	}

	// public method for url decoding
	 function decode(string) {
		return _utf8_decode(unescape(string));
	}

	// private method for UTF-8 encoding
	 function _utf8_encode(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
	 function _utf8_decode(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;
	}
function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}
 function sposta(from,to)
            {
                var arraySelected_t = new Array();
                var arraySelected_v = new Array();
                var arrayDeselected_t = new Array();
                var arrayDeselected_v = new Array();

                var a_1 = 0; // Contatore array 1
                var a_2 = 0; // Contatore array 2

                // CARICO TUTTI LE OPTION DEL GRUPPO nell'array
                for(i=0;i<to.length;i++)
                {
                    arraySelected_t[a_1] = to[i].text;

                    arraySelected_v[a_1] = to[i].value;
                    a_1++;
                }

                // Aggiungo quelli selezionati nello stesso array<br>
                // Quelli non selezionati in un altro
                for(i=0;i<from.length;i++)
                {

                    if(from[i].selected)
                    {
                        arraySelected_t[a_1] = from[i].text;
                        arraySelected_v[a_1] = from[i].value;
                        a_1++;
                    }
                    else
                    {
                        arrayDeselected_t[a_2] = from[i].text;
                        arrayDeselected_v[a_2] = from[i].value;
                        a_2++;
                    }
                }


                //arraySelected_t.sort(); // Ordinamento Array
                from.length = 0; // Azzeramneto Option

                // RISISTEMAZIONE Dei valori degli array nelle options
                for(a=0;a<arraySelected_t.length;a++)
                {

                    n = new Option();
                    n.value = arraySelected_v[a];
                    n.text = arraySelected_t[a];
                    to[a] = n;
                }

                for(a=0;a<arrayDeselected_t.length;a++)
                {
                    n = new Option();
                    n.value = arrayDeselected_v[a];
                    n.text = arrayDeselected_t[a];
                    from[a] = n;
                }
            }
            function inviaSelezionati(p)
            {
                $('gruppi_err').hide();
                $('select_err').hide();
                f = $('gruppo_gr');

                for(i=0;i<f.length;i++)
                    f.options[i].selected = true;

                if(f.length==0)
                    $('select_err').show();
                else
                    if($('nome_gr').value!='')
                {

                    sms.cambiaContenuto(p+'/rubrica/aggiungigruppo',$('nuovo_gruppo').serialize(),"POST")
                }
                else
                {
                    $('gruppi_err').show();
                }

            }
            var stringaCut = "";
            function countChars()
            {
                lenght = document.centrof.testo.value.length;

                document.centrof.nsms.value = Math.ceil(lenght/160);

                valore = (160)*(document.centrof.nsms.value);
                //alert(i+' '+valore+' '+lenght);
                if (lenght > valore)
                {
                    if(i != 4) document.centrof.rimasti.value = 160;
                    document.centrof.rimasti.value = stringaCut;
                }
                else if(document.centrof.rimasti.value > 160)
                {
                    document.centrof.rimasti.value = 160;
                }
                else
                {
                    document.centrof.rimasti.value = valore - document.centrof.testo.value.length;

                }
            }

var delay = 1000;
var start_frame = 0;
var timeout,timer2;
function creaSlides() {
	var lis = $('slide-images').getElementsByTagName('li');

	for( i=0; i < lis.length; i++){
		if(i!=0){
			lis[i].style.display = 'none';
		}
	}
	end_frame = lis.length -1;

	start_slideshow(start_frame, end_frame, delay, lis);


}



function start_slideshow(start_frame, end_frame, delay, lis) {

	timeout=setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay);
    
}


function fadeInOut(frame, start_frame, end_frame, delay, lis) {
	return (function() {
		lis = $('slide-images').getElementsByTagName('li');
		Effect.Fade(lis[frame]);
		if (frame == end_frame) { frame = start_frame; } else { frame++; }
		lisAppear = lis[frame];
		setTimeout("Effect.Appear(lisAppear);", 0);
		timer2=setTimeout(fadeInOut(frame, start_frame, end_frame, delay), delay + 1850);
	})

}

function slideFF()
{
    if(ultimo<massimo)
    {
        for(var i=primo;i<ultimo;i++)
        $("a"+i).hide();

     primo=ultimo;
     ultimo=primo+5;
     if(ultimo>massimo)
         ultimo=massimo;
     
    for(i=primo;i<ultimo;i++)
        $("a"+i).show();

   // alert(primo+" "+ultimo);
    }

    
}
function slideRW()
{
    if(primo>=5)
    {
   
    primo=primo-5;
    ultimo=primo+5;
    if(ultimo>=massimo) ultimo=massimo-1;
    for(var i=0;i<massimo;i++)
        if(i>=primo && i<ultimo)
        $("a"+i).show();
        else
            $("a"+i).hide();

  //  alert(primo+"  sd "+ultimo);
    }
}

function arrestaSlideShow()
{
    clearTimeout(timeout);
    clearTimeout(timer2);
    $('stato').update('Arrestato ...');
}
function caricaSlide(li)
{
    var lis = $('slide-images').getElementsByTagName('li');
    for(var i=0;i<lis.length;i++)
        lis[i].style.display="none";
    li.show();
}

function ajaxInfo(pagina,id){
    id.
    $("ajax_info").style.top="50px";
    $("ajax_info").style.left="450px";
}


/************************************************************************************************************
	@fileoverview
	Ajax tooltip
	Copyright (C) 2006  Alf Magne Kalleland(post@dhtmlgoodies.com)

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA


	www.dhtmlgoodies.com
	Alf Magne Kalleland

************************************************************************************************************/

/* Custom variables */

/* Offset position of tooltip */
var x_offset_tooltip = 5;
var y_offset_tooltip = 0;

/* Don't change anything below here */


var ajax_tooltipObjr = false;
var ajax_tooltipObjl = false;
var ajax_tooltipObj_iframe = false;

var ajax_tooltip_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)ajax_tooltip_MSIE=true;



var currentTooltipObject = false;

function ajax_showTooltip(e,externalFile,inputObj,l)
{
	currentTooltipObject = inputObj;
	//window.onresize = function(e) { ajax_positionTooltip(e); } ;
   if(document.all)e = event;


	if(!ajax_tooltipObjr && l == 0)	/* Tooltip div not created yet ? */
	{
		ajax_tooltipObjr = document.createElement('DIV');
		ajax_tooltipObjr.style.position = 'absolute';
		ajax_tooltipObjr.id = 'ajax_tooltipObj';

		document.body.appendChild(ajax_tooltipObjr);


		var leftDiv = document.createElement('DIV');	/* Create arrow div */

        leftDiv.className='ajax_tooltip_arrow_r';
        leftDiv.id = 'ajax_tooltip_arrow';
		ajax_tooltipObjr.appendChild(leftDiv);

		var contentDiv = document.createElement('DIV'); /* Create tooltip content div */

        contentDiv.className = 'ajax_tooltip_content_r';
		ajax_tooltipObjr.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_contentr';
		contentDiv.style.marginBottom = '15px';

		// Creating button div
		var buttonDiv = document.createElement('DIV');
		buttonDiv.style.cssText = 'position:absolute;left:50%;bottom:20px;text-align:center;background-color:#FFF;font-size:0.8em;height:15px;z-index:10000000';
		
		ajax_tooltipObjr.appendChild(buttonDiv);

		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObjr.style.cursor = 'move';
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}
	}
    else if(!ajax_tooltipObjl && l == 1)	/* Tooltip div not created yet ? */
	{
		ajax_tooltipObjl = document.createElement('DIV');
		ajax_tooltipObjl.style.position = 'absolute';
		ajax_tooltipObjl.id = 'ajax_tooltipObj';

		document.body.appendChild(ajax_tooltipObjl);


		var leftDiv = document.createElement('DIV');	/* Create arrow div */

        leftDiv.className='ajax_tooltip_arrow_l';
        leftDiv.id = 'ajax_tooltip_arrow';
		ajax_tooltipObjl.appendChild(leftDiv);

		var contentDiv = document.createElement('DIV'); /* Create tooltip content div */

        contentDiv.className = 'ajax_tooltip_content_l';
		ajax_tooltipObjl.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_contentl';
		contentDiv.style.marginBottom = '15px';

		// Creating button div
		var buttonDiv = document.createElement('DIV');
		buttonDiv.style.cssText = 'position:absolute;left:50%;bottom:20px;text-align:center;background-color:#FFF;font-size:0.8em;height:15px;z-index:10000000';

		ajax_tooltipObjl.appendChild(buttonDiv);

		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObjl.style.cursor = 'move';
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}
	}
    
	// Find position of tooltip
	if(l == 1)
    {
        ajax_tooltipObjl.style.display='block';
        ajax_loadContent('ajax_tooltip_contentl',externalFile);
        if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObjl.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObjl.clientHeight + 'px';
	}
    }
    else
    {
        ajax_tooltipObjr.style.display='block';
        ajax_loadContent('ajax_tooltip_contentr',externalFile);
        if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObjr.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObjr.clientHeight + 'px';
	}
    }
	


	ajax_positionTooltip(e,inputObj,l);
}

function ajax_positionTooltip(e,inputObj,l)
{
	var tooltipWidth;
   
   if(l == 1)
    {
        tooltipWidth = document.getElementById('ajax_tooltip_contentl').offsetWidth +  document.getElementById('ajax_tooltip_arrow').offsetWidth;
    }
    else {
       tooltipWidth = document.getElementById('ajax_tooltip_contentr').offsetWidth +  document.getElementById('ajax_tooltip_arrow').offsetWidth;
    }
    if(!inputObj)inputObj=currentTooltipObject;
	if(inputObj){
        var leftPos;
        if(l == 1)
           leftPos = (ajaxTooltip_getLeftPos(inputObj) - tooltipWidth) ;
        else
          leftPos = (ajaxTooltip_getLeftPos(inputObj) + (inputObj.offsetWidth)) ;
		var topPos = ajaxTooltip_getTopPos(inputObj);
        
	}else{
	   var leftPos = e.clientX;
	   var topPos = e.clientY;
	}
   
   if(l == 1)
    {
         ajax_tooltipObjl.style.left = leftPos + 'px';
   ajax_tooltipObjl.style.top = topPos + 'px';
    }
    else {
      ajax_tooltipObjr.style.left = leftPos + 'px';
   ajax_tooltipObjr.style.top = topPos + 'px';
    }
}

function ajax_hideTooltip()
{
	if(ajax_tooltipObjr) ajax_tooltipObjr.style.display='none';
    if(ajax_tooltipObjl) ajax_tooltipObjl.style.display='none';
}

function ajaxTooltip_getTopPos(inputObj)
{
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function ajaxTooltip_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}

/************************************************************************************************************
Ajax dynamic content
Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com


************************************************************************************************************/

var enableCache = true;
var jsCache = new Array();

var dynamicContent_ajaxObjects = new Array();

function ajax_showContent(divId,ajaxIndex,url,callbackOnComplete)
{
	var targetObj = document.getElementById(divId);
	targetObj.innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;
	if(enableCache){
		jsCache[url] = 	dynamicContent_ajaxObjects[ajaxIndex].response;
	}
	dynamicContent_ajaxObjects[ajaxIndex] = false;

	ajax_parseJs(targetObj);

	if(callbackOnComplete) {
		executeCallback(callbackOnComplete);
	}
}

function executeCallback(callbackString) {
	if(callbackString.indexOf('(')==-1) {
		callbackString = callbackString + '()';
	}
	try{
		eval(callbackString);
	}catch(e){

	}


}

function ajax_loadContent(divId,url,callbackOnComplete)
{
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		ajax_parseJs(document.getElementById(divId))
		evaluateCss(document.getElementById(divId))
		if(callbackOnComplete) {
			executeCallback(callbackOnComplete);
		}
		return;
	}

	var ajaxIndex = dynamicContent_ajaxObjects.length;

	document.getElementById(divId).innerHTML = 'Caricamento in corso...';

	dynamicContent_ajaxObjects[ajaxIndex] = new sack();

	if(url.indexOf('?')>=0){
		dynamicContent_ajaxObjects[ajaxIndex].method='GET';
		var string = url.substring(url.indexOf('?'));
		url = url.replace(string,'');
		string = string.replace('?','');
		var items = string.split(/&/g);
		for(var no=0;no<items.length;no++){
			var tokens = items[no].split('=');
			if(tokens.length==2){
				dynamicContent_ajaxObjects[ajaxIndex].setVar(tokens[0],tokens[1]);
			}
		}
		url = url.replace(string,'');
	}


	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;	// Specifying which file to get
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url,callbackOnComplete); };	// Specify function that will be executed after file has been found
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function


}

function ajax_parseJs(obj)
{
	var scriptTags = obj.getElementsByTagName('SCRIPT');
	var string = '';
	var jsCode = '';
	for(var no=0;no<scriptTags.length;no++){
		if(scriptTags[no].src){
	        var head = document.getElementsByTagName("head")[0];
	        var scriptObj = document.createElement("script");

	        scriptObj.setAttribute("type", "text/javascript");
	        scriptObj.setAttribute("src", scriptTags[no].src);
		}else{
			if(navigator.userAgent.toLowerCase().indexOf('opera')>=0){
				jsCode = jsCode + scriptTags[no].text + '\n';
			}
			else
				jsCode = jsCode + scriptTags[no].innerHTML;
		}

	}

	if(jsCode)ajax_installScript(jsCode);
}


function ajax_installScript(script)
{
    if (!script)
        return;
    if (window.execScript){
    	window.execScript(script)
    }else if(window.jQuery && jQuery.browser.safari){ // safari detection in jQuery
        window.setTimeout(script,0);
    }else{
        window.setTimeout( script, 0 );
    }
}


function evaluateCss(obj)
{
	var cssTags = obj.getElementsByTagName('STYLE');
	var head = document.getElementsByTagName('HEAD')[0];
	for(var no=0;no<cssTags.length;no++){
		head.appendChild(cssTags[no]);
	}
}
/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
   see documentation or authors website for more details */

function sack(file) {
	this.xmlhttp = null;

	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName = elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							/* These lines were added by Alf Magne Kalleland ref. info on the sack home page. It prevents memory leakage in IE */

							delete self.xmlhttp['onreadystatechange'];
							self.xmlhttp=null;
							self.responseStatus=null;
							self.response=null;
							self.responseXML=null;

							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}


function disableEnterKey(e)
{
     var key;
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox

     return (key != 13);
}





