var wndhnd

function ReplaceAll(item,OldChar,NewChar)
{

  var _ret="";
  var _flag=0;
  var _item=item.split("");
  for(var i=0;i<_item.length;i++)
  {
    if(_item[i] == OldChar)
     {
       _item[i]=NewChar;
       
     }
     _ret+=_item[i];
  }
  return(_ret);
}

function OpenTender(x,y,z,id){
    envname = id;
    if (typeof(z)=='undefined'){
        z='';
    }
    CloseWin();
    if(z=='')
        z = 'directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,top=20,left=20,width=660,height=550';
    
    wndhnd = OpenWindow(x,y,z);
}

function Help(ID_Text, NoPanel, CommentUrl)
{
  var loc = window.location.href ;
  loc = loc.toLowerCase();
  
  if(NoPanel!=null){
        NoPanel = true;
   }else{
        NoPanel = false;
   } 
     
  CommentUrl = ReplaceAll(loc, "&", "#");
  CommentUrl = ReplaceAll(CommentUrl, "?", "§");
  
  i = loc.lastIndexOf("comhelp.aspx",0)
  var dest='';
  if(i>=0){
       if(ID_Text!=''){
            CommentPage = "comHelp.aspx?idtext=" + ID_Text;
            dest = "comHelp.aspx?idtext=" + ID_Text;
           if(NoPanel){
                dest  =dest + "&NoPanel=true";
            }     
            dest+="&CommentPage=" + CommentPage + "&CommentUrl=" + CommentUrl;
       }else {
            CommentPage = "comHelp.aspx";
            dest = "comHelp.aspx?"
           if(NoPanel){
                dest  =dest + "NoPanel=true&";
            }     
            dest+="CommentPage=" + CommentPage + "&CommentUrl=" + CommentUrl;
       }  
       window.location = dest;
  }else{  
      if(ID_Text!=''){
            CommentPage = "comHelp.aspx?idtext=" + ID_Text;
            dest = "comHelp.aspx?idtext=" + ID_Text;
           if(NoPanel){
                dest  =dest + "&NoPanel=true";
            }
            dest+="&CommentPage=" + CommentPage + "&CommentUrl=" + CommentUrl;
       }else {
            CommentPage = "comHelp.aspx";
            dest = "comHelp.aspx?"; 
            if(NoPanel){
                dest  =dest + "NoPanel=true&";
            }
            dest+="CommentPage=" + CommentPage + "&CommentUrl=" + CommentUrl;
       }  
        OpenWindow(dest,"Help","Max3","",""); 
    }
}
function ChangeLang(x)
{
	strLoc = window.location.href;
	strLoc = strLoc.replace(/&lang=EN/i,"");
	strLoc = strLoc.replace(/&lang=FR/i,"");
	strLoc = strLoc.replace(/&lang=NL/i,"");
	strLoc = strLoc.replace(/\?lang=EN&/i,"?");
	strLoc = strLoc.replace(/\?lang=FR&/i,"?");
	strLoc = strLoc.replace(/\?lang=NL&/i,"?");
	strLoc = strLoc.replace(/\?lang=EN/i,"?");
	strLoc = strLoc.replace(/\?lang=FR/i,"?");
	strLoc = strLoc.replace(/\?lang=NL/i,"?");
	p = strLoc.indexOf("?")
	if(p==-1){
		strLoc = strLoc + "?"
	}else{
		if(p+1!=strLoc.length){
			strLoc = strLoc + "&"
		}
	}
	strLoc = strLoc + "lang=" + x
	window.location.href = strLoc 
}

function OpenWindow(x,y,z,intWidth,intHeight)
{
    CloseWin();
    if(typeof(z)=="undefined"){
	    z="";
    }
    if(typeof(intWidth)=="undefined" || typeof(intHeight)=="undefined"){
        intWidth = 0;
        intHeight = 0;
    }
    if(z==""){
        if(intWidth > 50 && intHeight > 50 && intWidth < screen.width-20 && intHeight < screen.height-20){
            z = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,top=10,left=10,width=" + intWidth + ",height=" + intHeight; 
        }
        else{
            z = "directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,top=20,left=20,width=600,height=600";
        }
    }else{
        if(z=="Max"){
	        width = screen.width - 40;
	        if (width > 1024) width = 1024;
	        height = screen.height - 70;
	        z = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,top=10,left=10,width=" + width + ",height=" + height; }
        if(z=="Max1"){
	        width = screen.width - 60;
	        if (width > 1024) width = 1024;
	        height = screen.height - 90;
	        z = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,top=30,left=30,width=" + width + ",height=" + height; }
        if(z=="Max2"){
	        width = screen.width-30;
	        if (width > 1024) width = 1024;
	        height = screen.height-60;
	        z = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,top=0,left=0,width=" + width + ",height=" + height; }
	    if(z=="Max3"){
	        if(screen.width>1400){ 
	            width = screen.width/2;
	        }else{
	            width = 700;
	        } 
	        height = screen.height-30;
	        z = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,top=0,left=0,width=" + width + ",height=" + height; }
	}
    wndhnd = window.open(x,y,z);
    if(wndhnd !=  null) wndhnd.focus();
}

function CloseWin(){
  if(typeof(wndhnd)=="object")
  {
    if(wndhnd.closed==false)
    {
      wndhnd.close();
    }
  }
}
