﻿/***** CONTACT US PAGE JAVA SCRIPT STARTS *****/

function change1(val)
      {
        
        var path=document.getElementById(val).src;
        var imageName=path.substr(path.lastIndexOf('/')+1,path.length - path.lastIndexOf('/'));
        
        if (imageName=='tick_box.jpg')
        {
        document.getElementById(val).src="/global/assets/images/center-content/Tick_icon.jpg";
        document.getElementById('Contactus1_chkcopy').checked=true;
        }
        else
        {
        document.getElementById(val).src="/global/assets/images/center-content/tick_box.jpg";
        document.getElementById('Contactus1_chkcopy').checked=false;
        }
      }
 

/***** FAQ PAGE JAVA SCRIPT STARTS *****/

var oldDiv=null;
var newDiv=null;
function ShowHideHeaders(HeaderDivId,SignLabel,divfaqqnno,pcounter,psecondcounter,clickcolorchange)
{   
        newDiv=HeaderDivId;
        newSignLabel=SignLabel;
        newdivfaqqnno=divfaqqnno;
        newpcounter=pcounter;
        newpsecondcounter=psecondcounter;
        newclickcolorchange=clickcolorchange;
        if(document.getElementById(HeaderDivId).className=="faq-ans-show")
        {
        document.getElementById(HeaderDivId).className ="faq-ans-hide";
        document.getElementById(SignLabel).src = "/global/assets/images/center-content/arrow_right.jpg";
        document.getElementById(divfaqqnno).className = "faq-qnno";
        document.getElementById(pcounter).className = "counter";
        document.getElementById(psecondcounter).className = "secondcounter";
        document.getElementById(clickcolorchange).style.color = '#6a6a6a';
            if(newDiv!=oldDiv)
            {
            document.getElementById(oldHeaderDivId).className ="faq-ans-hide";
            document.getElementById(oldSignLabel).src = "/global/assets/images/center-content/arrow_right.jpg";
            document.getElementById(olddivfaqqnno).className = "faq-qnno";
            document.getElementById(oldpcounter).className = "counter";
            document.getElementById(oldpsecondcounter).className = "secondcounter";
            document.getElementById(oldclickcolorchange).style.color = '#6a6a6a';
            }
        }
        else
        {
            if(document.getElementById(HeaderDivId).className=="faq-ans-hide")
                {
                if(newDiv!=oldDiv && oldDiv!=null)
                    {
                        /* SHOW NEW DIV */
                        document.getElementById(HeaderDivId).className = "faq-ans-show";
                        document.getElementById(SignLabel).src = "/global/assets/images/center-content/arrow_down.jpg";
                        document.getElementById(divfaqqnno).className = "faq-qnno-change";
                        document.getElementById(pcounter).className = "counter-colorchange";
                        document.getElementById(psecondcounter).className = "secondcounter-colorchange";
                        document.getElementById(clickcolorchange).style.color = '#002d4e';
                        
                        /*HIDE OLD DIV */
                        document.getElementById(oldDiv).className ="faq-ans-hide";
                        document.getElementById(oldSignLabel).src = "/global/assets/images/center-content/arrow_right.jpg";
                        document.getElementById(olddivfaqqnno).className = "faq-qnno";
                        document.getElementById(oldpcounter).className = "counter";
                        document.getElementById(oldpsecondcounter).className = "secondcounter";
                        document.getElementById(oldclickcolorchange).style.color = '#6a6a6a';
                    }
                else
                    {
                    /* SHOW NEW DIV */
                        document.getElementById(HeaderDivId).className = "faq-ans-show";
                        document.getElementById(SignLabel).src = "/global/assets/images/center-content/arrow_down.jpg";
                        document.getElementById(divfaqqnno).className = "faq-qnno-change";
                        document.getElementById(pcounter).className = "counter-colorchange";
                        document.getElementById(psecondcounter).className = "secondcounter-colorchange";
                        document.getElementById(clickcolorchange).style.color = '#002d4e';
                        
                    }
                }
        }
        
       
      
        oldDiv = HeaderDivId;
        oldSignLabel=SignLabel;
        olddivfaqqnno=divfaqqnno;
        oldpcounter=pcounter;
        oldpsecondcounter=psecondcounter;
        oldclickcolorchange=clickcolorchange;
        }
        
function appendClear()
{
var newdiv = '<div class="clearboth"></div>';
$(newdiv).insertAfter('#parent_faq_QuestionAnswer >div:odd');
}

