﻿function ouvrepop()
{
window.open('/_layouts/portbayonne/localisation/map_handler.html','Localisation','menubar=no, status=no, scrollbars=no, menubar=no, width=895, height=600'); 
}


function changeAction(actionURL) {
    document.forms[0].action = actionURL;
}

function PopupImage(img) {
        titre="ZOOM - Port de Bayonne";
w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no');        
        w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
        w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
        w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
        w.document.write("");
        w.document.write("</BODY></HTML>");
        w.document.close();
}

function popUp(href) {
    window.open(href, 'Titre', 'height=400, width=400, toolbar=no, menubar=no, location=no, resizable=no, scrollbars=yes, status=no')
}

function GoPage(page) {
    var t = document.getElementById('resultat');
    if (page == "previous") {
        res = Table.pagePrevious(t);
    }
    else {
        res = Table.pageNext(t);
    }
}
/* Recherche */
var HIGH_SURROGATE_BITS = 0xD800;
var SURROGATE_6_BIT = 0xFC00;
var SURROGATE_OFFSET = 0x10000;
function escapeProperlyCoreCore(str, bAsUrl, bForFilterQuery, bForCallback) {
    var strOut = "";
    var strByte = "";
    var ix = 0;
    var strEscaped = " \"%<>\'&";
    if (typeof (str) == "undefined")
        return "";
    for (ix = 0; ix < str.length; ix++) {
        var charCode = str.charCodeAt(ix);
        var curChar = str.charAt(ix);
        if (bAsUrl && (curChar == '#' || curChar == '?')) {
            strOut += str.substr(ix);
            break;
        }
        if (bForFilterQuery && curChar == '&') {
            strOut += curChar;
            continue;
        }
        if (charCode <= 0x7f) {
            if (bForCallback) {
                strOut += curChar;
            }
            else {
                if ((charCode >= 97 && charCode <= 122) ||
					 (charCode >= 65 && charCode <= 90) ||
					 (charCode >= 48 && charCode <= 57) ||
					 (bAsUrl && (charCode >= 32 && charCode <= 95) && strEscaped.indexOf(curChar) < 0)) {
                    strOut += curChar;
                }
                else if (charCode <= 0x0f) {
                    strOut += "%0" + charCode.toString(16).toUpperCase();
                }
                else if (charCode <= 0x7f) {
                    strOut += "%" + charCode.toString(16).toUpperCase();
                }
            }
        }
        else if (charCode <= 0x07ff) {
            strByte = UTF8_1ST_OF_2 | (charCode >> 6);
            strOut += "%" + strByte.toString(16).toUpperCase();
            strByte = UTF8_TRAIL | (charCode & 0x003f);
            strOut += "%" + strByte.toString(16).toUpperCase();
        }
        else if ((charCode & SURROGATE_6_BIT) != HIGH_SURROGATE_BITS) {
            strByte = UTF8_1ST_OF_3 | (charCode >> 12);
            strOut += "%" + strByte.toString(16).toUpperCase();
            strByte = UTF8_TRAIL | ((charCode & 0x0fc0) >> 6);
            strOut += "%" + strByte.toString(16).toUpperCase();
            strByte = UTF8_TRAIL | (charCode & 0x003f);
            strOut += "%" + strByte.toString(16).toUpperCase();
        }
        else if (ix < str.length - 1) {
            var charCode = (charCode & 0x03FF) << 10;
            ix++;
            var nextCharCode = str.charCodeAt(ix);
            charCode |= nextCharCode & 0x03FF;
            charCode += SURROGATE_OFFSET;
            strByte = UTF8_1ST_OF_4 | (charCode >> 18);
            strOut += "%" + strByte.toString(16).toUpperCase();
            strByte = UTF8_TRAIL | ((charCode & 0x3f000) >> 12);
            strOut += "%" + strByte.toString(16).toUpperCase();
            strByte = UTF8_TRAIL | ((charCode & 0x0fc0) >> 6);
            strOut += "%" + strByte.toString(16).toUpperCase();
            strByte = UTF8_TRAIL | (charCode & 0x003f);
            strOut += "%" + strByte.toString(16).toUpperCase();
        }
    }
    return strOut;
}
function MySubmitSearchRedirect(strUrl) {
    var frm = document.forms[MSOWebPartPageFormName];
    var searchText = frm.elements["MySearchString"].value;
    if (searchText.length > 1) {
        strUrl += "?k=" + escapeProperlyCoreCore(searchText, false, false, false);
        window.location = strUrl;
    }
}

function MySearchKeyDown(event, strUrl) {
    if (IsKeyDownSubmit(event)) {
        MySubmitSearchRedirect(strUrl);
        return false;
    }
    return true;
}
function IsKeyDownSubmit(event) {
    if (event != null) {
        var charCode;
        var bKeyModifiers;
        if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
            charCode = event.keyCode;
            bKeyModifiers = event.altKey || event.ctrlKey;
        }
        else {
            charCode = event.which;
            bKeyModifiers = event.modifers &
						   (event.ALT_MASK | event.CONTROL_MASK);
        }
        if ((charCode == 13) && !bKeyModifiers)
            return true;
    }
    return false;
}


function displayOnOff(id)
{
    var _elt = document.getElementById(id);
	if (_elt) 
	{
		if (_elt.style.display == 'block')
		{
			_elt.style.display='none';
		}
		else
		{
			_elt.style.display='block';
		}
	}
}
