// JavaScript Document


function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}
function make_blank(textbox, textstr) {
    if (document.aspnetForm[textbox].value == textstr) {
        document.aspnetForm[textbox].value = "";
    }
}
function add_textback(textbox, textstr) {
    if (document.aspnetForm[textbox].value == "") {
        document.aspnetForm[textbox].value = textstr;
    }
}

function bookmarksite() {

    title = document.title;
    url = window.location.href;

    if (window.sidebar) // firefox 
        window.sidebar.addPanel(title, url, "");
    else if (window.opera && window.print) { // opera 
        var elem = document.createElement('a');
        elem.setAttribute('href', url);
        elem.setAttribute('title', title);
        elem.setAttribute('rel', 'sidebar');
        elem.click();
    }
    else if (document.all)// ie 
        window.external.AddFavorite(url, title);
} 


function hidediv(menu) {
    if (document.getElementById) { // DOM3 = IE5, NS6 
        document.getElementById(menu).style.visibility = 'hidden';
    }
    else {
        if (document.layers) { // Netscape 4 
            document.menu.visibility = 'hidden';
        }
        else { // IE 4 
            document.all.menu.style.visibility = 'hidden';
        }
    }
}
function showdiv(menu) {
    if (document.getElementById) { // DOM3 = IE5, NS6 
        document.getElementById(menu).style.visibility = 'visible';
    }
    else {
        if (document.layers) { // Netscape 4 
            document.menu.visibility = 'visible';
        }
        else { // IE 4 
            document.all.menu.style.visibility = 'visible';
        }
    }
}
function hidedivall() {
    if (navigator.appName.indexOf("Microsoft") != -1 || navigator.appName.indexOf("Opera") != -1) {
        document.all.ctl00_ToolBarMenus1_customerservicemenu.style.visibility = 'hidden';
        document.all.minibasket.style.visibility = 'hidden';
    }
    if (navigator.appName == "Netscape" || navigator.appName == "Firefox" || navigator.appName == "Safari") {
        document.getElementById("ctl00_ToolBarMenus1_customerservicemenu").style.visibility = 'hidden';
        document.getElementById("minibasket").style.visibility = 'hidden';
    }
}

function hidedivallforCSM() {
    if (navigator.appName.indexOf("Microsoft") != -1 || navigator.appName.indexOf("Opera") != -1) {
        document.all.minibasket.style.visibility = 'hidden';
    }
    if (navigator.appName == "Netscape" || navigator.appName == "Firefox" || navigator.appName == "Safari") {
        document.getElementById("minibasket").style.visibility = 'hidden';
    }
}




