﻿// JScript File

function showMenu(menuName) {
	var theMenuToShow = document.getElementById(menuName);
		theMenuToShow.style.display = "block";
		theMenuToShow.style.visibility = "visible";
}

function showSubMenu(menuName, parentName) {
	var theMenuToShow = document.getElementById(menuName);
	theMenuToShow.style.display = "block";
	theMenuToShow.style.visibility = "visible";
	var theParent = document.getElementById(parentName);
	theMenuToShow.style.top = theParent.offsetTop + 34 + "px";
	var theIframe = document.getElementById('menuIframe2');
	theIframe.style.top = theParent.offsetTop + 34 + "px";
}

function setIframe(idx,xleft,items) {
	var theIframe = document.getElementById('menuIframe' + idx);
	var frameHeight = 24 * items;
	theIframe.style.display = "block";
	theIframe.style.visibility = "visible";
	theIframe.style.left = xleft;
	theIframe.height = frameHeight;
}

function closeMenu(menuName) {
	var theMenuToShow = document.getElementById(menuName);
		theMenuToShow.style.display = "none";
		theMenuToShow.style.visibility = "hidden";
}

function closeIframe(idx) {
	var theIframe = document.getElementById('menuIframe' + idx);
		theIframe.style.display = "none";
}

function menuStyleChange (ele) {
    
    ele.style.backgroundColor = "#dddddd";
	ele.style.cursor = "hand";
}

function menuStyleOrig (ele) {
    
    ele.style.backgroundColor = "#ffffff";
}

function gotoLink (link) {
   
    var str = link;
    //var checkbrowser = CheckBrowserVersion();

    //if (checkbrowser == true) {

        if ((str.substring(1, 4) == "dtc") || (str == "/FARealEstate")) {
            //link = "http:" + "//" + document.location.hostname + link;
            var host = document.location.hostname;

            if (host.substring(0, 4) == "www.")
                host = host.substring(4);
            link = "https:" + "//" + host + link;
        }
        //alert(link);
        document.location.href = link;
    //}
}

function gotoRELink(link) {

    var str = link;
   // var checkbrowser = CheckBrowserVersion();

    //if (checkbrowser == true) {

        if ((str.substring(1, 4) == "dtc") || (str == "/FARealEstate")) {
            //link = "http:" + "//" + document.location.hostname + link;
            var host = document.location.hostname;

            if (host.substring(0, 4) == "www.")
                host = host.substring(4);
            link = "https:" + "//" + host + link;
        }
        //alert(link);
        document.location.href = link;
    //}
}

//added by skoka to prefix https
function prefixProtocol() {
    window.open("http://www.fanhd.com");
}
//added by skoka for secure DTC link
function gotosecureDTCLink() {
var host = document.location.hostname;
    //alert(document.location.hostname);
    if (host.substring(0, 4) == "www.")
        host = host.substring(4);
    document.location.href = "https:" + "//" + host + '/dtc/spring/Client-flow?wm=fa-dtc-web-webui&wn=DTCTask&vm=fa-dtc-web-webui&vn=DTCTask';
    //alert(document.location.href);
    //document.location.href = "http:" + "//" + document.location.hostname + '/dtc/spring/Client-flow?wm=fa-dtc-web-webui&wn=DTCTask&vm=fa-dtc-web-webui&vn=DTCTask';
}

//added by skoka for secure RE link
function gotosecureRELink() {

   var host = document.location.hostname;
//var checkbrowser = CheckBrowserVersion();

//if (checkbrowser == true) {

    //alert(document.location.hostname);
    if (host.substring(0, 4) == "www.")
        host = host.substring(4);
    document.location.href = "https:" + "//" + host + '/FARealEstate';
    //alert(document.location.href);
    //document.location.href = "http:" + "//" + document.location.hostname + '/FARealEstate';
//}
}

