﻿// JScript File

/*== Strat MasterPage.master ==*/

/*---------Nav-----------------*/
//Nav mouse on class
function FrontNavOnMouseOver(navitem)
{
  navitem.style.cursor="pointer";
  var list=navitem.getElementsByTagName('img');
  if(list.length!=0)
   {
     var temp=list[0].src;
     list[0].src=temp.replace("normal","active");
   }
}
//Nav mouse out class
function FrontNavOnMouseOut(navitem)
{
 navitem.style.cursor="default";
 var list=navitem.getElementsByTagName('img');
 if(list.length!=0)
   {
     var temp=list[0].src;
     list[0].src=temp.replace("active","normal");
   }
}

//Show the nav and sub nav selected, depend on the request url
function FrontNav_SubNavOnCurrent(url)
{
   
   var temp=url.toLowerCase();
   var navitem;
   var subnavitem;
   var BenefitsToAnimalArray=new Array("benefits_","casestudies_","science_");
   var ProductRangeArray=new Array("minisystem","minisystemproduct","ft1200","ft2500","highervolume","maxisystem");
   
   //Home Page
   if((temp.indexOf(".aspx")==-1)||(temp.indexOf("/home/default.aspx")!=-1))
   {
     
      navitem=document.getElementById("nav_default");//find nav item
      OnCurrent(navitem);//active the nav item
   }
   
   //Other Page 
  
   else 
   {
     var nav=temp.replace("http://","");
      //Nav
     if(nav.indexOf("/")!=-1)
     {
       
        var list=nav.split("/");
        if((list.length==3)&&(list[1]!=null))
        {
          
           var navid="nav_"+list[1];
           navitem=document.getElementById(navid);
           OnCurrent(navitem);
        }
        
        //SubNav
        if(list[list.length-1].indexOf(".aspx")!=-1)
        {
            var temp=list[list.length-1].replace(".aspx","");
            
            var temp2=temp;
           
            //If this page is under a kind of animal,highlight the relevant animal nav tag.  
            for(var i=0;i<BenefitsToAnimalArray.length;i++)
              if(temp.indexOf(BenefitsToAnimalArray[i])!=-1)
                  temp2=temp.replace(BenefitsToAnimalArray[i],"");
                  
            //If this page is under product range category, highlight the product range nav tag.
            for(var j=0; j<ProductRangeArray.length;j++)
            if(temp.indexOf(ProductRangeArray[j])!=-1)
               {
                  temp2="product_range";
                  break;
               }            
            
            var subid="sub_"+temp2;
            subnavitem=document.getElementById(subid);
          
            if(subnavitem!=null)
            {
              subnavitem.style.backgroundImage='url(../img/nav/nav2_active.jpg)';
              //subnavitem.style.color="#206ea6";
              OnCurrent(subnavitem);
            }
        }
        
     }
     
    
   }
 
}

//Nav or sub nav on selected class
function OnCurrent(navitem) {
    
    if (navitem != null) {
        navitem.style.cursor = "default";
        navitem.onmouseover = new Function("");
        navitem.onmouseout = new Function("");
        FrontNavOnMouseOver(navitem);
    }
}

/*---------Sub Nav-----------------*/

//sub nav mouse on class
function FrontSubNavOnMouseOver(subnavitem)
{ 
   subnavitem.style.cursor="pointer";
   FrontNavOnMouseOver(subnavitem);
   //subnavitem.style.backgroundImage='url(../img/nav/nav2_active.jpg)';
}
//sbu nav mouse off class
function FrontSubNavOnMouseOut(subnavitem)
{
   subnavitem.style.cursor="default";
   FrontNavOnMouseOut(subnavitem);
   //subnavitem.style.backgroundImage=''; 
}


/*-------------- Find the flash player version------------------------ */
 // Detect Client Browser type
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
      // NS/Opera version >= 3 check for Flash plugin in plugin array
      if (navigator.plugins != null && navigator.plugins.length > 0) {
            if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                  var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                        var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                        descArray = flashDescription.split(" ");
                        tempArrayMajor = descArray[2].split(".");
                        versionMajor = tempArrayMajor[0];
                  if ( descArray[3] != "" ) {
                        tempArrayMinor = descArray[3].split("r");
                  } else {
                        tempArrayMinor = descArray[4].split("r");
                  }
                        versionMinor = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
                        flashVer = parseFloat(versionMajor + "." + versionMinor);
            } else {
                  flashVer = -1;
            }
      }
      // MSN/WebTV 2.6 supports Flash 4
      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
      // WebTV 2.5 supports Flash 3
      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
      // older WebTV supports Flash 2
      else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
      // Can't detect in all other cases
      else {
            
            flashVer = -1;
      }
      return flashVer;
}


//Main class to get the flash player version of the broswer.
//Start form version 25 to version 1.
//If the broswer is ie,system is windows and not opera, use vbscript to find the flash player version,
//else use the JSGetSwfVer() class to find the flash player version.
function FrontFlash_GetBroswerFlashVersion()
{
     var version=-1; 
     for(var i=25;i>0;i--)
     {
        var temp;
        if(isIE && isWin && !isOpera) 
            temp = VBGetSwfVer(i);
        else 
            temp = JSGetSwfVer(i);
       if((temp!=-1)&&(temp!=0))
           version=temp;
    }
 
   return version;

}

/*== End   MasterPage.master ==*/


