	function go(theParam, theValue) {
			var vParams = new Array();
			if (location.search != '') {
				vParams = location.search.substring(1).split("&");
			}

			for (j=0; j < arguments.length-1; j+=2) {
				bFound = false;
				
				for (i=0; i < vParams.length; i++) {
					if (vParams[i].substring(0,vParams[i].indexOf("=")) == arguments[j]) {
						var modifier = "";
						if ((vParams[i] == arguments[j] + "=" + arguments[j+1]) && (arguments[j]=='sort') && (arguments[j+1]!='')) modifier = " DESC";
						vParams[i] = arguments[j] + "=" + escape(arguments[j+1]) + modifier;
						bFound = true;
					}
				}
				if (!bFound) vParams[vParams.length] = arguments[j] + "=" + escape(arguments[j+1]);
			}
		
			theParams = vParams.join("&amp;");
			if (theParams!='') theParams = "?" + theParams;

			theURL = "http://" + location.host + location.pathname + theParams;
			
			if (((arguments.length % 2)==1)) {
				if (arguments[arguments.length-1]=='new') {
					window.open(theURL,'_blank','status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=500,height=400');
				} else {
					theURL = arguments[arguments.length-1] + theParams;
					location.href = theURL;
				}
			} else {
				location.href = theURL;
			}
		}

	function clearUrl(theParam) {
			var vParams = new Array();
			if (location.search != '') {
				vParams = location.search.substring(1).split("&");
			}

			for (j=0; j < arguments.length; j+=1) {
				bFound = false;
				
				for (i=0; i < vParams.length; i++) {
					if (vParams[i].substring(0,vParams[i].indexOf("=")) == arguments[j]) {
						var modifier = "";
						vParams.splice(i, 1);
						bFound = true;
					}
				}
			}
		
			theParams = vParams.join("&amp;");
			if (theParams!='') theParams = "?" + theParams;

			theURL = "http://" + location.host + location.pathname + theParams;
			
			location.href = theURL;
		}

	function searchPage(theTot) {
		el = document.getElementById("pagetosearch");
		theReqPage = el.value;

		if(theReqPage == "") {
			alert("Inserire un numero di pagina.");
			el.focus();
			return;
		} else if(theReqPage == 0 || theReqPage < 0) {
			if(theReqPage == 1) {
				theMsg = "pari a";
			} else {
				theMsg = "minore di";
			}
			alert("Il numero non puņ essere " + theMsg + " 0.");
			el.value = 1;
			el.focus();
			return;
		} else if(isNaN(theReqPage)) {
			if(theReqPage.toString().indexOf(",") != -1) {
				alert("Nel campo non sono ammesse cifre decimali.");
				el.value = 1;
				el.focus();
				return;
			}
			alert("Inserire nel campo un valore numerico.");
			el.value = 1;
			el.focus();
			return;
		} else if (theReqPage.toString().indexOf(".") != -1) {
			alert("Nel campo non sono ammesse cifre decimali.");
			el.value = 1;
			el.focus();
			return;
		} else if(theReqPage > theTot) {
			theReqPage = theTot;
		}

		go('page',theReqPage);
	}

	function updateLauncher (theImage) {

		window.opener.launcher.value = theImage;
		//window.opener.resetFieldsLook();
		window.close();

	}

	function showImage(theImage, thePage) {

		if(thePage) {
			theUrl = thePage + "?img="+theImage;
		} else {
			theUrl = theImage;
		}

	window.open(theUrl,'image','width=550,height=550,scrollbars=yes,resizable=yes');

	}

	function addDid(thePath, theID) {

		if(theID) {
			theUrl = thePath + "&id_foto="+theID;
		} else {
			theUrl = thePath;
		}

	window.open(theUrl,'did','width=550,height=550,scrollbars=yes,resizable=yes');

	}

var openImg = new Image();
openImg.src = "http://www.studyabroadworld.org/_w4pub_shared/_img/icone/open.gif";
var closedImg = new Image();
closedImg.src = "http://www.studyabroadworld.org/_w4pub_shared/_img/icone/closed.gif";


function showBranch(branch){
	var objBranch = document.getElementById(branch).style;
	if(objBranch.display=="block")
		objBranch.display="none";
	else
		objBranch.display="block";
}

function swapFolder(img){
	objImg = document.getElementById(img);
	if(objImg.src.indexOf('closed.gif')>-1)
		objImg.src = openImg.src;
	else
		objImg.src = closedImg.src;
}

function checkLogin(theLang){
	if(theLang){
		theLangParam = "?lang=" + theLang;
	} else {
		theLangParam = "";
	}
	window.open('checklogin.php' + theLangParam, 'checklogin', 'width=350,height=350,status=no,scrollbars=yes,resizable=yes');
}

function checkCode(theLang){
	if(theLang){
		theLangParam = "?lang=" + theLang;
	} else {
		theLangParam = "";
	}
	window.open('checkcode.php' + theLangParam, 'checkcode', 'width=350,height=350,status=no,scrollbars=yes,resizable=yes');
}

function doLogout(theLang){
	if(theLang){
		theLangParam = "?lang=" + theLang;
	} else {
		theLangParam = "";
	}
	window.open('dologout.php' + theLangParam, 'dologout', 'width=15,height=15,status=no,scrollbars=no,resizable=no');
}

function remindMyPwd(theLang) {
	if(theLang){
		theLangParam = "?lang=" + theLang;
	} else {
		theLangParam = "";
	}
	window.open('reminder.php' + theLangParam, 'dologout', 'width=350,height=350,status=no,scrollbars=no,resizable=no');
}

function setCode() {
	el = document.forms["check"].elements["code"];
	theCode = el.value;
	if(theCode == "") {
		alert("Inserire un codice di sconto oppure chiudere la finestra se non lo si possiede.");
		el.focus();
		return(false);
	}
	go('code', theCode);
}