﻿// JScript File



function fnNextPreviousHome(vPage,vLink)
{
   
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
      alert ("Your browser does not support AJAX!");
      return;
   } 

  
   var url=vLink.replace("%%1",vPage);

    
   xmlHttp.onreadystatechange=NextPreviousHome;
   xmlHttp.open("GET",url,true);
   xmlHttp.send(null); 
}
function Start_home(vLink,vForm)
{   if(vForm == "2")
    {
        var vGender = document.getElementById("ctl00_cphWorkspace_ddlGender").value;
        var vFirstName = document.getElementById("ctl00_cphWorkspace_txtFirstName").value;
        var vLastName = document.getElementById("ctl00_cphWorkspace_txtLastName").value;
        vLink = vLink + "&fn=" + vFirstName + "&ln=" + vLastName + "&g=" + vGender;
    }
        location.href=vLink ;             
}


function NextPreviousHome() 
{     
      
    if (xmlHttp.readyState==4)
    {                 
       
        // if(xmlHttp.status  == 200) 
       //{
        document.getElementById("ctl00_cphWorkspace_tdImage").style.display = "none"; 
        var vAjaxValue = xmlHttp.responseText;   
//alert(vAjaxValue);              
        document.getElementById("ctl00_cphWorkspace_divImage").innerHTML = vAjaxValue; 
      // }
     //  else
     //  {
      //   document.getElementById("divImage").innerHTML = vAjaxValue.status; 
      // }          
       
       
    }           
}

function PauseFilmstrip()
{

  interval = 900000;
   
}

function StartFilmstrip(vInterval) {
     interval = vInterval;
}


function Slideshow()
{
     if(interval != 900000) {
         if(i < 15)                     
            fnNextPreviousHome( i, szmain);
        if(i==vCount)
    	
            i=1;
        else
            i++;       
    }	
}






function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttp;
}

function fnSearch_click(gszLang,gszVirtualDirectory)
{

        var szFirstName = "", szLastName = "", szYear = "", szExact = "", szCountry = "";
        
        szYear = document.getElementById("ctl00_cphWorkspace_txtBirthYear").value;     
        szFirstName =  document.getElementById("ctl00_cphWorkspace_txtFirst").value;
        szLastName = document.getElementById("ctl00_cphWorkspace_txtLast").value;
        szExact = document.getElementById("ctl00_cphWorkspace_ddlExactBirth").value;
        szCountry =document.getElementById("ddlFamilyCountry").value;

        var szURL = gszVirtualDirectory + "/Search/Default.aspx?l=" + gszLang + "&fn=" + szFirstName + "&ln=" + szLastName + "&Yr=" + szYear + "&ex=" + szExact + "&frm=1&c=" + szCountry;

       location.href=szURL ;
       
}

function fnFlipURL(vURL)
{
    szLang = document.getElementById("ctl00_Contentplaceholder1_ctl00_DDLLang").value;  
    if(szLang=="FR")
        szLang = "EN";
    vURL = vURL.replace("%%Lang%%", szLang);
    location.href=vURL ;
}

function fnFlip(vURL) {
    
    var vLangControl = document.getElementById("ctl03_DDLLang");
    if (vLangControl == null)
        vLangControl = document.getElementById("ctl00_Contentplaceholder1_ctl00_DDLLang");
    szLang = vLangControl.value;
    if (szLang == "FR")
        szLang = "EN";
    vURL = vURL.replace("%%Lang%%", szLang);
    location.href = vURL;
}

function fnStartSearchHome(gszLang,gszVirtualDirectory)
{ 
    szSearch = document.getElementById("ctl00_cphWorkspace_txtSearch").value;
    var szURL = gszVirtualDirectory + "/Search/Search.aspx?l=" + gszLang + "&fn=" + szSearch + "";

   location.href=szURL ;
}

function fnStartSearchHomeNew(gszLang, gszVirtualDirectory) {
    szSearch = document.getElementById("ctl00_cphWorkspace_txtSearch").value;
    var szURL = gszVirtualDirectory + "/Search/NewSearch.aspx?l=" + gszLang + "&fn=" + szSearch + "";

    location.href = szURL;
}




function searchSuggest() 
{

 var vLetter=document.getElementById('ctl00_cphWorkspace_txtSearch').value ;

CallAjax.DrawSuggestion(vLetter,handleSearchSuggest_callback);
  
}
function handleSearchSuggest_callback(response) {
 

  var ss = document.getElementById('search_suggest')

  
   //Build our element string.  This is cleaner using the DOM, but
////////   //IE doesn't support dynamically added attributes.
////////   var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
////////   suggest += 'onmouseout="javascript:suggestOut(this);" ';
////////   suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';
////////   suggest += 'class="suggest_link">' + str[i] + '</div>';
 
 if (response.value != "" && response.value != null)
 {
    ss.style.display="block";
    ss.innerHTML =response.value; 
    }
    else
    {
     ss.innerHTML =response.value; 
     ss.style.display="none";
     }
    
  }
 //}
