//========================================================
//get the identity

    function getMasthead(){
        var html = '';
        html += '<map name="home_map">';
        html += '<area href="a1-home.html" coords="43,6,125,33">';
        html += '<area href="a1-home.html" coords="628,16,715,25">';
        html += '</map>';
        html += '<img src="images/identity.jpg" usemap="#home_map">';
        return html;
    }
	
	 function getMasthead2(unit_name){
        var html = '';
        html += '<div style="position:relative;">';
        html += '<table cellpadding="0" cellspacing="0" border="0" class="masthead"><tr>';
        html += '<td class="identity"><a href="a-home.html"><img src="images/identity2.jpg"></a></td>';
        html += '<td class="unit_flag"><img src="images/masthead-'+ cid +'.jpg"/></td>';
        html += '<td class="unit_name">Otis Switzerland</td>';
        html += '<a href="http://www.otis.com">Go to Otis Worldwide</a><td class="unit_name"></td>';
        html += '</tr></table>';
        html += '</div>';
        return html;
        }


	 function getMasthead3(unit_name){
        var html = '';
        html += '<div style="position:relative;">';
        html += '<table cellpadding="0" cellspacing="0" border="0" class="masthead"><tr>';
        html += '<td class="identity"><img src="images/identity2.jpg"></td>';
        html += '<td class="unit_flag"><img src="images/masthead_'+ cid +'.jpg"/></td>';
        html += '<td class="unit_name">Otis Elevator Company</td>';
        html += '<td class="unit_name2"><a href="http://www.otis.com" class="unit_name2">Go to Otis Worldwide </a></td>';
        html += '</tr></table>';
        html += '</div>';
        return html;
        }
		
		
//========================================================
//main menu/navigation methods

    function getMainMenu(page_id){

        var indexes = page_id.split("_");
        var current_index = parseInt(indexes[0]);
        var struct = getStruct();
        var row_1 = "<tr>"; //highlight caps
        var row_2 = "<tr>"; //labels

        for(var i=0; i<struct.length; i++){

            var cap = (i == current_index)? "cap_on" : "cap_off";
            var nav = (i == current_index)? "nav_on" : "nav_off";
            var jsc = (i == current_index)? ' onClick="document.location = \'' + struct[i].page + '\';"' : 'onMouseOver="onMainOver(this.id);" onMouseOut="onMainOut(this.id);" onClick="document.location = \'' + struct[i].page + '\';"';
            var r1div = (i != struct.length - 1)? '<td></td>' : '';
            var r2div = (i != struct.length - 1)? '<td><img src="images/navdiv.gif"/></td>' : '';

            row_1   += '<td id="cap_' + i + '" class="' + cap + '"><img src="images/spacer.gif" height="5"/></td>' + r1div;
            row_2   += '<td id="nav_' + i + '" class="' + nav + '" ' + jsc + '><span class="nav_txt">' + struct[i].label + '</span></td>' + r2div;
        }

        row_1 += '<td style="width:100%;"><img src="images/spacer.gif"/></td></tr>';
        row_2 += '<td style="width:100%;background-color:#999999;"><img src="images/spacer.gif"/></td></tr>';

        var row_3 = '<tr><td colspan="' + (struct.length * 2) + '"><img src="images/spacer.gif"/></td></tr>';

        var html = '<table cellpadding="0" cellspacing="0" border="0" width="100%">' + row_1 + row_2 + row_3 + '</table>';

        return html;
    }


	  function getMainMenu2(page_id){

        var indexes = page_id.split("_");
        var current_index = parseInt(indexes[0]);
        var struct = getStruct2();
        var row_1 = "<tr>"; //highlight caps
        var row_2 = "<tr>"; //labels

        for(var i=0; i<struct.length; i++){

            var cap = (i == current_index)? "cap_on" : "cap_off";
            var nav = (i == current_index)? "nav_on" : "nav_off";
            var jsc = (i == current_index)? ' onClick="document.location = \'' + struct[i].page + '\';"' : 'onMouseOver="onMainOver(this.id);" onMouseOut="onMainOut(this.id);" onClick="document.location = \'' + struct[i].page + '\';"';
            var r1div = (i != struct.length - 1)? '<td></td>' : '';
            var r2div = (i != struct.length - 1)? '<td><img src="images/navdiv.gif"/></td>' : '';

            row_1   += '<td id="cap_' + i + '" class="' + cap + '"><img src="images/spacer.gif" height="5"/></td>' + r1div;
            row_2   += '<td id="nav_' + i + '" class="' + nav + '" ' + jsc + '><span class="nav_txt">' + struct[i].label + '</span></td>' + r2div;
        }

        row_1 += '<td style="width:100%;"><img src="images/spacer.gif"/></td></tr>';
        row_2 += '<td style="width:100%;background-color:#999999;"><img src="images/spacer.gif"/></td></tr>';

        var row_3 = '<tr><td colspan="' + (struct.length * 2) + '"><img src="images/spacer.gif"/></td></tr>';

        var html = '<table cellpadding="0" cellspacing="0" border="0" width="100%">' + row_1 + row_2 + row_3 + '</table>';

        return html;
    }

	
	
	

    function onMainOver(nav_id){
        var index = nav_id.split("_");
        var cell = document.getElementById("cap_" + index[1]);
        cell.className = "cap_on"; 
    }

    function onMainOut(nav_id){
        var index = nav_id.split("_");
        var cell = document.getElementById("cap_" + index[1]);
        cell.className = "cap_off"; 
    }

