﻿/***********************************************
*   FLASH DETECTION                            *
***********************************************/

var requiredMajorVersion = 8; // Major version of Flash required
var requiredMinorVersion = 0; // Minor version of Flash required
var requiredRevision = 0; // Minor revision of Flash required

/***********************************************
*   END OF FLASH DETECTION                     *
***********************************************/
    
function CheckBought()
{
    if(document.getElementById("chkBought").checked)
    {
        ValidatorEnable(reqStore,true);
        document.getElementById("trStore").style.display = "";
        document.getElementById("trStore2").style.display = "none";
    
    } // end if
    else
    {
        ValidatorEnable(reqStore,false);
        document.getElementById("trStore").style.display = "none";
        document.getElementById("trStore2").style.display = "";
    
    } // end else
            
} // end function CheckBought

function ShowForecast()
{
    if(document.getElementById("News1_forecast").style.display=="none")
        document.getElementById("News1_forecast").style.display="";
    else
        document.getElementById("News1_forecast").style.display="none";
        
    calcHeight2();
    
} // end function ShowForecast

function calcHeight()
{   
  if(parent.document.getElementById("main") != null)
  {  
    document.getElementById('main').style.display = "";
    
      //find the height of the internal page
      var the_height=
        document.getElementById('main').contentWindow.
          document.body.scrollHeight;
        
      //change the height of the iframe
      document.getElementById('main').height=
          the_height;
  
  } // end if

} // end function calcHeight

function calcHeight2()
{       
    if(parent.document.getElementById("main") != null)
    {
        parent.document.getElementById("main").style.display = "";
    
      var the_height=document.body.scrollHeight;
        
      //change the height of the iframe
      parent.document.getElementById("main").height=
          the_height;
      
    } // end if

} // end function calcHeight

function numbersonly(e)
{
    var unicode=e.charCode? e.charCode : e.keyCode
        
    if(unicode!=8 && unicode!=9)
    {
        if (unicode<48 || unicode>57)
        return false;
    }

} // end function numbersonly

function ValidateLogin()
{
    if(document.getElementById("Login1_txtUsername").value=="Email Address")
        ValidatorEnable(Login1_emailFormatVal,false);
    else
        ValidatorEnable(Login1_emailFormatVal,true);

} // end function ValidateFunction

function SelectStore()
{
    document.getElementById("txtStore").value = document.getElementById("ddlStores").value;    

} // end function SelectStore

function ShowFullSpecs() {
    document.getElementById("tblFullSpecs").style.display = "";
    document.getElementById("tblGeometry").style.display = "none";
    document.getElementById("tblOverview").style.display = "none";

    document.getElementById("lnkShowOverview").className = "link";
    document.getElementById("lnkShowFull").className = "selected";
    document.getElementById("lnkShowGeo").className = "link";

    calcHeight2();

} // end function ShowFullSpecs

function ShowOverview() {

    document.getElementById("tblGeometry").style.display = "none";
    document.getElementById("tblFullSpecs").style.display = "none";
    document.getElementById("tblOverview").style.display = "";

    document.getElementById("lnkShowOverview").className = "selected";
    document.getElementById("lnkShowFull").className = "link";
    document.getElementById("lnkShowGeo").className = "link";

    calcHeight2();

} // end function ShowFullSpecs

function ShowGeometry() {

    document.getElementById("tblGeometry").style.display = "";
    document.getElementById("tblFullSpecs").style.display = "none";
    document.getElementById("tblOverview").style.display = "none";

    document.getElementById("lnkShowOverview").className = "link";
    document.getElementById("lnkShowFull").className = "link";
    document.getElementById("lnkShowGeo").className = "selected";

    calcHeight2();

} // end function ShowGeometry

var xmlHttp;
var xmlHttp2;

/***********************************************
*   POLL                                       *
***********************************************/

function showPollResults(pollid,option,usrid)
{ 
    xmlHttp=GetXmlHttpObject();
    
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    
    var url="poll_results.ashx?id="+pollid+"&o="+option+"&uid="+usrid;
//alert(url);
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);

} // end function showPollResults