function showmap(mapid,continentid)
{
id=mapid;
continent=continentid;
document.getElementById("mapimage").src=id;
if(continent!="")
{
document.getElementById("continent-image").src=continent;
}
} 

/********** JQUERY FOR WHERE WE OPERATE **********/

// JScript File

//$(document).ready(function($) {
//var arr= Array();
//var FinalArra;
//$(document).ready(function(){
//$.ajax({
//    type: "GET",
//    url: strgetpath+"assets/xml/global_offices_search.xml",
//    dataType: "xml",
//    success: parseXml
//});
//});
//function parseXml(xml)
//{
//$(xml).find('countrylist').each(function(){
//for ( var i=0; i<this.childNodes.length;i++)
//{
//arr[i] =$(this.childNodes[i]).text();
//}
// FinalArra =arr;
// $("#globaloff_q").autocompleteArray(arr,
//        {
//            delay:10,
//            minChars:1,
//           matchSubset:1,
//            onItemSelect:selectItem,
//            onFindValue:findValue,
//            autoFill:true,
//            maxItemsToShow:20
//        }
//    );

//});
//}
//});

/*** Function for Ombudsman Page ***/
function changeombudsman(val)
      {
        
        var path=document.getElementById(val).src;        
        var imageName=path.substr(path.lastIndexOf('/')+1,path.length - path.lastIndexOf('/'));
        if (imageName=='tick_box.jpg')
        {
        document.getElementById(val).src="/global/assets/images/center-content/Tick_icon.jpg";
        document.getElementById('OmbudsmanContactus1_chkcopy').checked=true;           
        }
        else
        {
        document.getElementById(val).src="/global/assets/images/center-content/tick_box.jpg";
        document.getElementById('OmbudsmanContactus1_chkcopy').checked=false;        
        }
      }
 /** Report Builder Page function starts here 15-June-2011 **/
function GetCookie() {
var strName = "varCook";
if (document.cookie.indexOf(strName) == -1)
{
 document.getElementById("HF_Chk_Cookie_Val").value="0";
//alert("Cookies ARE NOT currently enabled!\n Report Builder feature is disabled.To Enable please enable cookies and reload (Hit F5) the page  - Thank You.");
return false;
}
else
{
cookieStart = document.cookie.indexOf(strName);
cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
cookieValEnd = document.cookie.indexOf(";", cookieStart);
if (cookieValEnd == -1)
{
cookieValEnd = document.cookie.length;
}
cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
}
if (cookieValue = "True")
{
return ("True");
}
}
function SetCookie(name,value,expires,path,domain,secure)
{
var strDNS = GetDNS();
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() + 1000*60*20 : "") +
( (path) ? ";path=" + path : "") +
//( (domain) ? ";domain=" + domain : "") +
( (domain) ? ";domain=" + strDNS : "") +
( (secure) ? ";secure" : "");
return true
}
function GetDNS()
{
cookieDomain = document.location.hostname;
}
function CheckCookiesEnabled()
{
SetCookie('varCook','True','','/','','');
if (GetCookie() == "True"){
document.getElementById("HF_Chk_Cookie_Val").value="1";
//document.getElementById("TestHidden").value=document.getElementById("HF_Chk_Cookie_Val").value;
//alert('Cookies are enabled, you can use the shopping cart!');
} else {
return false;
}
}
 /** Report Builder Page function  ends here **/
 

/***** FIVE PRINCIPLES JAVA SCRIPT STARTS *****/
function fiveprinciplestabvis(divid,liid)
{
var divdetid = divid;
var listid = liid;
      closediv();
      showdiv(divid,liid);
}
function  closediv()
{
        document.getElementById('li1').className="five-prin-text-hide";
        document.getElementById('li2').className="five-prin-text-hide";
        document.getElementById('li3').className="five-prin-text-hide";
        document.getElementById('li4').className="five-prin-text-hide";
        document.getElementById('li5').className="five-prin-text-hide";
        document.getElementById('det1').className="displayNone";
        document.getElementById('det2').className="displayNone";
        document.getElementById('det3').className="displayNone";
        document.getElementById('det4').className="displayNone";
        document.getElementById('det5').className="displayNone";
}
function  showdiv(divid,liid)
{
      document.getElementById(liid).className="five-prin-text-show";
      document.getElementById(divid).className="displayBlock";
}

