/**
*
* UTF-8 data encode / decode
* http://www.webtoolkit.info/
*
**/

var Utf8 = {

    // public method for url encoding
    encode : function (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;
    },

    // public method for url decoding
    urlencode : function (utftext) {

        var txt=Utf8.encode(utftext);
        txt=txt.replace("/"," ");
        return escape(txt);
    },


    // public method for url decoding
    decode : function (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 Show_Div(sDiv){
document.getElementById("Div_Base_01").style.display = "none";
document.getElementById("Div_Base_02").style.display = "none";
document.getElementById("Div_Base_03").style.display = "none";
document.getElementById('Menu_BASE01').className = "menumiddle";
document.getElementById('Menu_BASE02').className = "menumiddle";
document.getElementById('Menu_BASE03').className = "menumiddle";
if (sDiv == "BASE01"){document.getElementById("Div_Base_01").style.display = "";document.getElementById('Menu_BASE01').className = "menumiddle_selected_orange";}
if (sDiv == "BASE02"){document.getElementById("Div_Base_02").style.display = "";document.getElementById('Menu_BASE02').className = "menumiddle_selected_orange";}
if (sDiv == "BASE03"){document.getElementById("Div_Base_03").style.display = "";document.getElementById('Menu_BASE03').className = "menumiddle_selected_orange";}
}
function Show_Base_Annuaire(){
var sName = document.getElementById("Search_homepage1_TextBox1").value;
var sRubrique = document.getElementById("Search_homepage1_Textbox23").value;
var sCity = document.getElementById("Search_homepage1_Textbox2").value;
document.location.href=CommonUrlAnnuaire+'/buslist+f'+Utf8.urlencode(sName)+'/rub+f'+Utf8.urlencode(sRubrique)+'/geo+f'+Utf8.urlencode(sCity)+"?"+CommonUrlSID;
}
function Show_Base_Restaurant(){
var sName = document.getElementById("Search_homepage1_Textbox9").value;
var sCity = document.getElementById("Search_homepage1_Textbox10").value;
document.location.href=CommonUrlRestaurant+'/buslist+f'+Utf8.urlencode(sName)+'/geo+f'+Utf8.urlencode(sCity)+"?"+CommonUrlSID;
}
function Show_Base_Google(){
var sGoogleSearch = document.getElementById("Search_homepage1_Textbox11").value;
if (sGoogleSearch == ""){alert("No word was entered in your search");
}else{
document.getElementById("sbi").value = sGoogleSearch;
document.getElementById('sbb').click();
}
}
function Show_Base_News(){
alert("Please include a hotel or a city");
}

var newWin = null;
function closeWin(){
if (newWin != null){
if(!newWin.closed)
newWin.close();
}
}
function popUp(strURL,strType,strWidth,strHeight) {
closeWin();
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
} 

function RunFoo(swf, hauteur, largeur, couleur, nom) {
document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""+hauteur+"\" height=\""+largeur+"\" id=\""+nom+"\" align=\"middle\">\n");
document.write("<param name=\"allowScriptAccess\" value=\"always\" />\n");
document.write("<param name=\"movie\" value=\""+swf+"\" />\n");
document.write("<param name=\"quality\" value=\"high\" />\n");
document.write("<param name=\"bgcolor\" value=\""+couleur+"\" />\n");
document.write("<param name=\"WMODE\" value=\"Transparent\" />\n");
document.write("<embed src=\""+swf+"\" quality=\"high\" bgcolor=\""+couleur+"\" width=\""+hauteur+"\" height=\""+largeur+"\" name=\""+nom+"\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n");
document.write("</object>\n");
}

function calcFrameImgHeight(obj)
{
  //find the height of the internal page
  var the_height=obj.contentWindow.document.body.scrollHeight;
  //change the height of the iframe
  obj.height=the_height;
}

