﻿var isIE6;
var isIE7;
var homerUrl = '<%= Url.Content("~/") %>'

function onButtonSubmit() {
        jQuery.post(
            jQuery("#ArcGISForm").attr('action'), 
            jQuery("#ArcGISForm").serialize(),
                iWorked
            );
            return false;
    }

    function iWorked(data) {
        //alert(data.length);
        if (data.length > 1000){
        
        jQuery("#lightBoxForm").html(data);
        //alert("Data Loaded: " + data);
        emailFormClicked();
        jQuery('head').append('<link id="bubbleStylePrint" media="print" rel="stylesheet" href="../../Content/css/bubblePrint.css" type="text/css" />');
        }else
        {
        jQuery("#spTest2").fadeOut();
        jQuery("#spTest2").html(data);
        jQuery("#spTest2").fadeIn();
        
            
        }
    }
    function getContent(index) {
        //alert(hasRun + " 0")
        //On Click Event for the icons
        iconIndex = splash[index];
        var splashHeader = jQuery("div#" + iconIndex + " span").text();
        var splashContent = jQuery("div#" + iconIndex).html();

        jQuery(".text001").text(splashHeader);
        jQuery(".text002").text(splashHeader);

        fadeContent(splashContent)

        splashPath = "/Content/img/GraphicsLibrary/" + iconIndex + ".png";
        jQuery("#splash_main").css("background-image", "url('" + splashPath + "')");

        //jQuery("p.dynContentClass").removeAttr('style');
        //alert(iconIndex);            
    }

    function fadeContent(content) {
        var contentBlock = jQuery("#dContent");
        contentBlock.hide();
        jQuery("#dContent").html(content);
        contentBlock.css({ 'display': 'block' });
        //jQuery("p.dynContentClass").removeAttr('style');
        //contentBlock.removeAttr('style');
    }
    function changeSplash() {
        if (refreshContent == true) {
            window.clearInterval(delay);
            delay = window.setInterval("changeSplash()", refreshMilliseconds);
        }
        if (randomDisplay == true) {
            random = Math.floor(Math.random() * max);
            number = random;
        }
        if (textDisplay == false) {
            //alert(number);
            if (number < 12) {
                number += 1;
            }
            else {
                number = 0;
            }
            iconIndex = splash[number];
            splashPath = "/WVS2/Content/img/GraphicsLibrary/" + iconIndex + ".png";
            jQuery("#splash_main").css("background-image", "url('" + splashPath + "')");
        }
        else {
            getContent(number);
        }
    }
    function showPauseBtn() {
        jQuery("#pauseBtn").css({ 'display': 'block' });
    }

//function enableSubmit()
//{
    //jQuery('#submitButton:button').removeAttr ("disabled");

//}
function startAnimation()
{
    //jQuery(".featuredSolutionText p").fadeIn(500);
    //jQuery(".text001").animate({left: "80px"},1800);
    //jQuery(".text001").animate({marginLeft: "80px"},1800);
}
function resetAnimation()
{
    //jQuery(".featuredSolutionText p").fadeOut(500);
    //jQuery(".text001").css({left: "0px"});
    //jQuery(".text002").css({marginRight: "0px"});
}

jQuery.noConflict(); 

jQuery(function() {

    
    jQuery("#newsTree").treeview({
		persist: "location",
		collapsed: false,
		unique: false
	});

    
var currentPage = location.href; 
var sURL = window.document.URL.toString();
var eURL = sURL.split("/");
var strLast = eURL.pop();
 if(currentPage.indexOf("Industry") >= 0 )
 {
     jQuery("#id_Tab_01").addClass("selected");
 }
 if(currentPage.indexOf("Sector") >= 0 )
 {
     jQuery("#id_Tab_02").addClass("selected");
 }
 if(currentPage.indexOf("Technology") >= 0 )
 {
     jQuery("#id_Tab_03").addClass("selected");
 }
 if(strLast == "SystemPlanning" || strLast == "DataDevelopment" || strLast == "ApplicationDevelopment" || strLast == "TrainingSupport")
 {
    jQuery("#id_Tab_04").addClass("selected");
 }

   jQuery("#homepage_link").hoverIntent(
       function() {
        jQuery("#btnHome_txtHover").fadeIn(800);
                },
        function() {
            //jQuery(this).stop()
            jQuery("#btnHome_txtHover").fadeOut(500);
        }
    );


    // Set Menu Hover Effect **************************
    var setMenuState = new Boolean;
    setMenuState = false;

    // jQuery Fade Fuctions and set the 'donothing' function
    var ddlOptionsVisible = function() {
        jQuery(".ddlOptions").fadeIn(300);
        setMenuState = true;
    };
    var donothing = function() {
    };

    var ddlOptionsVisible = function() {
        jQuery(".ddlOptions").fadeIn(300);
        //setMenuState = true;
    };
    var donothing = function() {
    };

    var ddlOptionsInvisible = function() {
        jQuery(".ddlOptions").fadeOut(300);
        //setMenuState = false;
    };
    
     jQuery(".ddlItem").hoverIntent(
         {
            sensitivity: 3,
            interval: 0,
            over:ddlOptionsVisible,
            timeout: 400,
            out:ddlOptionsInvisible
         }
     );

    // End Menu Hover Effect ************************

    
    // Constant Contact subscribe input
	jQuery('#enterEmail').val("Enter Your Email");
        jQuery('#enterEmail').css({"color" : "#CCC"});
        jQuery('#enterEmail').focus(function () {
        jQuery('#enterEmail').val("");
        jQuery('#enterEmail').css({"color" : "#000"});  
    });




    });