/***** FIVE PRINCIPLES JAVA SCRIPT ENDS *****/
 

/***** JOB DESCRIPTION PAGE JAVA SCRIPT STARTS *****/
function CallPrint(Page_JobHeading1,Page_JobHeading2,Page_JobRefNumber,Page_JdClosingDate,Page_JobHeading,Page_jdlocation,Page_jdfunctionalare,Page_jddescavil,Page_jddetails)
{
    var JobHeading1 = document.getElementById(Page_JobHeading1);
    var JobHeading2 = document.getElementById(Page_JobHeading2);
    var JobRefNumber = document.getElementById(Page_JobRefNumber);
    var JdClosingDate = document.getElementById(Page_JdClosingDate);
    var jdcompanyName = document.getElementById(Page_JobHeading);
    var jdlocation = document.getElementById(Page_jdlocation);
    var jdfunctionalare = document.getElementById(Page_jdfunctionalare);
    var jddescavil = document.getElementById(Page_jddescavil);
    var jddetails = document.getElementById(Page_jddetails);
    var WinPrint = window.open();
    WinPrint.document.write( '<html><head><!-- PageID 87 - published by Open Text Web Solutions 10 - 10.0.1.64 - 30120 --><title>Mars.com - Job detail print</title><link rel="stylesheet" type="text/css" href="/global/assets/css/JobPrint.css" /></head><body><div id="div_printportion"><div id="divPrintPageHeader"><div class="printheaderLeft"><img src="../../assets/images/logo_mars_print.gif" alt="Mars"></div><div class="printheaderRight"><h1>job details</h1></div><br></div><br><h2 id="Jobdetails1_headJobTitle" class="clearboth">'+JobHeading1.innerHTML +'</h2><h3 id="Jobdetails2_headJobTitle" class="clearboth">'+JobHeading2.innerHTML +'</h3><div class="JobDetailscontentCream"><table width="460px" cellpadding="0" cellspacing="0"><tbody><tr><th id="Jobdetails1_thRefNo">Job reference no:</th><td><span id="Jobdetails1_spnJobRefNo">'+JobRefNumber.innerHTML +'</span></td></tr><tr><th id="Jobdetails1_thCloseDate">Application closing date:</th><td><span id="Jobdetails1_spnJobCloseDate">'+JdClosingDate.innerHTML +'</span></td></tr><tr><th id="Jobdetails1_thCompany">Company:</th><td><span id="Jobdetails1_spnJobCompany">'+jdcompanyName.innerHTML +'</span></td></tr><tr><th id="Jobdetails1_thLocation">Location:</th><td><span id="Jobdetails1_spnJobLocation">'+jdlocation.innerHTML +'</span></td></tr><tr><th id="Jobdetails1_thFunArea">Functional area:</th><td><span id="Jobdetails1_spnFunArea">'+jdfunctionalare.innerHTML +'</span></td></tr><tr><th id="Jobdetails1_thAvailableIn">Job description available in:</th><td><span id="Jobdetails1_spnJobAvailable">'+jddescavil.innerHTML +'</span></td></tr></tbody></table></div><br><h3>Job description:</h3><div id="div_jobdesc">'+jddetails.innerHTML +'</div></div><br></body></html>' );
    WinPrint.document.close();
    WinPrint.print();
}
/***** JOB DESCRIPTION PAGE JAVA SCRIPT ENDS *****/
 

/********** pop up window script start ********/


