//========================================================
//get the identity

    function getMasthead(){
        var html = '';
        html += '<div style="position:relative;">';
        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="img/identity.jpg" usemap="#home_map">';
        html += '<div style="position:absolute;top:9px;left:180px;">';
        html += '<img src="img/masthead-'+ cid +'.jpg"/>';
        html += '</div>';
        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="img/navdiv.gif"/></td>' : '';
				
            row_1   += '<td id="cap_' + i + '" class="' + cap + '"><img src="img/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="img/spacer.gif"/></td></tr>';
        row_2 += '<td style="width:100%;background-color:#999999;"><img src="img/spacer.gif"/></td></tr>';

        var row_3 = '<tr><td colspan="' + (struct.length * 2) + '"><img src="img/spacer.gif"/></td></tr>';

        var html = '<table cellpadding="0" cellspacing="0" border="0" width="100%">' + row_1 + row_2 + row_3 + '</table>';
        alert(html);
        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="img/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 = "Australia.aspx"
        }
    }

    function getLocationList(){

        var html = "";
//alert(Request("lang_selector"));
        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 html        = "";
        
        for(var i=0; i<struct.sections.length; i++){
            var item_id = indexes[0] + "_" + i;
            html += buildSecondaryMenu(page_id,item_id,struct.sections[i]);
        }

        return html;
    }
    
    function buildSecondaryMenu(page_id,item_id,item){
        
        var html            = '<div class="smenu_item">';
        var page_indexes    = page_id.split("_");
        var item_indexes    = item_id.split("_");
        var level           = item_indexes.length;
        
        if(page_indexes.length < item_indexes.length && item.page != "group"){
            //leaf node so no treatment
            html += getSMenuOff(level, item, ("sm_" + item_id));
            html += '</div>';
        } else {
            if(item.page == "group"){
                //get group label
                html += getSMenuGroup(level, item);
                
            } else if(page_indexes.length == item_indexes.length){
                if(page_id == item_id){
                    //current page link
                    html += getSMenuOn(level, item);
                } else {
                    //sibling of current page link
                    html += getSMenuOff(level, item, ("sm_" + item_id));
                }
            } else {
                if(currentSection(page_id,item_id) && item_indexes.length > 1){
                    //flag as parent link but only after second level
                    html += getSMenuInactive(level, item);
                } else {
                    html += getSMenuOff(level, item, ("sm_" + item_id));
                }
            }
            
            html += '</div>';
            
            if(item.sections != null){
                for(var j=0; j<item.sections.length; j++){
                    html += buildSecondaryMenu(page_id,item_id + "_" + j,item.sections[j]);
                }
            }
        }
        
        return html;
    }
 
    function getSMenuOn(level, item){
        var contents = '<div class="smenu_on" onClick="document.location = \'' + item.page + '\';">' + item.label + '</div>';
        return getInlineContainer(contents,null,null,level);
    }

    function getSMenuOff(level, 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,level);
    }

    function getSMenuInactive(level, item){
        var contents = '<div class="smenu_inactive" onClick="document.location = \'' + item.page + '\';">' + item.label + '</div>';
        return getInlineContainer(contents,null,null,level);
    }

    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";
    }
    
    function currentSection(page_id, item_id){
        var pid = page_id.split("_");
        var iid = item_id.split("_");
        
        var current = true;
        for(var i=0; i<iid.length; i++){
            if(pid[i] != iid[i]){
                current = false;
                break;
            }
        }
        return current;
    }
    
    function getSMenuGroup(level, item){
        var padding = 'style="padding-left:'+ (((level - 1) * 5) + 10) +'px;"';
        var contents = '<div class="smenu_group" '+ padding +'>' + item.label + '</div>';
        return contents;
    }

//========================================================
//inline buttons

    //========================================================
    //titlebar wrappers

        function getTitlebar(txt,url,wrapped){

            var html = "";
            var contents = "";

            if(url == null){
                contents = '<div class="titlebar" NOWRAP>' + 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
        }

    //========================================================
    //========================================================
    //News titlebar wrappers

        function getNewsTitlebar(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 = getInlineContainer1(contents);
            } else {
                html = '<tr><td>' + getInlineContainer1(contents) + '</td></tr>';
            }
            return html
        }