// END OF JQUERY READY FUNCTION

// Create custom LightBox *****************************    
function emailFormClicked() {
    window.location = "#lightboxFocus";
    Height = jQuery(document).height();
    width = jQuery(document).width();
    centerForm = width/2 - 200;

    jQuery("#lightBoxBG").css({ "opacity": "0.7" });

    jQuery("#lightBoxBG").fadeIn(500);

    jQuery("#lightBox").fadeIn(500);


    jQuery("#lightBoxBG").css({ "width": width });
    jQuery("#lightBoxBG").css({ "height": Height });
    jQuery("#lightBoxForm").css({ "margin-left": centerForm });

};


function closeFrame() {
    jQuery("#lightBox").fadeOut(500);
    jQuery("#lightBoxBG").fadeOut(500);
};
// End custom LightBox ******************************* 


function goTo(URL) {
    document.location = URL;
 };

// removes and sets tabs on main page
function setActiveTab(index) {

    document.onmousedown = autoHideTabs;
    // set Content menuItem Value
    // Removes white background on all tabs            
    jQuery("#links li").removeClass("selected");
    // Adds the selected tabs white background
    jQuery("#links li:eq(" + index + ")").addClass("selected");
    
    //jQuery("#subMenuHolder").css({"display" : "none"}); *********** IE bug: hides the links for the first 2 cases ***********
    jQuery(".slectedSubMenuItems").slideUp(100);
 
    
    switch (index) {
        case 0:
            // Industry
            jQuery("#subMenuHolder").css({"display" : "block"});
            jQuery(".slectedSubMenuItems").hide();
            jQuery("#Industries").slideDown(200);
            break;
        case 1:
            // Sector
            
            jQuery(".slectedSubMenuItems").hide();
            jQuery("#subMenuHolder").css({"display" : "block"});
            jQuery("#Sectors").slideDown(200);
            break;
        case 2:
            // Industry
            jQuery("#subMenuHolder").css({"display" : "block"});
            jQuery(".slectedSubMenuItems").hide();
            jQuery("#Technologies").slideDown(200);
            break;
       case 3:
            // Services
            jQuery("#subMenuHolder").css({"display" : "block"});
            jQuery(".slectedSubMenuItems").hide();
            jQuery("#Services").slideDown(200);
            break;

    }
}

// Browser Compatible window and column Sizing ******************
function setHeight() {

    var getColumnHeight = jQuery(".middleColumn").height();

    if(getColumnHeight < 350)
    {
        jQuery(".middleColumn").css({ "height": "350px" });
    }

    var Height = jQuery(".middleColumn").height();

    if (Height < 25) {
        window.setTimeout(setHeight, 50);
        return;
    }

    if (Height > jQuery(".clientProfiles_Container").height())
    {
        jQuery(".clientProfiles_Container").css({ "overflow": "hidden" });

    } else
        jQuery(".clientProfiles_Container").css({ "overflow-y": "scroll" });


    jQuery(".clientProfiles_Container").css({ "height": Height });

}
// End Browser Sizing ******************************************

// Main Ribbon Links and SubMenu Items *************************
function ddlOptions2Visible() {
jQuery(this).next(".ddlOptions2").fadeIn(300);
};

function ddlOptions2Invisible() {
jQuery(this).next(".ddlOptions2").fadeOut(300);
};

function autoHideTabs(e){
            if (!e) var e = window.event;  
            var targ;
            if (e.target) 
                  targ = e.target;  
            else if (e.srcElement) 
                  targ = e.srcElement;  
            if (targ.nodeType == 3) // defeat Safari bug   
                  targ = targ.parentNode; 
                  
            if(!isRibbonArea(targ)){
                jQuery(".slectedSubMenuItems").hide();
                jQuery("#links li").removeClass("selected");
                jQuery("#subMenuHolder").slideUp(10);
                //jQuery("#subMenuHolder").css({"display" : "none"});
                  document.onmousedown = null;
            }
      }
      
      function isRibbonArea(element){
            
            while(element.id != "subMenuHolder") {
            //alert(element.id);
                  element = element.parentNode;
                  if(element == null) return false;
            }
            return true;            
      }
// End Main Ribbon Links and SubMenu Items *********************



function setTransparentPngInIE6() {

    var IEVersion = -1;
    if (navigator.appName == 'Microsoft Internet Explorer') {
        //jQuery(".About_Content").css({ "padding-bottom": "35px" });
        jQuery("ul.ddlOptions").css({ "position": "relative" });
         var ua = navigator.userAgent;
         var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
         if (re.exec(ua) != null)
             IEVersion = parseFloat(RegExp.$1);
         if (IEVersion < 7) {
             //alert("6");
             isIE6 = true;
         }
    }
    // IE design hacks
    if (isIE6) {
        jQuery(".innerAdvantage_bottom_right").css({"right" : "-3px"});
        var imgTags = document.getElementsByTagName("img");
        for (var i = 0; i < imgTags.length; i++) {
            imgObj = imgTags[i];
            if (imgObj != null) {
                if (imgObj.src.substr(imgObj.src.length - 3, 3).toLowerCase() == "png") {
                    //imgSrc = imgObj.src;
                    
                    imgObj.src = imgObj.src.substr(0, imgObj.src.length - 4) + ".gif";
                    
                    //imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + imgSrc + ")";
                }
            }
        }
    }
    

};