//added by skoka for secure REUserReg link
function gotosecureREUserRegLink() {
   var host = document.location.hostname;
//    
//    var checkbrowser = CheckBrowserVersion();

//    if (checkbrowser == true) {

        //alert(document.location.hostname);
        if (host.substring(0, 4) == "www.")
            host = host.substring(4);
        document.location.href = "https:" + "//" + host + '/FARealEstate/spring/Client-flow?wm=fa-re-web-webui&amp;wn=UserRegistration&amp;vm=fa-re-web-webui&amp;vn=ResetPassword';
        // alert(document.location.href);
        //document.location.href = "http:" + "//" + document.location.hostname + '/FARealEstate/spring/Client-flow?wm=fa-re-web-webui&amp;wn=UserRegistration&amp;vm=fa-re-web-webui&amp;vn=ResetPassword';
//    }
}


function popupLink (link) {
	window.open(link);
}

function CheckBrowserVersionAndRedirect() {

//    var browser = navigator.appName;

//    
//     if (browser == 'Microsoft Internet Explorer') {

//         if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
//             version = new Number(RegExp.$1) // capture x.x portion and store as a number

//             if (version < 7)
//                 alert('WARNING: This site is optimized for Internet Explorer 7.0 or higher. To use the features available in ‘My  Account’, please upgrade your browser to Internet Explorer 7.0 or higher.');
//             else document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';
//         }
//    }
//    else if (browser == 'Netscape') {
// 
//    
//       if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
//            version = new Number(RegExp.$1) // capture x.x portion and store as a number
//            
//        if (version < 3)
//            alert('WARNING: This site is optimized for Firefox®  3.0 or higher. To use the features available in ‘My  Account’, please upgrade your browser to Firefox®  3.0 or higher.');
//        else document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';
//       }
//       //for chrome
//       else document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';

//    }
//    //other browsers
//    else 
    
    document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';


}

function CheckAndRedirectAfterKeyPress() {
//    var browser = navigator.appName;
//     var version;

//     if (window.event.keyCode == 13) {
//         
//         if (browser == 'Microsoft Internet Explorer') {
//        
//            if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) 
//            {
//                version   = new Number(RegExp.$1) // capture x.x portion and store as a number
//            //alert(version);
//                if (version < 7)
//                    alert('WARNING: This site is optimized for Internet Explorer 7.0 or higher. To use the features available in ‘My  Account’, please upgrade your browser to Internet Explorer 7.0 or higher.');
//                else {
//                    document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';
//                    document.forms[0].submit();
//                }
//            }
//        }
//       else if (browser == 'Netscape') {

//        if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
//            version = new Number(RegExp.$1) // capture x.x portion and store as a number
//            //alert(version);
//            if (version < 3)
//                alert('WARNING: This site is optimized for Firefox®  3.0 or higher. To use the features available in ‘My  Account’, please upgrade your browser to Firefox®  3.0 or higher.');
//            else document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';

//        }
//        //for chrome
//        else document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';

//    }

//    else document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';
//}

    if (window.event.keyCode == 13) {
        document.forms[0].action = 'https:' + '//' + document.location.hostname + '/FARealEstate/spring/loginProcess;';
        document.forms[0].submit();
    }
}


function CheckBrowserVersion() {

    var browser = navigator.appName;


    if (browser == 'Microsoft Internet Explorer') {

        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
            version = new Number(RegExp.$1) // capture x.x portion and store as a number

            if (version < 7) {
                alert('WARNING: This site is optimized for Internet Explorer 7.0 or higher. To use the features available in ‘Order A Warranty’, please upgrade your browser to Internet Explorer 7.0 or higher.');
                return false;
            }
            else return true;
        }
    }
    else if (browser == 'Netscape') {


        if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
            version = new Number(RegExp.$1) // capture x.x portion and store as a number

            if (version < 3) {
                alert('WARNING: This site is optimized for Firefox®  3.0 or higher. To use the features available in ‘Order A Warranty’, please upgrade your browser to Firefox®  3.0 or higher.');
                return false;
            }
            else return true;
        }
        //for chrome 
        else return true;

    }
    //other browsers
    else return true;


}