$(document).ready(function(){
var country;
$("#US-click").click(function()
{
    $("#world-img").removeClass("displayBlock");
    $("#world-img").addClass("displayNone");
    $("#US-img").removeClass("displayNone");
    $("#US-img").addClass("displayBlock");
  });
$("#Uk-click").click(function(){
    $("#world-img").removeClass("displayBlock");
    $("#world-img").addClass("displayNone");
    $("#UK-img").removeClass("displayNone");
    $("#UK-img").addClass("displayBlock");
 });
$("#select-US-click").click(function(){
    $("#US-img").removeClass("displayBlock");
    $("#US-img").addClass("displayNone");
    $("#select-country").removeClass("displayBlock");
    $("#select-country").addClass("displayNone");
    $("#select-candidate-type").removeClass("displayNone");
    $("#select-candidate-type").addClass("displayBlock");
    $("#candidate-window").removeClass("displayNone");
    $("#candidate-window").addClass("displayBlock");
    country = "US";
});
$("#back-US-click").click(function(){
    $("#US-img").removeClass("displayBlock");
    $("#US-img").addClass("displayNone");
    $("#world-img").removeClass("displayNone");
    $("#world-img").addClass("displayBlock");
});
$("#select-UK-click").click(function(){
    $("#UK-img").removeClass("displayBlock");
    $("#UK-img").addClass("displayNone");
    $("#select-country").removeClass("displayBlock");
    $("#select-country").addClass("displayNone");
    $("#select-candidate-type").removeClass("displayNone");
    $("#select-candidate-type").addClass("displayBlock");
    $("#candidate-window").removeClass("displayNone");
    $("#candidate-window").addClass("displayBlock");
    country="UK";
});
$("#back-UK-click").click(function(){
    $("#UK-img").removeClass("displayBlock");
    $("#UK-img").addClass("displayNone");
    $("#world-img").removeClass("displayNone");
    $("#world-img").addClass("displayBlock");
});
 $("#click").click(function(e) {
    e.preventDefault();
    var arrActPageSizes = getPageSize();
    var arrPopPageScroll =getPageScroll();
    var id = $(this).attr('href');
    var maskHeight = $(document).height();
        var maskWidth = $(document).width();
    $('#mask').css({'width':maskWidth,'height':maskHeight});    
    $('#mask').removeClass("displayNone");
    $('#mask').addClass("displayBlock");
        $('#mask').fadeTo("slow",0.6); 
    var winH = $(window).height();
        var winW = $(window).width();
$(id).css({top:    arrPopPageScroll[1]+ (arrActPageSizes[3]/4)});
            $(id).css('left', winW/2-$(id).width()/2);
    
    $(id).removeClass("displayNone");
    $(id).addClass("displayBlock");
});

function getPageScroll() {
            var xScroll, yScroll;
            if (self.pageYOffset) {
                yScroll = self.pageYOffset;
                xScroll = self.pageXOffset;
            } else if (document.documentElement && document.documentElement.scrollTop) {     // Explorer 6 Strict
                yScroll = document.documentElement.scrollTop;
                xScroll = document.documentElement.scrollLeft;
            } else if (document.body) {// all other Explorers
                yScroll = document.body.scrollTop;
                xScroll = document.body.scrollLeft;    
            }
            arrayPageScroll = new Array(xScroll,yScroll);
            return arrayPageScroll;
        };
function getPageSize() {
            var xScroll, yScroll;
            if (window.innerHeight && window.scrollMaxY) {    
                xScroll = window.innerWidth + window.scrollMaxX;
                yScroll = window.innerHeight + window.scrollMaxY;
            } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
            } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
            }
            var windowWidth, windowHeight;
            if (self.innerHeight) {    // all except Explorer
                if(document.documentElement.clientWidth){
                    windowWidth = document.documentElement.clientWidth; 
                } else {
                    windowWidth = self.innerWidth;
                }
                windowHeight = self.innerHeight;
            } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
            } else if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }    
            // for small pages with total height less then height of the viewport
            if(yScroll < windowHeight){
                pageHeight = windowHeight;
            } else { 
                pageHeight = yScroll;
            }
            // for small pages with total width less then width of the viewport
            if(xScroll < windowWidth){    
                pageWidth = xScroll;        
            } else {
                pageWidth = windowWidth;
            }
            arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
            return arrayPageSize;
        };