function windowsize() {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        toppos = document.body.clientHeight / 2 - 100;
        leftpos = document.body.clientWidth / 2 - 100;

    }
    else {
        toppos = window.innerHeight / 2 - 100;
        leftpos = window.innerWidth / 2 - 100;
    }
    //alert("toppos: " + toppos);
    //alert("leftpos: " + leftpos);
}
function changeBackground(div1) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        document.all[div1].style.background = '#eae7e2';
    }
    if (navigator.appName.indexOf("Opera") != -1) {
        document.all[div1].style.background = '#eae7e2';
    }
    if (navigator.appName == "Netscape" || navigator.appName == "Firefox" || navigator.appName == "Safari") {
        document.getElementById(div1).style.backgroundColor = '#eae7e2';
    }
}
function undochangeBackground(div1) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        document.all[div1].style.background = '';
    }
    if (navigator.appName.indexOf("Opera") != -1) {
        document.all[div1].style.background = '';
    }
    if (navigator.appName == "Netscape" || navigator.appName == "Firefox" || navigator.appName == "Safari") {
        document.getElementById(div1).style.backgroundColor = '';
    }
}
function setMenuPos() {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        toppos = document.body.clientHeight / 2;
        leftpos = document.body.clientWidth / 2;

        if (document.all.originalfitlayer)
            document.all.originalfitlayer.style.top = 235;
        if (document.all.slimfitlayer)
            document.all.slimfitlayer.style.top = 200;
        if (document.all.vintagefitlayer)
            document.all.vintagefitlayer.style.top = 200;
    }
    else {
        toppos = window.innerHeight / 2;
        leftpos = window.innerWidth / 2;
        if(document.getElementById("originalfitlayer"))
            document.getElementById("originalfitlayer").style.top = 235 + "px";
        if (document.getElementById("slimfitlayer"))
            document.getElementById("slimfitlayer").style.top = 200 + "px";
        if (document.getElementById("vintagefitlayer"))
            document.getElementById("vintagefitlayer").style.top = 200 + "px";            
            
        //alert(leftpos);
    }
    if (leftpos >= 800) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            document.all.ctl00_ToolBarMenus1_customerservicemenu.style.left = leftpos - 215;
            document.all.minibasket.style.left = leftpos + 170;

            if (document.all.originalfitlayer)
                document.all.originalfitlayer.style.left = leftpos - 200;
            if (document.all.slimfitlayer)
                document.all.slimfitlayer.style.left = leftpos + 40;
            if (document.all.vintagefitlayer)
                document.all.vintagefitlayer.style.left = leftpos + 240;                        
        }
        if (navigator.appName.indexOf("Opera") != -1) {
            document.all.ctl00_ToolBarMenus1_customerservicemenu.style.left = leftpos - 254;
            document.all.minibasket.style.left = leftpos + 212;

            if (document.all.originalfitlayer)
                document.all.originalfitlayer.style.left = leftpos - 200;
            if (document.all.slimfitlayer)
                document.all.slimfitlayer.style.left = leftpos + 40;
            if (document.all.vintagefitlayer)
                document.all.vintagefitlayer.style.left = leftpos + 240;            
        }
        if (navigator.appName == "Netscape" || navigator.appName == "Firefox" || navigator.appName == "Safari") {
            document.getElementById("ctl00_ToolBarMenus1_customerservicemenu").style.left = leftpos - 220 + "px";
            document.getElementById("minibasket").style.left = leftpos + 360 + "px";
            if (document.getElementById("originalfitlayer"))
                document.getElementById("originalfitlayer").style.left = leftpos + 360 + "px";
            if (document.getElementById("slimfitlayer"))
                document.getElementById("slimfitlayer").style.left = leftpos + 360 + "px";
            if (document.getElementById("vintagefitlayer"))
                document.getElementById("vintagefitlayer").style.left = leftpos + 360 + "px";
        }
    }
    if (leftpos >= 500) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            document.all.ctl00_ToolBarMenus1_customerservicemenu.style.left = leftpos - 215;
            document.all.minibasket.style.left = leftpos + 170;

            if (document.all.originalfitlayer)
                document.all.originalfitlayer.style.left = leftpos - 200;
            if (document.all.slimfitlayer)
                document.all.slimfitlayer.style.left = leftpos + 40;
            if (document.all.vintagefitlayer)
                document.all.vintagefitlayer.style.left = leftpos + 240;
        }
        if (navigator.appName.indexOf("Opera") != -1) {
            document.all.ctl00_ToolBarMenus1_customerservicemenu.style.left = leftpos - 254;
            document.all.minibasket.style.left = leftpos + 212;

            if (document.all.originalfitlayer)
                document.all.originalfitlayer.style.left = leftpos - 200;
            if (document.all.slimfitlayer)
                document.all.slimfitlayer.style.left = leftpos + 40;
            if (document.all.vintagefitlayer)
                document.all.vintagefitlayer.style.left = leftpos + 240;
        }
        if (navigator.appName == "Netscape" || navigator.appName == "Firefox" || navigator.appName == "Safari") {
            document.getElementById("ctl00_ToolBarMenus1_customerservicemenu").style.left = leftpos - 223 + "px";
            document.getElementById("minibasket").style.left = leftpos + 162 + "px";

            if (document.getElementById("originalfitlayer"))
                document.getElementById("originalfitlayer").style.left = leftpos + -205 + "px";
            if (document.getElementById("slimfitlayer"))
                document.getElementById("slimfitlayer").style.left = leftpos + 35 + "px";
            if (document.getElementById("vintagefitlayer"))
                document.getElementById("vintagefitlayer").style.left = leftpos + 235 + "px";
        }
    }
    if (leftpos <= 499) {

        if (navigator.appName.indexOf("Microsoft") != -1 || navigator.appName.indexOf("Opera") != -1) {
            if (document.all.originalfitlayer)
                document.all.originalfitlayer.style.left = leftpos - 190;
            if (document.all.slimfitlayer)
                document.all.slimfitlayer.style.left = leftpos + 40;
            if (document.all.vintagefitlayer)
                document.all.vintagefitlayer.style.left = leftpos + 185;

            document.all.ctl00_ToolBarMenus1_customerservicemenu.style.left = 255;
            document.all.minibasket.style.left = 255;
            //document.all.breadcrumbs.style.left = 210; 
        }
        if (navigator.appName.indexOf("Opera") != -1) {
            document.all.ctl00_ToolBarMenus1_customerservicemenu.style.left = 250;
            document.all.minibasket.style.left = 805;

            if (document.all.originalfitlayer)
                document.all.originalfitlayer.style.left = leftpos - 190;
            if (document.all.slimfitlayer)
                document.all.slimfitlayer.style.left = leftpos + 50;
            if (document.all.vintagefitlayer)
                document.all.vintagefitlayer.style.left = leftpos + 245;

            //document.all.breadcrumbs.style.left = 210;
        }
        if (navigator.appName == "Netscape" || navigator.appName == "Firefox" || navigator.appName == "Safari") {
            document.getElementById("ctl00_ToolBarMenus1_customerservicemenu").style.left = 280 + "px";
            document.getElementById("minibasket").style.left = 302 + "px";
            document.getElementById("minibasket").style.left = leftpos + 162 + "px";

            if (document.getElementById("originalfitlayer"))
                document.getElementById("originalfitlayer").style.left = leftpos + -205 + "px";
            if (document.getElementById("slimfitlayer"))
                document.getElementById("slimfitlayer").style.left = leftpos + 35 + "px";
            if (document.getElementById("vintagefitlayer"))
                document.getElementById("vintagefitlayer").style.left = leftpos + 185 + "px";

            //document.getElementById("breadcrumbs").style.left = 152 + "px";
            
        }
    }
}

