
function changeList(field, name ){
	g_arr_add_Fields = new Array;
  var divforlist=document.getElementById(name);
  var divforlistframe=document.getElementById(name+'frame');
  var objType =document.getElementById("typefund");
  var objId = document.getElementById("idfund");
  var tmpValue = '';
  if( !objType || objType.value==""||!objId || objId.value=="")
  {
    divforlist.innerHTML ="";
    divforlist.style.visibility="hidden";
    divforlistframe.style.visibility="hidden";
    return;
  }

  tmpValue = field.value
  
  if( divforlist ){
    var objXHR = getXHR();
    objXHR.onreadystatechange = function(){
		  if(objXHR.readyState == 4 && objXHR.status == 200){
		    var text=objXHR.responseText;
		    text+="<br><br><br>";
		    divforlist.innerHTML = text; //
		    divforlist.style.visibility="visible";
		    divforlistframe.style.visibility="visible";
		    divforlistframe.style.width = divforlist.offsetWidth+"px";
		    divforlistframe.style.height = divforlist.offsetHeight+"px";
		    
		  }
	  }
	  
	  type = objType.value;
	  id = objId.value;
	  objXHR.open("POST","/tools/ajax-services/index.lbl",true);
    objXHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    objXHR.send("case=4"+"&id="+id+"&type="+type);
	  
  }
}


function selectDate(selecteddate, valuedate){
	var divforlist=document.getElementById("datelist");
  var divforlistframe=document.getElementById("datelistframe");
  divforlist.innerHTML ="";
  divforlist.style.visibility="hidden";
  divforlistframe.style.visibility="hidden";
  var divInput = document.getElementById("dateselected");
  var divInputHidden = document.getElementById("valuedateselected");
  divInputHidden.value = selecteddate;
  divInput.value = valuedate;
  
}


function openPopup(strUrl, intWidth, intHeight, intTop, intLeft, bolScrollbars, strPopupName){
  if(!strPopupName)
    strPopupName = "_blank";
    
  var strParams = "";
  
  if(intWidth){
    strParams += (strParams!=""?", ":"");
    strParams += "width="+intWidth;
  }
  
  if(intHeight){
    strParams += (strParams!=""?", ":"");
    strParams += "height="+intHeight;
  }
  
  if(intTop){
    strParams += (strParams!=""?", ":"");
    strParams += "top="+intTop;
  }
  
  if(intLeft){
    strParams += (strParams!=""?", ":"");
    strParams += "left="+intLeft;
  }
  
  strParams += (strParams!=""?", ":"");
  strParams += "scrollbars="+(bolScrollbars?"yes":"no");
  
  var oWindow = window.open(strUrl, strPopupName, strParams);
  return oWindow;
}

function openTagPopup(sLBL, intWidth, intHeight, intTop, intLeft, bolScrollbars, strPopupName, intMargin, intMarginTop){
  if(!intMargin)
    intMargin = '';
  if(!intMarginTop)
    intMarginTop = '';
  return openPopup("/tools/popup?s=" + sLBL + "&m=" + intMargin + "&mt=" + intMarginTop, intWidth, intHeight, intTop, intLeft, bolScrollbars, strPopupName)
}

function openImagePopup(sLBL, bReturn){
  if(bReturn)
    return openPopup("/tools/popup?i=" + sLBL + "&m=0&mt=0", 20, 20, 20, 20, false, "popupImage");
  openPopup("/tools/popup?i=" + sLBL + "&m=0&mt=0", 20, 20, 20, 20, false, "popupImage");
}

function openPopupImage(sLBL, bReturn) {
  if(bReturn)
    return openImagePopup(sLBL, true);
  openImagePopup(sLBL);
}

function openVideoPopup(sLBL, intWidth, intHeight, intTop, intLeft, bolScrollbars, strPopupName){
  if(!intWidth)
    intWidth = 400;
  
  if(!intHeight)
    intHeight = 300;
  openPopup("/tools/popup?v=" + sLBL + "&m=" + 0 + "&mt=" + 0, intWidth, intHeight, intTop, intLeft, bolScrollbars, strPopupName)
}

function openLocation(strURL){
  document.location = strURL;
}

function openLegal(){
  openTagPopup("Legal Terms", 300, 400, 0, 0, true, "LEGAL", 5, 5);
}

function openMyAccountHelp(){
  openTagPopup("My Account Help", 300, 400, 0, 0, false, "MY_ACCOUNT_HELP");
}