$("#clickcareer").click(function(e) {
    e.preventDefault();
    var arrActPageSizes = getPageSize();
    var arrPopPageScroll =getPageScroll();
    var id = $(this).attr('href');
    var maskHeight = $(document).height();
        var maskWidth = $(document).width();
    $('#mask').css({'width':maskWidth,'height':maskHeight});    
    $('#mask').removeClass("displayNone");
    $('#mask').addClass("displayBlock");
        $('#mask').fadeTo("slow",0.6); 
    var winH = $(window).height();
        var winW = $(window).width();
$(id).css({top:    arrPopPageScroll[1]+ (arrActPageSizes[3]/4)});
            $(id).css('left', winW/2-$(id).width()/2);
    
    $(id).removeClass("displayNone");
    $(id).addClass("displayBlock");
});
$("#click-yourmars").click(function(e) {
e.preventDefault();
    var arrActPageSizes = getPageSize();
    var arrPopPageScroll =getPageScroll();
    var id = $(this).attr('href');
    var maskHeight = $(document).height();
        var maskWidth = $(document).width();
    $('#mask').css({'width':maskWidth,'height':maskHeight});    
    $('#mask').removeClass("displayNone");
    $('#mask').addClass("displayBlock");
        $('#mask').fadeTo("slow",0.6); 
    var winH = $(window).height();
        var winW = $(window).width();
$(id).css({top:    arrPopPageScroll[1]+ (arrActPageSizes[3]/4)});
            $(id).css('left', winW/2-$(id).width()/2);
    
    $(id).removeClass("displayNone");
    $(id).addClass("displayBlock");

});

 $("#close-btn").click(function (e) {
    e.preventDefault();
    
    $("#UK-img").removeClass("displayBlock");
    $("#UK-img").addClass("displayNone");
    $("#US-img").removeClass("displayBlock");
    $("#US-img").addClass("displayNone");
    $("#world-img").removeClass("displayNone");
    $("#world-img").addClass("displayBlock");
    $("#select-country").removeClass("displayNone");
    $("#select-country").addClass("displayBlock");
    $("#select-candidate-type").removeClass("displayBlock");
    $("#select-candidate-type").addClass("displayNone");
    $("#candidate-window").removeClass("displayBlock");
    $("#candidate-window").addClass("displayNone");
    $('#mask').removeClass("displayBlock");
    $('#mask').addClass("displayNone");
    $('#popup-box').removeClass("displayBlock");
    $('#popup-box').addClass("displayNone");
});
$("#graduate-choose").click(function (e) {
    e.preventDefault();
    
    if(country == "UK")
    {
        UpdateCookie('Professional-United Kingdom',1);
        window.open('/global/careers/your-mars/uk-experienced-hires.aspx','_self');
    }
    else if(country == "US")
    {
        UpdateCookie('Professional-United states',1);
        window.open('/global/careers/your-mars/us-experienced-hires.aspx','_self');
    }
    return false;
});
$("#proffessional-choose").click(function (e) {
    e.preventDefault();
    
    if(country == "UK")
    {
        UpdateCookie('Graduate-United Kingdom',1);
        window.open('/global/careers/your-mars/uk-graduates.aspx','_self');
    }
    else if(country == "US")
    {
        UpdateCookie('Graduate-United states',1);
        window.open('/global/careers/your-mars/us-graduates.aspx','_self');
    }
    return false;
});

$("#back-to-country").click(function (e) {
    e.preventDefault();
    $("#select-candidate-type").removeClass("displayBlock");
    $("#select-candidate-type").addClass("displayNone");
    $("#select-country").removeClass("displayNone");
    $("#select-country").addClass("displayBlock");
    $("#candidate-window").removeClass("displayBlock");
    $("#candidate-window").addClass("displayNone");
    $("#world-img").removeClass("displayNone");
    $("#world-img").addClass("displayBlock");
});

});
function UpdateCookie(Value,days)
{
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = "CRCookie="+Value+expires+"; path=/";
  
}

 /********** pop up window script end ********/
 /*** Search Box Autocomplete for Google Search ***/
 // JScript File
$(document).ready(function($) {
var arr= Array();
var FinalArra;
$(document).ready(function(){
$.ajax({
    type: "GET",
    url: strgetpath+"assets/xml/Search-autocomplete.xml",
    dataType: "xml",
    success: parseXml
});
});
function parseXml(xml)
{
$(xml).find('suggestions').each(function(){
for ( var i=0; i<this.childNodes.length;i++)
{
 arr[i] =$(this.childNodes[i]).text();
}
 FinalArra =arr;
 $("#q").autocompleteArray(arr,
        {
            delay:10,
            minChars:1,
           matchSubset:1,
           onItemSelect:selectItem,
           onFindValue:findValue,
            autoFill:true,
           maxItemsToShow:20
        }
    );
      $("#searchBox").autocompleteArray(arr,
        {
           delay:10,
            minChars:1,
            matchSubset:1,
           onItemSelect:selectItem,
           onFindValue:findValue,
            autoFill:true,
            maxItemsToShow:20
        }
  );
});
}
});
 
/***** JQUERY EFFECT FOR MEDIA CONTACTS SECTION *****/
 $(document).ready(function(){
    $("#showhideclick").show(); 
        $("#showhideclick").click(function(){
        $("#showhide").toggle("slow");
        return false; 
    });
});