//========================================================
//get the toolbar

    function getToolbar(query){

        var html = "";

        html += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
        html +=     '<tr>';
        html +=         '<td colspan="2" class="toolbar_bkg">';
        html +=             '<div style="position:relative;">';
        html +=                 '<div id="selector" style="position:absolute;top:5px;left:10px;">';
        html +=                     getLanguageSelector();
        html +=                 '</div>';
        html +=                 '<div id="search" style="position:absolute;top:5px;left:576px;">';
        html +=                     getSearchControls(query);
        html +=                 '</div>';
        html +=             '</div>';
        html +=             '<img src="images/spacer.gif" width="1" height="32"/>';
        html +=         '</td>';
        html +=     '</tr>';
        html += '</table>'

        return html;
    }

//========================================================
//language selector methods

    function getLanguageSelector(){

        var html = "";

        html += '<form><select name="lang_selector" size="1" onChange="changeLanguage(this.options[this.selectedIndex].value);">';
        html += getLocationList();
        html += '</select></form>';

        return html;
    }

    function changeLanguage(id){
        if(id == "0"){
            document.location = "a1-home.html";
        } else {
            document.location = "http://www.otis.com/otis/1,1352,CLI" + id + "_RES1,00.html"
        }
    }

    function getLocationList(){

        var html = "";

        html += '<option value="0" selected>Otis Worldwide</option>';
        html += '<option value="30">Argentina / Spanish</option>';
        html += '<option value="23">Australia / English</option>';
        html += '<option value="24">Austria / German</option>';
        html += '<option value="33">Belgium / Dutch</option>';
        html += '<option value="32">Belgium / French</option>';
        html += '<option value="3">Brazil / Portuguese</option>';
        html += '<option value="111">Cameroon / French</option>';
        html += '<option value="25">Canada / English</option>';
        html += '<option value="4">Canada / French</option>';
        html += '<option value="98">Chile / Spanish</option>';
        html += '<option value="79">China / English</option>';
        html += '<option value="54">China / Simplified Chinese</option>';
        html += '<option value="113">Croatia / Croatian</option>';
        html += '<option value="34">Czech Republic / Czech</option>';
        html += '<option value="6">Denmark / Danish</option>';
        html += '<option value="69">Egypt / English</option>';
        html += '<option value="55">Estonia / Estonian</option>';
        html += '<option value="7">Finland / Finnish</option>';
        html += '<option value="8">France / French</option>';
        html += '<option value="9">Germany / German</option>';
        html += '<option value="72">Greece / Greek</option>';
        html += '<option value="36">Hong Kong / English</option>';
        html += '<option value="37">Hungary / Hungarian</option>';
        html += '<option value="38">India / English</option>';
        html += '<option value="81">Indonesia / English</option>';
        html += '<option value="39">Ireland / English</option>';
        html += '<option value="10">Italy / Italian</option>';
        html += '<option value="104">Ivory Coast / French</option>';
        html += '<option value="57">Japan / Japanese</option>';
        html += '<option value="58">Kazakhstan / Russian</option>';
        html += '<option value="66">Korea / Korean</option>';
        html += '<option value="70">Kuwait / English</option>';
        html += '<option value="59">Latvia / Latvian</option>';
        html += '<option value="67">Luxembourg / French</option>';
        html += '<option value="82">Malaysia / English</option>';
        html += '<option value="40">Mexico / Spanish</option>';
        html += '<option value="11">Netherlands / Dutch</option>';
        html += '<option value="41">New Zealand / English</option>';
//        html += '<option value="12">Norway / Danish</option>';
        html += '<option value="99">Norway / Norwegian</option>';
        html += '<option value="84">Philippines / English</option>';
        html += '<option value="42">Poland / Polish</option>';
        html += '<option value="13">Portugal / Portuguese</option>';
        html += '<option value="43">Russian Federation / Russian</option>';
        html += '<option value="71">Saudi Arabia / English</option>';
        html += '<option value="85">Singapore / English</option>';
        html += '<option value="44">Slovak Republic / Slovak</option>';
        html += '<option value="101">Slovenia / Slovene</option>';
        html += '<option value="46">South Africa / English</option>';
        html += '<option value="29">Spain / English</option>';
        html += '<option value="15">Spain / Spanish</option>';
        html += '<option value="16">Sweden / Swedish</option>';
        html += '<option value="17">Switzerland / French</option>';
        html += '<option value="18">Switzerland / German</option>';
        html += '<option value="52">Switzerland / Italian</option>';
        html += '<option value="90">Taiwan / English</option>';
        html += '<option value="91">Taiwan / Traditional Chinese</option>';
        html += '<option value="88">Thailand / English</option>';
        html += '<option value="64">Turkey / Turkish</option>';
        html += '<option value="109">U.A.E. / English</option>';
        html += '<option value="1">U.S. / English</option>';
        html += '<option value="60">Ukraine / Ukrainian</option>';
        html += '<option value="27">United Kingdom / English</option>';
        html += '<option value="61">Uruguay / Spanish</option>';
        html += '<option value="93">Vietnam / Vietnamese</option></select>';

        return html;
    }