//}
 
 
 
function suggestOver(div_value) {
 div_value.className = 'suggest_link_over';
}
//Mouse out function
 
 
 

function suggestOut(div_value) {
 div_value.className = 'suggest_link';
}
//Click function
function setSearch(value) {
 document.getElementById('ctl00_cphWorkspace_txtSearch').value = value;
 document.getElementById('search_suggest').innerHTML = '';
  document.getElementById('search_suggest').style.display="none";
}





function openBlogPopup(vlink, Vindex, vAddHeight, vAddWidth) {

    //Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"

    var vHeight = screen.height;
    var vWidth = screen.width;
    var vDHeight = (2 * vHeight) / 3;
    var vLeft = (vWidth - vAddWidth) / 2;
    vDHeight = vDHeight + (vAddHeight * 1);

    var vFeatures = "left=" + vLeft + ",width=" + vAddWidth + ",height=" + vDHeight + ",resize=1,scrolling=1,top=160";

    emailwindow = dhtmlmodal.open('Category', 'iframe', vlink, Vindex, vFeatures)

    emailwindow.onclose = function() {
        var vText2;

        if (this.contentDoc.getElementById("ctl00_cphWorkspace_CloseIndex") != null)
            vText2 = this.contentDoc.getElementById("ctl00_cphWorkspace_CloseIndex").value;

        if (vText2 == '0') {


        }
        else {

            var theForm = document.forms['aspnetForm'];
            theForm.submit();
        }
    }
}

//function to open PopUp
function openPopup(vlink, Vindex, vAddHeight, vAddWidth) {

    //Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"

    var vHeight = screen.height;
    var vWidth = screen.width;
    var vDHeight = (2 * vHeight) / 3;
    var vLeft = (vWidth - vAddWidth) / 2;

    var vIHeight = parseInt(vAddHeight);
    var vCalcHeight = "";
    if (vHeight < 850)
        vCalcHeight = (vAddHeight * vHeight) / 864;
    else if (vHeight < 900) {
        if (vIHeight > 0 && vIHeight < 25)
            vCalcHeight = (vAddHeight * (-2.5));
        else if (vIHeight > 24 && vIHeight < 50)
            vCalcHeight = (vAddHeight * (-1.2));
        else if (vIHeight < 0 && vIHeight > -6) {
            vCalcHeight = (vAddHeight * 13);
        }
        else if (vIHeight < -7 && vIHeight > -20) {
            vCalcHeight = (vAddHeight * 9);
        }
        else if (vIHeight < -19 && vIHeight > -25) {
            vCalcHeight = (vAddHeight * 4.5);
        }
        else if (vIHeight < -24 && vIHeight > -39) {
            vCalcHeight = (vAddHeight * 3.5);
        }
        else if (vIHeight < -38 && vIHeight > -51) {
            vCalcHeight = (vAddHeight * 2.5);
        }
        else if (vIHeight < -50 && vIHeight > -120) {
            vCalcHeight = (vAddHeight * 1.5);
        }
        else if (vIHeight < -120 && vIHeight > -150) {
            vCalcHeight = (vAddHeight * 1.35);
        }
        else if (vIHeight < -150 && vIHeight > -200) {
            vCalcHeight = (vAddHeight * 1.23);
        }
        else if (vIHeight < -199 && vIHeight > -219) {
            vCalcHeight = (vAddHeight * 1.22);
        }
        else if (vIHeight < -219 && vIHeight > -248) {

            vCalcHeight = (vAddHeight * 1.2);
        }
        else if (vIHeight < -247 && vIHeight > -270) {
            vCalcHeight = (vAddHeight * 1.15);
        }
        else if (vIHeight < -269) {
            vCalcHeight = (vAddHeight * 1.05);
        }
        else
            vCalcHeight = (vAddHeight * 1.2);
    }
    else if (vHeight > 1000) {
        if (vIHeight > 0 && vIHeight < 25)
            vCalcHeight = (vAddHeight * (-7));
        else if (vIHeight > 24 && vIHeight < 50)
            vCalcHeight = (vAddHeight * (-4.8));
        else if (vIHeight < 0 && vIHeight > -6) {
            vCalcHeight = (vAddHeight * 30);
        }
        else if (vIHeight < -7 && vIHeight > -20) {
            vCalcHeight = (vAddHeight * 9);
        }
        else if (vIHeight < -19 && vIHeight > -24) {
            vCalcHeight = (vAddHeight * 2.8);
        }
        else if (vIHeight < -24 && vIHeight > -39) {
            vCalcHeight = (vAddHeight * 7.5);
        }
        else if (vIHeight < -38 && vIHeight > -50) {
            vCalcHeight = (vAddHeight * 5);
        }
        else if (vIHeight < -49 && vIHeight > -121) {
            vCalcHeight = (vAddHeight * 2.5);
        }
        else if (vIHeight < -120 && vIHeight > -150) {
            vCalcHeight = (vAddHeight * 2);
        }
        else if (vIHeight < -150 && vIHeight > -200) {
            vCalcHeight = (vAddHeight * 1.8);
        }
        else if (vIHeight < -199 && vIHeight > -219) {
            vCalcHeight = (vAddHeight * 1.7);
        }
        else if (vIHeight < -219 && vIHeight > -250) {

            vCalcHeight = (vAddHeight * 1.6);
        }
        else if (vIHeight < -249 && vIHeight > -270) {
            vCalcHeight = (vAddHeight * 1.55);
        }
        else if (vIHeight < -269) {
            vCalcHeight = (vAddHeight * 1.4);
        }
        else
            vCalcHeight = (vAddHeight * 1.2);
    }
    else {
        if (vIHeight > 0 && vIHeight < 25)
            vCalcHeight = (vAddHeight * (-5));
        else if (vIHeight > 24 && vIHeight < 50)
            vCalcHeight = (vAddHeight * (-3.5));
        else if (vIHeight < 0 && vIHeight > -6) {
            vCalcHeight = (vAddHeight * 25);
        }
        else if (vIHeight < -7 && vIHeight > -21) {
            vCalcHeight = (vAddHeight * 7);
        }
        else if (vIHeight < -20 && vIHeight > -51) {
            vCalcHeight = (vAddHeight * 2.8);
        }
        else if (vIHeight < -50 && vIHeight > -120) {
            vCalcHeight = (vAddHeight * 2);
        }
        else if (vIHeight < -120 && vIHeight > -150) {
            vCalcHeight = (vAddHeight * 1.75);
        }
        else if (vIHeight < -150 && vIHeight > -200) {
            vCalcHeight = (vAddHeight * 1.55);
        }
        else if (vIHeight < -199 && vIHeight > -219) {
            vCalcHeight = (vAddHeight * 1.45);
        }
        else if (vIHeight < -219 && vIHeight > -250) {

            vCalcHeight = (vAddHeight * 1.5);
        }
        else if (vIHeight < -249 && vIHeight > -270) {
            vCalcHeight = (vAddHeight * 1.4);
        }
        else if (vIHeight < -269) {
            vCalcHeight = (vAddHeight * 1.3);
        }
        else
            vCalcHeight = (vAddHeight * 1.1);
    }


    vDHeight = vDHeight + (vCalcHeight * 1);



    var vFeatures = "left=" + vLeft + ",width=" + vAddWidth + ",height=" + vDHeight + ",resize=1,scrolling=1,top=20";
    emailwindow = dhtmlmodal.open('Category', 'iframe', vlink, Vindex, vFeatures)

    emailwindow.onclose = function() {
        var vText2;

        if (this.contentDoc.getElementById("ctl00_cphWorkspace_CloseIndex") != null)
            vText2 = this.contentDoc.getElementById("ctl00_cphWorkspace_CloseIndex").value;
        if (vText2 == '0') {

        }
        else {
            var theForm = document.forms['MainForm'];
            theForm.submit();
        }
    }
}