function openRetailerDetails(uidRetailer, strUrl){
  openPopup(strUrl + "?ur=" + uidRetailer, 586, 411);
}

function openMobileF1() {
  openPopup("/the-brand/multimedia/mobile-phone/f1", 600, 490, 0, 0, 0, "mobilegamesf1");
}
function openMobileIndy() {
  openPopup("/the-brand/multimedia/mobile-phone/indy500", 600, 490, 0, 0, 0, "mobilegamesindy");
}

function openWatchPDF(watchId, strUrl, strOpener, bolForEmail){
  if(!strOpener)
    strOpener = "";
    
  var intWidth = 600, intHeight = 800;
  if(bolForEmail)
    intWidth = intHeight = 400;
  
  openPopup(strUrl + "?w=" + watchId + "&opener=" + strOpener + (bolForEmail?"&foremail=1":""), intWidth, intHeight, 20, 20, 0, "_blank");
}

function openPortfolioPDF(strWatches, strUrl, bolForEmail){    
  var intWidth = 800, intHeight = 600;
  if(bolForEmail)
    intWidth = intHeight = 400;
    
  openPopup(strUrl + "?a=" + strWatches + (bolForEmail?"&foremail=1":""), intWidth, intHeight, 20, 20, 0, "_blank");
}

function print_r(arr, s, msg) {
  if(!s || !s.length) {
    var bEnd = true;
    s = "";
  } else
    var bEnd = false;
    
  if(typeof(arr)!= 'object') {
    alert(arr);
    return arr; 
  }
  var str = "Array\n"+s+"(\n";
  s += "     ";
  for(k in arr) {
    str += s+"["+k+"] => ";
    if(typeof(arr[k])=='object')
      str += print_r(arr[k], s);
    else
      str += arr[k]+"\n";
  }
  str += s.substr(5)+")\n";
  if(bEnd)
    alert(msg?(msg+"\n"+str):str);
  return str;
}

function generate_myinvest(devise, uobj, dateasofsql, dateasof){
	
	if(devise && uobj){
	  var objXHR = getXHR();
  
    objXHR.onreadystatechange = function(){
   
		  if(objXHR.readyState == 4 && objXHR.status == 200){
		    response= objXHR.responseText;
		    
		    if(response!=false)
		      window.open('/_pdf/'+response+'.pdf');
		    else
		      alert('Error, please contact the administrator');
		 
		  }
	  }
    objXHR.open("POST","/tools/ajax-services/index.lbl",true);
    objXHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    objXHR.send("case=3"+"&devise="+devise+"&uobj="+uobj+"&dateasofsql="+dateasofsql+"&dateasof="+dateasof);
	}
}

function displayDescription(fundname){
	
	var div = getE('messagebox');
	var divfund = getE('fund_'+fundname);
	
	var x = getPageX(divfund);
	var y = getPageY(divfund)+20;
	var window_x= document.documentElement.offsetWidth;
	if((x+300)>window_x)
	x= window_x-330;

	if(fundname){
		div.setAttribute('className','divmessagebox');
		div.style.top=y;
	  div.style.left=x;

	   var objXHR = getXHR();
    
	    objXHR.onreadystatechange = function(){
	   
			  if(objXHR.readyState == 4 && objXHR.status == 200){
			    response= objXHR.responseText;
			    if(response!='')
			      div.innerHTML = response;
			    else
			      div.innerHTML = 'No value found';
			  div.style.visibility="visible";
			  }
		  }
	    objXHR.open("POST","/tools/ajax-services/index.lbl",true);
	    objXHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    objXHR.send("case=1"+"&fundname="+fundname);
  }
}
	



function closediv(){
	var div = getE('messagebox');
	div.style.visibility="hidden";
}


function old_confirmleave(lien){
	var answer = confirm('You are trying to connect to a website outside of swissedge.com. Do you want to continue?')
	if (answer){
		 var objXHR = getXHR();
	    objXHR.onreadystatechange = function(){
	   
			  if(objXHR.readyState == 4 && objXHR.status == 200){
			    response= objXHR.responseText;
			    if(response){
							window.location=lien;
			    }
			  }
		  }
	    objXHR.open("POST","/tools/ajax-services/index.lbl",true);
	    objXHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    objXHR.send("case=2");
	}

}

function confirmleave() {
	return confirm(g_leavemsg);
}
	
	
function quickLogin(){
	closediv();
	username = document.forms["formlogin"].username;
	username.focus();
  username.select();
}