//========================================================
//search methods

    function getSearchControls(query){

        var value = (query == null)? "" : query;

        var html = "";

            html += '<form action="i1-search.asp" method="get">';
            html +=     '<input id="query" name="query" value="' + value + '" type="text" size="18"/>&nbsp;';
            html +=     '<input type="submit" value="Search"/>';
            html += '</form>';

        return html;
    }

//========================================================
//secondary nav methods

    function getSecondaryMenu(page_id){
   
        var indexes     = page_id.split("_");
        var struct      = getStructObject(indexes[0]);
        var items       = struct.sections;
        var html        = "";

        for(var i=0; i<items.length; i++){

            html += '<div class="smenu_item">';

            var current_section = (parseInt(indexes[1]) == i)? true : false;

            if(current_section){
                if(indexes.length == 2){
                    //handle highlight case
                    html += getSMenuOn(items[i]);
                } else {
                    //handle inactive case
                    html += getSMenuInactive(items[i]);
                }
            } else {
                //handle off case
                html += getSMenuOff(items[i],("sm_" + i));
            }

            html += '</div>';
        }

        return html;
    }
 
 
 	   function getSecondaryMenu2(page_id){
   
        var indexes     = page_id.split("_");
        var struct      = getStructObject2(indexes[0]);
        var items       = struct.sections;
        var html        = "";

        for(var i=0; i<items.length; i++){

            html += '<div class="smenu_item">';

            var current_section = (parseInt(indexes[1]) == i)? true : false;

            if(current_section){
                if(indexes.length == 2){
                    //handle highlight case
                    html += getSMenuOn(items[i]);
                } else {
                    //handle inactive case
                    html += getSMenuInactive(items[i]);
                }
            } else {
                //handle off case
                html += getSMenuOff(items[i],("sm_" + i));
            }

            html += '</div>';
        }

        return html;
    }
 
 
 
    function getSMenuOn(item){
        var contents = '<div class="smenu_on" onClick="document.location = \'' + item.page + '\';">' + item.label + '</div>';
        return getInlineContainer(contents);
    }

    function getSMenuOff(item,id){
        var qid = "'" + id + "'";
        var contents = '<div id="' + id + '" class="smenu_off" onMouseOver="javascript:onSMenuOver(' + qid + ');" onMouseOut="javascript:onSMenuOut(' + qid + ');" onClick="document.location = \'' + item.page + '\';">' + item.label + '</div>';
        return getInlineContainer(contents,true,id);
    }

    function getSMenuInactive(item){
        var contents = '<div class="smenu_inactive" onClick="document.location = \'' + item.page + '\';">' + item.label + '</div>';
        return getInlineContainer(contents);
    }

    function onSMenuOver(id){

        var item = document.getElementById(id);
        item.className = "smenu_over";

        var left_rule = document.getElementById("rl_" + id);
        var right_rule = document.getElementById("rr_" + id);
        left_rule.className = "td_gray";
        right_rule.className = "td_gray";
    }

    function onSMenuOut(id){
        var item = document.getElementById(id);
        item.className = "smenu_off";

        var left_rule = document.getElementById("rl_" + id);
        var right_rule = document.getElementById("rr_" + id);
        left_rule.className = "td_white";
        right_rule.className = "td_white";
    }