function load() {

    GetURL();
}

function GetURL() {
    var url = document.location.href;
    //alert(url);

    if (url.indexOf('contact-details') > 0) {
        //Function only exists on contact details page in CMS
        //attachmap(53.70397,-0.88946);
        ContactDetailsAttachMap();
    }
    if (url.indexOf('baracuta-shop') > 0) {
        //Function only exists on contact details page in CMS
        //attachmap(53.70397,-0.88946);
        LondonShopDetailsAttachMap();
    }
}

function attachmap(lat,lon) {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(lat,lon), 13);
        var point = new GLatLng(-0.88946,53.70397);
        map.addOverlay(new GMarker(point));
    }
}

function ContactDetailsAttachMap() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(53.70397, -0.88946), 13);
        var point = new GLatLng(53.70397, -0.88946);
        map.addOverlay(new GMarker(point));
        map.setUIToDefault();
    }
}

function LondonShopDetailsAttachMap() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(51.51425, -0.12656), 13);
        var point = new GLatLng(51.51425, -0.12656);
        map.addOverlay(new GMarker(point));
        map.setUIToDefault();
    }
}

function CopyRegFields() {

    var ShipAddress1 = "";
    var ShipAddress2 = "";
    var ShipCity = "";
    var ShipState = "";
    var ShipStateIndex = 0;
    var ShipZip = "";
}


function InitSaveVariables(form) {
    ShipAddress1 = form.ctl00_ContentPlaceHolder1_Registration1_SAddress1TextBox.value;
    ShipAddress2 = form.ctl00_ContentPlaceHolder1_Registration1_SAddress2TextBox.value;
    ShipCity = form.ctl00_ContentPlaceHolder1_Registration1_SCityTextBox.value;
    ShipZip = form.ctl00_ContentPlaceHolder1_Registration1_SPostcodeTextBox.value;
    ShipStateIndex = form.ctl00_ContentPlaceHolder1_Registration1_SCountryDropDownList.selectedIndex;
    ShipState = form.ctl00_ContentPlaceHolder1_Registration1_SCountryDropDownList[ShipStateIndex].value;
}

    function ShipToBillPerson(form) {
        if (form.ShippingSameAsAddressCheckBox.checked) {
        InitSaveVariables(form);
        form.ctl00_ContentPlaceHolder1_Registration1_SAddress1TextBox.value = form.ctl00_ContentPlaceHolder1_Registration1_Address1TextBox.value;
        form.ctl00_ContentPlaceHolder1_Registration1_SAddress2TextBox.value = form.ctl00_ContentPlaceHolder1_Registration1_Address2TextBox.value;
        form.ctl00_ContentPlaceHolder1_Registration1_SCityTextBox.value = form.ctl00_ContentPlaceHolder1_Registration1_CityTextBox.value;
        form.ctl00_ContentPlaceHolder1_Registration1_SPostcodeTextBox.value = form.ctl00_ContentPlaceHolder1_Registration1_PostcodeTextBox.value;
        form.ctl00_ContentPlaceHolder1_Registration1_SCountryDropDownList.selectedIndex = form.ctl00_ContentPlaceHolder1_Registration1_BCountryDropDownList.selectedIndex;
    }
    else {
        form.ctl00_ContentPlaceHolder1_Registration1_SAddress1TextBox.value = ShipAddress1;
        form.ctl00_ContentPlaceHolder1_Registration1_SAddress2TextBox.value = ShipAddress2;
        form.ctl00_ContentPlaceHolder1_Registration1_SCityTextBox.value = ShipCity;
        form.ctl00_ContentPlaceHolder1_Registration1_SPostcodeTextBox.value = ShipZip;
        form.ctl00_ContentPlaceHolder1_Registration1_SCountryDropDownList.selectedIndex = ShipStateIndex;
    }
}