/*== Start Default.aspx ==*/
function FrontHomeBanner_OnAutoClick()
{
  var list=document.getElementById("HomeBannerList");
  var itemlist=list.getElementsByTagName("img");
  var temp=document.getElementById("HomeBannerLinkSmalllink");
  for(var i=0;i<itemlist.length;i++)
  {
     if((itemlist[i].alt!="|")&&(itemlist[i].alt==temp.innerHTML))
     {
      
        if(i==itemlist.length-1)
           {
             FrontHomeBannerItem_OnClick(itemlist[0]);
             break;
           } 
        else
           {
            FrontHomeBannerItem_OnClick(itemlist[i+2]);
            break;
           }
     }
  }

}

function FrontHomeBannerItem_OnClick(item)
{



  var imgsrc=item.src.replace("_small","");
  item.style.border="solid 1px white";

  document.getElementById("HomeBannerImg").style.background="url('"+imgsrc+"')";
  document.getElementById("HomeBannerLinkBiglink").href=item.getAttribute("href");
  document.getElementById("HomeBannerLinkSmalllink").href=item.getAttribute("href");
  document.getElementById("HomeBannerLinkSmalllink").innerHTML=item.alt;
  
  //document.getElementById("HomeBannerLink").innerHTML=item.alt;
  item.onmouseover=new Function("");
  item.onmouseout=new Function("");
 
  var list=document.getElementById("HomeBannerList");
  var itemlist=list.getElementsByTagName("img");
 
  for(var i=0;i<itemlist.length;i++)
  {
     if((itemlist[i].alt!="|")&&(itemlist[i].id!=item.id))
        FrontHomeBannerItem_OnRecover(itemlist[i]);
  }
}

function FrontHomeBannerItem_OnRecover(item)
{
   item.style.border="solid 1px transparent";
   item.onmouseover=new Function("FrontHomeBannerItem_OnMouseOver(this)");
   item.onmouseout=new Function("FrontHomeBannerItem_OnMouseOut(this)");
}

function FrontHomeBannerItem_OnMouseOver(item)
{
  //item.style.border="solid 1px white";
  FrontHomeBannerItem_OnClick(item);
}

function FrontHomeBannerItem_OnMouseOut(item)
{
 // item.style.border="solid 1px transparent";
  FrontHomeBannerItem_OnRecover(item);
}

/*== End   Default.aspx ==*/

/*== Start Enquiries.aspx ==*/

/*Dropdownlist*/
function EnquiriesDDL_OnCurrent(url)
{
  if(url.indexOf("Enquiries.aspx")!=-1)
    document.getElementById("Enquiriesddldrownbkg").style.display="";
}
function EnquiriesDDL_OnClick()
{
  document.getElementById("Enquiriesddldrownlist").style.display="block";
  var ddldisplay=document.getElementById("Enquiriesddldisplay");
  ddldisplay.style.border="solid 1px black";
  ddldisplay.onmouseout=new Function("");
}

function EnquiriesDDLitem_OnMouseOver(item)
{
 item.style.backgroundColor='#206ea6';
 item.style.color='white';
}

function EnquiriesDDLitem_OnMouseOut(item)
{
 item.style.backgroundColor='white';
 item.style.color='#696a6e';
}

function  EnquiriesDDLitem_OnClick(item)
{
  document.getElementById("Enquiriesddltxt").innerHTML=item.innerHTML;
  document.getElementById("Enquiriesddldrownlist").style.display="none";
  document.getElementById("ctl00_ContentPlaceHolder1_txttitle").value=item.innerHTML;
 
  var ddldisplay=document.getElementById("Enquiriesddldisplay");
  ddldisplay.style.border="none";
  ddldisplay.onmouseout=new Function("this.style.border='none'");
}

/*CheckBox*/
function EnquireiesChk_OnClick(item)
{
  var chkphone=document.getElementById("ctl00_ContentPlaceHolder1_chkphone");
  var chkemail=document.getElementById("ctl00_ContentPlaceHolder1_chkemail");
  var txt=document.getElementById("ctl00_ContentPlaceHolder1_txtcontactway");
  var temp=item.src;
  if(temp.indexOf("img/button/chk_off.jpg")!=-1)
  {  
    
    item.src="../img/button/chk_on.jpg";
    if(item.id=="ctl00_ContentPlaceHolder1_chkphone")
     {
       chkemail.src="../img/button/chk_off.jpg";
       txt.value="Phone";
     }
    else
     {
       chkphone.src="../img/button/chk_off.jpg";
       txt.value="Email";
     }
  }
}

/*== End   Enquiries.aspx ==*/ 
/*== Start BenefitstoAnimals.aspx ==*/
function RightItem_OnClick(item)
{
  var panel=document.getElementById("ctl00_ContentPlaceHolder1_html_pagecontent");
  var list=panel.getElementsByTagName("div");
  var temp=item*5;
  
  if(list.length!=0)
  {
    for(var i=0;i<list.length;i++)
    {    
      if(list[i].className=="BenefitsLeftItem")
      {
        if(i==temp)
           list[i].style.display="block";
        else
          list[i].style.display="none";
      }
    }
  }
}

function RightItem_OnMouseOver(item)
{
  var temp=item.src.replace("normal","active");
  item.src=temp;
}
function RightItem_OnMouseOut(item)
{
  var temp=item.src.replace("active","normal");
  item.src=temp;
}
/*== End   BenefitstoAnimals.aspx ==*/ 