//========================================================
//inline buttons

    //========================================================
    //titlebar wrappers

        function getTitlebar(txt,url,wrapped){

            var html = "";
            var contents = "";

            if(url == null){
                contents = '<div class="titlebar">' + txt + '</div>';
            } else {
                var on_click = "javascript:document.location = '" + url + "';" ;
                contents = '<div class="titlebar" onMouseOver="javascript:this.className = \'titlebar_over\';" onMouseOut="javascript:this.className = \'titlebar\';" onClick="' + on_click + '">' + txt + '</div>';
            }

            if(wrapped == false){
                html = getInlineContainer(contents);
            } else {
                html = '</td></tr><tr><td>' + getInlineContainer(contents) + '</td></tr><tr><td class="content_zone">';
            }
            return html
        }

    //========================================================
    //inline button containers

        function getInlineButtonRule(){
            return getInlineContainer("");
        }

        //private function
        function getInlineContainer(contents,norules,id){

            var rule_class = (norules == true)? 'class="td_white"' : 'class="td_gray"';
            var rule_1 = (id != null)? 'id="rl_' + id + '" ' : "";
            var rule_2 = (id != null)? 'id="rr_' + id + '" ' : "";

            var html = "";

            html += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
            html +=     '<tr>';
            html +=         '<td style="vertical-align:middle;width:10px;"><div ' + rule_1 + rule_class + 'style="width:10px;"><img src="images/spacer.gif"/></div></td>';
            html +=         '<td>' + contents + '<td>';
            html +=         '<td style="vertical-align:middle;width:100%;"><div ' + rule_2 + rule_class + 'style="width:100%;"><img src="images/spacer.gif"/></div></td>';
            html +=     '</tr>';
            html += '</table>';

            return html;
        }

//========================================================
//build breadcrumb trail

    function getBreadcrumbs(page_id){

        var indexes = page_id.split("_");
        var html    = "";
        var path    = "";

        html += '<div class="breadcrumb_zone">';
        html += '<a href="a1-home.html"><img src="images/more.gif" class="more_arrow"/></a>';
        html += '&nbsp;<a href="http://www.otis.com/site/us" class="breadcrumb">Home</a>&nbsp;&#124;';

        for(var i=0; i<indexes.length-2; i++){
            if(i>0){ path += "_"; }
            path += indexes[i];
            var info = getStructObject(path);
            html += '&nbsp;<a href="' + info.page + '" class="breadcrumb">' + info.label + '</a>&nbsp;&#124;';
        }

        html += '&#133;';
        html += '</div>';

        return html;
    }


//========================================================
//common objects

    function getCopyright(){

        var html = "";

        html += '<table  class="copyright" cellpadding="0" cellspacing="0" border="0" width="784">';
        html +=     '<tr>';
        html +=         '<td style="padding-left:10px;">&#169; 2007 Otis Elevator Company<br/>&nbsp;</td>';
        html +=         '<td style="padding-right:10px;text-align:right;"><a href="http://www.otis.com/site/us/Pages/TermsOfUse.aspx">Terms of Use</a> &#124; <a href="http://www.otis.com/site/us/Pages/Privacy.aspx">Privacy</a> &#124; <a href="mailto:suggestions@otis.com">Suggestions</a> &#124; <a href="http://www.otis.com/site/us/Pages/SiteMap.aspx">Site Map</a></td>';
        html +=     '</tr>';
        html += '</table>';

        return html;
    }

    function getSeparator(width){
        if(width == null){ width = "100%"; }
        var html = '<table class="separator" width="' + width + '" cellpadding="0" cellspacing="0" border="0"><tr><td class="td_gray"><img src="images/spacer.gif"/></td></tr></table>';
        return html;
    }

    function getDottedSeparator(width){
        if(width == null){ width = "100%"; }
        var html = '<table class="separator_dots" width="' + width + '" cellpadding="0" cellspacing="0" border="0"><tr><td><img src="images/spacer.gif"/></td></tr></table>';
        return html;
    }

    function getDottedRule(width){
        if(width == null){ width = "100%"; }
        var html = '<table class="hr_dotted" width="' + width + '" cellpadding="0" cellspacing="0" border="0"><tr><td><img src="images/spacer.gif"/></td></tr></table>';
        return html;
    }

//========================================================
//launchers

    function launchMovie(page){
        var newWin=window.open(page,'movie','width=400,height=400,scrollbars=no,resizable=no,toolbar=no,status=no,location=no');
        newWin.focus();
    }

    function launchPage(page){
        var newWin=window.open(page,'page');
        newWin.focus();
    }