function SubmitPoll()
{
    option = 0;
    
    if(document.getElementById("btnOption1").checked)
        option = 1;
    if(document.getElementById("btnOption2").checked)
        option = 2;
    if(document.getElementById("btnOption3").checked)
        option = 3;
    
    pollid = document.getElementById("Poll1_hidPoll").value;
    usrid = document.getElementById("Poll1_hidUser").value;
    showPollResults(pollid, option,usrid);
    
} // end function SubmitPoll

function stateChanged() 
{ 
    if (xmlHttp.readyState==4)
    {
        document.getElementById("poll_body").innerHTML=xmlHttp.responseText;
        calcHeight2();
    
    } // end if

} // end function

/***********************************************
*   END OF POLL                                *
***********************************************/

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;
}

/***********************************************
*   EMAIL FRIEND                               *
***********************************************/

function ShowEmailFriend(id) {
    
    document.getElementById("frame_noframe").src = "email_friend.aspx?id=" + id;

    document.getElementById("email_friend_noframe").style.display = "";
    document.getElementById("email_friend_noframe").style.height = document.body.clientHeight + "px";
    document.getElementById("email_friend_noframe").style.width = document.body.clientWidth + "px";
    document.getElementById("email_friend_panel_noframe").style.display = "";

    docHeight = document.documentElement.clientHeight;
    panelHeight = document.getElementById("email_friend_panel_noframe").clientHeight;

    docWidth = document.documentElement.clientWidth;
    panelWidth = document.getElementById("email_friend_panel_noframe").clientWidth;

    var yScroll;

    if (self.pageYOffset)
        yScroll = self.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    else if (document.body) // all other Explorers
        yScroll = document.body.scrollTop;

    document.getElementById("email_friend_panel_noframe").style.left = ((parseInt(docWidth) - parseInt(panelWidth)) / 2) + "px";
    document.getElementById("email_friend_panel_noframe").style.top = yScroll + ((parseInt(docHeight) - parseInt(panelHeight)) / 2) + "px";

    if (document.getElementById("brand_flash_noframe") != null)
        document.getElementById("brand_flash_noframe").style.display = "none";

    if (document.getElementById("brand_panel_noframe") != null)
        document.getElementById("brand_panel_noframe").style.display = "";

} // end function

function ShowEmailFriendComp(id)
{   
    document.getElementById("frame_noframe").src = "email_friend_comp.aspx?id=" + id;

    document.getElementById("email_friend_noframe").style.display = "";
    document.getElementById("email_friend_noframe").style.height = document.body.clientHeight + "px";
    document.getElementById("email_friend_noframe").style.width = document.body.clientWidth + "px";
    document.getElementById("email_friend_panel_noframe").style.display = "";

    docHeight = document.documentElement.clientHeight;
    panelHeight = document.getElementById("email_friend_panel_noframe").clientHeight;

    docWidth = document.documentElement.clientWidth;
    panelWidth = document.getElementById("email_friend_panel_noframe").clientWidth;

    var yScroll;

    if (self.pageYOffset)
        yScroll = self.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    else if (document.body) // all other Explorers
        yScroll = document.body.scrollTop;

    document.getElementById("email_friend_panel_noframe").style.left = ((parseInt(docWidth) - parseInt(panelWidth)) / 2) + "px";
    document.getElementById("email_friend_panel_noframe").style.top = yScroll + ((parseInt(docHeight) - parseInt(panelHeight)) / 2) + "px";

    if (document.getElementById("brand_flash_noframe") != null)
        document.getElementById("brand_flash_noframe").style.display = "none";

    if (document.getElementById("brand_panel_noframe") != null)
        document.getElementById("brand_panel_noframe").style.display = "";

} // end function

function CloseEmail()
{
    document.getElementById("email_friend").style.display = "none";
    document.getElementById("email_friend_panel").style.display = "none";
    
    if(parent.document.getElementById("Email_friend1_bg")!=null)
        parent.document.getElementById("Email_friend1_bg").style.display = "none";
            
    if(self.frames["main"].document.getElementById("brand_flash")!=null)
        self.frames["main"].document.getElementById("brand_flash").style.display = "";
    
    if(self.frames["main"].document.getElementById("brand_panel")!=null)    
        self.frames["main"].document.getElementById("brand_panel").style.display = "none";
    
} // end function CloseEmail

