// JavaScript Document

  // define wanted languages - 'native' first
  lang = new Array ("gb","es","ct","fr","nl","de" );
  
  
  
  
  
  
  
  
  
 /* function init()
  {
	   var refreshrate=10; //SECONDS BETWEEN REFRESH 
  var image="images/picturecam.jpg";       //IMAGE NAME
  function refresh(){
  var getdate = new Date();
  document.images["pic"].src=image+"?"+ getdate;
//  document.getElementById("picgot").innerHTML= getdate;
  setTimeout('refresh()', refreshrate*1000);
  }

 if(document.images)window.onload=refresh;
  
  }*/
 
	function MM_openBrWindow(theURL,winName,features) { //v2.0
  		window.open(theURL,winName,features);
		}
		
	function MM_changeProp(objId,x,theProp,theValue) { //v9.0
 		 var obj = null; with (document){ if (getElementById)
 		 obj = getElementById(objId); }
 		 if (obj){
    		if (theValue == true || theValue == false)
     			eval("obj.style."+theProp+"="+theValue);
   			 else eval("obj.style."+theProp+"='"+theValue+"'");
  			}
	}
	
	  var ns = (navigator.appName.indexOf("Netscape") != -1);
    var d = document;
    function JSFX_FloatDiv(id, sx, sy)
    {
        var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
        var px = document.layers ? "" : "px";
        window[id + "_obj"] = el;
        if(d.layers)el.style=el;
        el.cx = el.sx = sx;el.cy = el.sy = sy;
        el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};

        el.floatIt=function()
        {
                var pX, pY;
                pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
                document.documentElement && document.documentElement.clientWidth ? 
                document.documentElement.clientWidth : document.body.clientWidth;
                pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
                document.documentElement.scrollTop : document.body.scrollTop;
                if(this.sy<0) 
                pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
                document.documentElement.clientHeight : document.body.clientHeight;
                this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
                this.sP(this.cx, this.cy);
                setTimeout(this.id + "_obj.floatIt()", 40);
        }
        return el;
    }
	
	 function setCookie(c_name,value,exdays)
  {
	  var exdays;
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null)?"":";expires="+exdate.toUTCString());
	document.cookie=c_name + "=" +c_value
	return;
  }

 function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

 function set_flag() {
	  
  document.getElementById('flag_'+ lang_opt_old).style.border="hidden";
  // document.getElementById('flag_'+ lang_opt).style.borderTop="2px solid";
  document.getElementById('flag_'+ lang_opt).style.borderLeft="3px solid";  
  } // END function set_flag
  
  
   function select_lang(new_opt) {
        for(lang_x = 0 ; lang_x <lang_count ; lang_x ++) {
                if(new_opt == lang[lang_x] && document.getElementById(lang[lang_x]) ) { // valid entry found
                        lang_opt_old = lang_opt;
                        lang_opt = new_opt;
                        if(flag_exist) set_flag();
                        document.getElementById(lang_opt_old).style.display="none";
                        document.getElementById(lang_opt).style.display="inline";
						
						//set a cookie = lang_opt
			setCookie("lang_opt",lang_opt,365);
					
                        break;
                }
        }
  } // END function select_lang()


function pick_language()
{
  lang_opt = lang[0]; // pre-set a value
 	lang_opt_old = lang[0]; // pre-set a value
	lang_count = lang.length;

  // build 'flags' options
  	flag_exist = document.getElementById('flags');
	
 	if(flag_exist) {
        flag_table="<table>";
        for(lang_x = 0 ; lang_x <lang_count ; lang_x ++)
				{
       	 	flag_table += "<tr><td><img src=\"" + lang[lang_x] + ".png\" onClick=\"select_lang('" + lang[lang_x] + "');\"  id=\"flag_" + lang[lang_x] +"\" style=\"cursor: hand; \" /><\/td><\/tr>";
        		}
					
		flag_table += "<\/table>";
   		flag_exist.innerHTML= flag_table;
		
    set_flag();
				}

  // find out if we have come from a non-native page
 	posted_opt = " " + this.location;
  	find_it = posted_opt.indexOf('?');
  
		if(document.cookie)posted_opt=getCookie("lang_opt");
		
		
		if (posted_opt!=null && posted_opt!="")select_lang(posted_opt );

	posted_opt = posted_opt.substring(find_it +1); // returns everything after '?' in url
	
  		if(posted_opt.length >= 2) select_lang(posted_opt );	
		
	 var refreshrate=10; //SECONDS BETWEEN REFRESH 
/*	 if(document.images)window.onload=refresh;
	 alert("java 137");
  var image="images/picturecam.jpg";       //IMAGE NAME
  function refresh(){
  var getdate = new Date();
  document.images["pic"].src=image+"?"+ getdate;
//  document.getElementById("picgot").innerHTML= getdate;
  setTimeout('refresh()', refreshrate*1000);
  alert("java 144");
  }	*/
		
		
}
