﻿// JScript File

$(document).ready(function(){

    $('.careersItem h2').next().hide();
	 
	    $('.careersItem h2').click(function () {
	        $(this).next().slideToggle('fast');
	        $(this).find('a').toggleClass('open');
			
    });

    $(".askUs").click(function(){
        $('#divQPopUp').slideToggle('normal'); return false;
    });
});

function initMenu(openIndex) {
 
        $('#VMenu ul:not(.current)').hide();
        
        //$('#VMenu ul:first').show();
         
        $('#VMenu li a').click(
         
        function() {
            var checkElement = $(this).next();
            if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
                $('#VMenu ul:visible').slideUp('normal');
                return false;
                }
         
            if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
                $('#VMenu ul:visible').slideUp('normal');
                checkElement.slideDown('normal');
            return false;
            }
        }
    );
}

function InitTopMenu()
{
    $(document).ready(function(){   
  
    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)   
  
    $("ul.topnav li span").click(function() { //When trigger is clicked...   
  
        //Following events are applied to the subnav itself (moving subnav up and down)   
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click   
  
        $(this).parent().hover(function() {   
        }, function(){   
            $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up   
        });   
  
        //Following events are applied to the trigger (Hover events for the trigger)   
        }).hover(function() {   
            $(this).addClass("subhover"); //On hover over, add class "subhover"   
        }, function(){  //On Hover Out   
            $(this).removeClass("subhover"); //On hover out, remove class "subhover"   
    });   
  
});  
}


function trim(strText) 
{    
while('' + strText.charAt(0) == ' ') 
{        strText = strText.substring(1, strText.length);    }    
while('' + strText.charAt(strText.length-1)==' ') {        
strText = strText.substring(0, strText.length-1);    }   
return strText;
}

function SearchKeyword()
{
    var searchKeyword = trim($('#txtSearch').attr('value'));
    if(searchKeyword != "")
        location.href = 'search_' + searchKeyword + '.html';
}

function Search() 
{
    if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
    {
        $('#SearchButton').click();
        return false;
    }
    return true;
}

function InitMapTable()
{
    if(!('.Continent').length > 0)
        return;

    $('.Continent').hide();
    $('.country').hide();
}

function showTable(country)
{
    if(!('.Continent').length > 0)
        return;

    $('.Continent').hide();
    $('.country').hide();
    $('.Continent a').each(function(){
     //alert($(this).attr('name'));
     if($(this).attr('name') == country)
     {
        //$.prettyPhoto.open($(this).closest('.Continent'),'Title','Description');
        $('#inline-1').html($(this).closest('.Continent'));
        $(this).closest('.Continent').show();
        $(this).closest('.country').show();
        $('#aPopupOpen').click();
     }
    });
}

function InitFlash()
{
//    if($(".zoom").length > 0)
//    {
//        $(".zoom").attr("rel","prettyPhoto[flash]");
//    }
      //$(".zoom[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
}

function InittblSupport()
{
    $('.tblSupport a').each(function(){
        $(this).hover(function(){
            $(this).parent().parent().find('td').css('color','#0054b1');
        },function(){
            $(this).parent().parent().find('td').css('color','#5a5a5a');
        });
    });
}


function WriteFlashObj(sSrc, sWidth, sHeight, bTrans, sFlashVars, sID) {
    var sObj = "";
    var sWMode = "";
    var sObjID = sSrc.replace(".swf", "");
    var sVars = "";
    var sPrfx = "?";
    if (sFlashVars) {
        sVars = sFlashVars;
    }
    if (sID) {
        sObjID = sID;
    } else {
        sObjID = sSrc.replace(".swf", "");
    }
    sObj = sObj + "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab' width='" + sWidth + "' height='" + sHeight + "' id='" + sObjID + "' align='middle' VIEWASTEXT>";
    sObj = sObj + "<param name='allowScriptAccess' value='sameDomain' />";
    sObj = sObj + "<param name='movie' value='" + sSrc + "' />";
    sObj = sObj + "<param name='quality' value='high' />";
    sObj = sObj + "<param name='bgcolor' value='#ffffff' />";
    sObj = sObj + "<param name='flashvars' value='" + sVars + "' />";
    if (bTrans == true) {
        sObj = sObj + "<PARAM NAME='WMode' VALUE='Transparent'>";
        sWMode = "wmode='transparent'";
    }
    sObj = sObj + "<embed src='" + sSrc + "' flashvars='" + sVars + "' quality='high' bgcolor='#ffffff' " + sWMode + " width='" + sWidth + "' height='" + sHeight + "' ID='" + sObjID + "' NAME='bg' align='middle' allowScriptAccess='sameDomain' swLiveConnect=true ID='bg' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    sObj = sObj + "</object>";
    DocumentWrite(sObj);

}

function DocumentWrite(sHtml) {
    document.writeln(sHtml);
}

function InitGallery()
{
    if($(".ImageGallery").length > 0)
    {
        $(".ImageGallery a").attr("rel","prettyPhoto[gallery1]");
        $(".ImageGallery a").each(function(){
                $(this).attr('href',$(this).attr('href'));
        });
        $(".ImageGallery a[rel^='prettyPhoto']").prettyPhoto({ theme: 'facebook' });
    }
    if ($(".ImageVideo").length > 0)
        $(".ImageVideo").prettyPhoto({ theme: 'facebook', callback: function() { $('#pp_full_res').html(''); } });
        
    if ($(".ImageEnlarge").length > 0)
        $(".ImageEnlarge").prettyPhoto({ theme: 'facebook' });
    if ($(".InlinePopup").length > 0)
        $(".InlinePopup").prettyPhoto({ theme: 'facebook', default_width: 300 });

    if ($(".FlashPop").length > 0)
        $(".FlashPop").prettyPhoto({ theme: 'facebook' }); 
    
    
}