//inline button containers

        function getInlineButtonRule1(){
            return getInlineContainer1("");
        }

        //private function
        function getInlineContainer1(contents,norules,id,level){

            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 indent = (level != null)? (level * 5) : "10";

            var html = "";

            html += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
            html +=     '<tr>';
            html +=         '<td style="vertical-align:middle;"><div ' + rule_1 + rule_class + '><img src="/_layouts/OT_IMG/spacer.gif" style="width:'+ indent +'px;height:1px;"/></div></td>';
            html +=         '<td nowrap>' + contents + '<td>';
            html +=         '<td style="vertical-align:middle;width:100%;"><div ' + rule_2 + rule_class + 'style="width:100%;"><img src="/_layouts/OT_IMG/spacer.gif"/></div></td>';
            html +=     '</tr>';
            html += '</table>';

            return html;
        }
    //========================================================
    
    //inline button containers

        function getInlineButtonRule(){
            return getInlineContainer("");
        }

        //private function
        function getInlineContainer(contents,norules,id,level){

            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 indent = (level != null)? (level * 5) : "10";

            var html = "";

            html += '<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-top:10px">';
            html +=     '<tr>';
            html +=         '<td style="vertical-align:Top;padding-top:10px"><div ' + rule_1 + rule_class + '><img src="/_layouts/OT_IMG/spacer.gif" style="width:'+ indent +'px;height:1px;"/></div></td>';
            html +=         '<td NOWRAP>' + contents + '<td>';
            html +=         '<td style="vertical-align:Top;padding-top:10px;width:100%;"><div ' + rule_2 + rule_class + 'style="width:100%;"><img src="/_layouts/OT_IMG/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="img/more.gif" class="more_arrow"/></a>';
        html += '&nbsp;<a href="a1-home.html" class="breadcrumb">Home</a>&nbsp;&#124;';

        for(var i=0; i<indexes.length-1; i++){
            if(i>0){ path += "_"; }
            path += indexes[i];
            var info = getStructObject(path);
            if(info.page != "group"){
                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="g1-terms.html">Terms of Use</a> &#124; <a href="h1-privacy.html">Privacy</a> &#124; <a href="mailto:suggestions@otis.com">Suggestions</a> &#124; <a href="m1-sitemap.html">Site Map</a></td>';
        html +=     '</tr>';
        html += '</table>';

        return html;
    }

    function getSeparator(width){
        if(width == null){ width = "100%"; }
        var html = '<div class="SeparatorPadding"><table  width="' + width + '" cellpadding="0" cellspacing="0" border="0"><tr><td class="Separator_td_gray"><img src="/_LAYOUTS/OT_IMG/spacer.gif"/></td> </tr></table></div>';
        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="_layouts/OT_IMG/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="_layouts/OT_IMG/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();
    }
    
     function launchNews(page){
        var newWin=window.open(page,'News','width=450,height=550,scrollbars=yes,resizable=no,toolbar=no,status=no,location=no');
        newWin.focus();
    }
    
    function popUp(strPage,strWidth,strHeight){
    	var strParameters='width='+strWidth+',height='+strHeight+',scrollbars=no,resizable=no,toolbar=no,status=no,location=no';
        var newWin=window.open(strPage,'movie',strParameters);
        newWin.focus();
    }

    function HomePopup(strPage){
        var strWidth=screen.width-50;
        var strHeight=screen.height-250;
	    var strParameters='width='+strWidth+',height='+strHeight+',scrollbars=yes,resizable=yes,toolbar=yes,status=yes,menubar=yes,location=yes';
        var newWin=window.open(strPage,'HomePopup',strParameters);
        newWin.focus();
        self.close();
    }


 function newPage(object){       
        window.location=object.options[object.selectedIndex].value;
                
    }


function contactOfficePopUp(strPage,strWidth,strHeight)
        {
        
           var strForm1="OT_WP_RequestForm1.aspx";
    	     //var strParameters='width='+strWidth+',height='+strHeight+',scrollbars=yes,resizable=no,toolbar=no,status=no,location=no';
            //var newWin=window.open(strPage,'null','width=1000,height=600,resizable=yes,left=10,top=10,scrollbars=1');
            if(strPage.search(strForm1)==-1){
            var newWin=window.open(strPage,'null','width=800,height=650,resizable=yes,left=10,top=10,scrollbars=1');
            newWin.focus();
            }else{
            var newWin=window.open(strPage,'null','width=800,height=600,resizable=yes,left=10,top=10,scrollbars=1');
            newWin.focus();
            }
            
        }

	