function CloseEmailNoFrame()
{
    document.getElementById("email_friend_noframe").style.display = "none";
    document.getElementById("email_friend_panel_noframe").style.display = "none";
    
    if(document.getElementById("Email_friend1_bg")!=null)
        document.getElementById("Email_friend1_bg").style.display = "none";

    CloseAccessories();
        
} // end function CloseEmail

/***********************************************
*   END OF EMAIL FRIEND                               *
***********************************************/

/***********************************************
*   FAVOURITES                                 *
***********************************************/

function RemoveFave(modelid)
{
    AddFave(-modelid);
    
} // end RemoveFave

function AddFave(modelid)
{ 
    //alert(modelid);

    xmlHttp=GetXmlHttpObject();
    
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    
    var url="favourites.aspx?id="+modelid;
    xmlHttp.onreadystatechange=faveChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);   

} // end function AddFave

function faveChanged() 
{ 
    if (xmlHttp.readyState==4)
    {
        responseTxt = xmlHttp.responseText;
        
        //alert(responseTxt);
        document.getElementById("fave").innerHTML=responseTxt;
        
        //alert(responseTxt);
        
        if(responseTxt.length>0)
            document.getElementById("Favourites1_fave_panel").style.display = "";
        else
            document.getElementById("Favourites1_fave_panel").style.display = "none";
            
        calcHeight2();
    
    } // end if

} // end function

/***********************************************
*   END OF FAVOURITES                                 *
***********************************************/

/***********************************************
*   MOUSE OVERS                                *
***********************************************/

function BrandOver(brandid)
{
    document.getElementById("imgBrand" + brandid).src = "images/brands/main_brand_logo_" + brandid + "_over.gif";
    //document.getElementById("imgBrand" + brandid).src = "brand_logo.ashx?id=" + brandid + "&d=l&t=o";

} // end function BrandOver

function BrandOut(brandid)
{
    document.getElementById("imgBrand" + brandid).src = "images/brands/main_brand_logo_" + brandid + ".gif";
    //document.getElementById("imgBrand" + brandid).src = "brand_logo.ashx?id=" + brandid + "&d=l";

} // end function BrandOut

function BrandOverSmall(brandid)
{
    document.getElementById("imgBrand"+brandid).src = "images/brands/main_brand_logo_"+brandid+"_over_small.gif";

} // end function BrandOverSmall

function BrandOutSmall(brandid)
{
    document.getElementById("imgBrand"+brandid).src = "images/brands/main_brand_logo_"+brandid+"_small.gif";

} // end function BrandOutSmall

function StyleOver(styleid)
{
    document.getElementById("imgStyle"+styleid).src = "images/styles/style_"+styleid+"_over.gif";

} // end function StyleOver

function StyleOut(styleid)
{
    document.getElementById("imgStyle"+styleid).src = "images/styles/style_"+styleid+".gif";

} // end function StyleOut

function StyleOverSmall(styleid)
{
    document.getElementById("imgStyle"+styleid).src = "images/styles/style_"+styleid+"_over_small.gif";

} // end function StyleOverSmall

function StyleOutSmall(styleid)
{
    document.getElementById("imgStyle"+styleid).src = "images/styles/style_"+styleid+"_small.gif";

} // end function StyleOutSmall

/***********************************************
*   END OF MOUSE OVERS                                *
***********************************************/

function addOption(selectbox,text,value)
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);

} // end function addOption

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		selectbox.remove(i);
	
	} // end for

} // end function removeAllOptions

function ShowImage(imageid)
{
	document.getElementById("panel").style.backgroundImage = "url(image.ashx?id="+imageid+"&d=f)";	

} // end function ShowImage

function pwdClick()
{
    document.getElementById("Login1_txtPassword").style.display = "";
    document.getElementById("Login1_txtPassword_Temp").style.display = "none";

} // end function pwdFocus

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
    window.location = "/searching.aspx?searchfor="+document.getElementById("Search1_txtSearch").value;
   return false;
   }
else
   return true;
}