function fnRemoveBoxFocus(szClientId, szLabel) {
    szUser = document.getElementById("" + szClientId + "txtSearch").value;
    if (szUser == "")
        document.getElementById("" + szClientId + "txtSearch").value = szLabel;
}

function fnRemoveBox(szClientId, szLabel) {
    szUser = document.getElementById("" + szClientId + "txtSearch").value;
    if (szUser != "") {
        szUser = szUser.toUpperCase();
        szLabel = szLabel.toUpperCase();
        if (szUser == szLabel)
            document.getElementById("" + szClientId + "txtSearch").value = '';
    }
}


function KeyDownHandlerSearch(e,btn,vLang,VirtualDirect) {
    //process only the Enter key
    e = e || window.event;
    var keyCode = e.charCode || e.keyCode;
    if (keyCode === 13) {
        e.returnValue = false;
        e.cancel = true;
        fnStartSearchHome(vLang, VirtualDirect);
    }
}

function KeyDownHandlerSearchNew(e,btn, vLang, VirtualDirect) {
    //process only the Enter key
    e = e || window.event;
    var keyCode = e.charCode || e.keyCode;
    if (keyCode === 13) {
        e.returnValue = false;
        e.cancel = true;
        fnStartSearchHomeNew(vLang, VirtualDirect);
    }
}

function KeyDownHandlerAccount(e,btn, vUrl, vIFrom) {
    //process only the Enter key
    e = e || window.event;
    var keyCode = e.charCode || e.keyCode;
    if (keyCode === 13) {
        e.returnValue = false;
        e.cancel = true;
        Start_home(vUrl, vIFrom);
    }
}


