var g_CurrentFlyout = "";
var g_CurrentBubble = "";

var g_CurrentSpecialFocus = "";		
var g_DebugSpecialBubbles = false;	

var g_Stalled = false;
var g_MenuMustClose = false;
var g_MenuDebugIsOn = false;

var g_MastheadOffsetHeight = 0;

var g_CancelConsoleHide = false;

var g_BoxFloat_LastY = 0;
var g_BoxFloat_Count = 0;

var b_LogonInProgress = false;
var b_ForgotPasswordInProgress = false;
var b_SignupForNewsletterInProgress = false;

var b_BusyReporting = false;

var b_TermAndConditionsAccepted = false;

var g_CurrentPersonalisationUpsellId = "UpsellItem0";


g_LogoOn_NF = new Image();
g_LogoOn_NG = new Image();

function __correctLayout() {
    if ( //IE 6 AND 7 DOESN'T LIKE MY TOPBAR, AND IE6 DOESN'T LIKE FLOATING MY LEFT BAR
            (
                BrowserDetect.browser == "Explorer"
            )
            &&
            (
                BrowserDetect.version == 6
                ||
                BrowserDetect.version == 7
            )
        ) {
        var o_D = document.getElementById("D"); //content
        var o_C = document.getElementById("C"); //leftbar
        var o_B = document.getElementById("B"); //advert bar
        var o_A = document.getElementById("A"); //topbar
        var o_F = document.getElementById("F"); //only exists on B.Master
        var o_SearchButton = document.getElementById("SearchButton");
        var o_SearchField = document.TopSearch.Search;

        if (o_B && o_A) {
            //we set the topbar to be from the left of the screen
            //based on the distance that the advert bar is from the
            //left of the screen.
            o_A.style.left = o_B.offsetParent.offsetLeft + "px";
        }
        else if ((!o_B) && o_A && o_D) {
            o_A.style.left = o_C.offsetParent.offsetLeft + "px";
        }

        if (o_SearchButton && o_SearchField) { //because NOBR is not working, and IE6 & IE7 loves breaking my button to a new line
            o_SearchButton.style.float = "none";
            o_SearchButton.style.top = "-25px"
            o_SearchButton.style.position = "relative";
            o_SearchField.style.position = "relative";
            o_SearchField.style.right = "57px";
        }

        if (o_C && BrowserDetect.version == 6) {
            //set the leftbar to appear left of the content element,
            //minus the width of the menu
            o_C.style.position = "absolute"; //absolute, so that we can position it directly
            o_C.style.top = o_D.offsetTop + "px"; //content's offset from top
            o_C.style.left = (o_D.offsetLeft - 283) + "px"; //content's offset from left, minus width of menu
        }

        if (o_F && BrowserDetect.version == 7) {
            //set the leftbar to appear left of the content element,
            //minus the width of the menu
            o_C.style.position = "absolute"; //absolute, so that we can position it directly
            o_C.style.top = o_F.offsetTop + "px"; //content's offset from top
            o_C.style.left = (o_F.offsetLeft - 213) + "px"; //content's offset from left, minus width of menu

            //if the advert height plus the content height is smaller than the leftbar
            //set the content height to be the leftbar height minus the advert height
            //(because IE7 (and prolly IE6) is floating the leftbar in a weird manner)
            if (o_F.offsetHeight + o_D.offsetHeight < o_C.offsetHeight) {
                o_D.style.height = (o_C.offsetHeight - o_F.offsetHeight) + "px";
            }
        }
    }

    __loadMouseOvers();
}

function __loadMouseOvers() {
    var s_Path = "";

    if (document.getElementById("NetFloristImage") != null) {
        s_Path = document.getElementById("NetFloristImage").src;
        s_Path = s_Path.substring(0, s_Path.lastIndexOf("/") + 1);

    }
    else if (document.getElementById("NetGiftsImage") != null) {
        s_Path = document.getElementById("NetGiftsImage").src;
        s_Path = s_Path.substring(0, s_Path.lastIndexOf("/") + 1);
    }

    g_LogoOn_NF.src = s_Path + "tp_logo_netflorist_on.gif";
    g_LogoOn_NG.src = s_Path + "tp_logo_netgifts_on.gif";
}

function InitiateTopSearch() {
    /* 
    This function performs a cleanup of the GET url that will be 
    submitted next (gets rid of odd x y coordinates that'll be 
    uncool for search engines 
    */
    if (document.RealSearch != null && document.TopSearch != null) {
        if (document.TopSearch.value != "Search") {
            document.RealSearch.Search.value = document.TopSearch.Search.value;
            document.RealSearch.PageNumber.value = "1";
            document.RealSearch.PriceStart.value = "-1";
            document.RealSearch.PriceStop.value = "-1";
            document.RealSearch.submit();
        }
        else
        {
            return false;
        }
    }
    else 
    {
        return false;
    }
}

function ScrewWithIframesForHoursOn(oObject) {
}

function ScrewWithIframesForHoursOff(oObject) {
}

function NetFloristZoomOpen(){
  var oZoomed = document.getElementById("ImageZoomed");
  var oTT = document.getElementById("Title");
  if(oZoomed){
	oTT?oZoomed.style.top=oTT.offsetHeight:null;
    oZoomed.className = oZoomed.className.replace("hideMe","showMe");
  }
}

function NetFloristZoomClose(){
  var oZoomed = document.getElementById("ImageZoomed");
  if(oZoomed!=null){
    oZoomed.className = oZoomed.className.replace("showMe","hideMe");
  }
}

function delayZoomOut(){
  self.setTimeout("NetFloristZoomClose();", 500)
}

function RefreshTemplate(){
	g_MastheadOffsetHeight = 0;
	_fn_FTA();
}

/*************************************************/
/*  Caching support: Restructure basket link     */
/*************************************************/
function AdjustBasketLink(cwProd,cwState,cwCountry,cwPrice,cwUpsellList,cwPersonalisationText,cwBalloonText,cwBalloonOption){
  var s_NewUrl = "";
  var b_BDUrlIsOn = false;
  var b_IsFPSpecial = false;

  if (typeof(s_SiteRootURL) != "undefined") {
      if (s_SiteRootURL.length > 0) {
          s_NewUrl += s_SiteRootURL;
      }
  }

  if(typeof(__nfwinelabel_SelectedWine)!="undefined"){
	if(__nfwinelabel_SelectedWine.length>0){
		cwUpsellList += ",32-1";
	}
  }
  
  s_NewUrl += "/Go/AddToBasket/?cwpg=43&cwprod="+cwProd+"&cwstate="+cwState+"&UseThisCountry="+cwCountry+"&cwprice="+cwPrice+"&ups="+URLEncode(cwUpsellList);
  if(String(cwPersonalisationText)!="undefined"){
	s_NewUrl += "&prn="+URLEncode(cwPersonalisationText);
  }
  if(String(cwBalloonOption)!="undefined"){
	s_NewUrl += "&bln="+URLEncode(cwBalloonOption);
  }
  if(String(cwBalloonText)!="undefined"){
	s_NewUrl += "&blntxt="+URLEncode(cwBalloonText);
  }
  if(String(__nfwinelabel_SelectedWine)!="undefined"){
	if(__nfwinelabel_SelectedWine.length>0){	
		s_NewUrl += "&wloption="+URLEncode(__nfwinelabel_SelectedWine);
	}
	if(__nfwinelabel_WineLabelText1.length>0){		
		s_NewUrl += "&wl01="+URLEncode(__nfwinelabel_WineLabelText1);
	}
	if(__nfwinelabel_WineLabelText2.length>0){		
		s_NewUrl += "&wl02="+URLEncode(__nfwinelabel_WineLabelText2);
	}
	if(__nfwinelabel_WineLabelText3.length>0){		
		s_NewUrl += "&wl03="+URLEncode(__nfwinelabel_WineLabelText3);
	}
	if(__nfwinelabel_WineLabelText4.length>0){		
		s_NewUrl += "&wl04="+URLEncode(__nfwinelabel_WineLabelText4);
	}
  }

  if (typeof(s_BDUrl) != "undefined") {
      s_NewUrl += "&dm=" + URLEncode(s_BDUrl);
  }

  switch (cwProd) {
      case 24752:
          b_IsFPSpecial = true;
          break;
      case 24754:
          b_IsFPSpecial = true;
          break;
      case 24756:
          b_IsFPSpecial = true;
          break;
      case 44774:
          b_IsFPSpecial = true;
          break;
      case 44775:
          b_IsFPSpecial = true;
          break;
      case 44776:
          b_IsFPSpecial = true;
          break;
      default: 
          b_IsFPSpecial = false;
  }

  if(!b_IsFPSpecial){
    TrackAbandonedBasketInfo();
  }

  document.forms["BasketDetailForm"].action = s_NewUrl;
  document.forms["BasketDetailForm"].submit();
  
  return true;
}

/*************************************************/
/*  Caching support: Restructure basket link     */
/*************************************************/
function AdjustQueryLink(cwProd,cwPrice){
  var s_NewUrl = "";
  if(
        location.hostname != "www.netflorist.co.za"
        &&
        location.hostname != "ww1.netflorist.co.za"
        &&
        location.hostname != "ww2.netflorist.co.za"
        &&
        location.hostname != "www.netgifts.co.za"
        &&
        location.hostname != "ww1.netgifts.co.za"
        &&
        location.hostname != "ww2.netgifts.co.za"
  )
  {
    s_NewUrl += "http://www.netflorist.co.za";
}

  if (s_CurrentProductId != null) {
      s_NewUrl += "/Go/BusinessServices/AddToCart/?ProductId=" + s_CurrentProductId;
  }

  document.forms[0].action = s_NewUrl;

  document.forms[0].submit();
  
  return true;
}

/*************************************************/
/*  Caching support: Terms and Conditions alert  */
/*************************************************/
function TermsAndConditionsChallenge(){
	var b_TACCResult = true;
	var o_TACCWindow = document.getElementById("TermsConditionsAction");
	
	var b_RequiresTermsAndConditions_Acceptance = document.getElementById("TermsConditionsAction")?true:false;

	if(o_TACCWindow&&b_TermAndConditionsAccepted==false){
		o_TACCWindow.style.display = "block";
	}
	
	o_TACCWindow = null;
	
	return ;//b_TACCResult;
}

/*************************************************/
/*  Caching support: Terms and Conditions accept */
/*************************************************/
function TermsAndConditionsAccept(){
	var o_TACCWindow = document.getElementById("TermsConditionsAction");
	
	b_TermAndConditionsAccepted = true;
	
	//change text
	
	//hide	
	o_TACCWindow.style.display = "none";
	
	o_TACCWindow = null;
	
	AddToBasket();
}

/*************************************************/
/*  Caching support: Terms and Conditions cancel */
/*************************************************/
function TermsAndConditionsCancel(){
	var o_TACCWindow = document.getElementById("TermsConditionsAction");
	
	b_TermAndConditionsAccepted = false;
	
	//hide	
	o_TACCWindow.style.display = "none";
	
	o_TACCWindow = null;
}

/*************************************************/
/*  Caching support: Add to basket event         */
/*************************************************/
function AddToBasket(){
  var i_Variant = 0;
  var i_Selected = 1;
  var i_Upsell = 0;
  var s_Upsell = "";
  var i_UpsellCount = 0;
  var s_PersonalisationText = "";
  var b_PersonalisationEnabled = (document.BasketDetailForm.prnText ? true : false);
  var s_BalloonText = "";
  var s_BalloonOption = "";
  i_Selected = document.BasketDetailForm.VariantOption != null ? document.BasketDetailForm.VariantOption.options[document.BasketDetailForm.VariantOption.selectedIndex].value : 1;
  for(i_Variant=0;i_Variant<document.getElementsByName("optUpsellFromInfo").length;i_Variant++){
    if(document.getElementsByName("optUpsellFromInfo")[i_Variant].checked){
      i_UpsellCount += 1;
      if(i_UpsellCount>1){
        s_Upsell += ",";
      }
      s_Upsell += document.getElementsByName("optUpsellFromInfo")[i_Variant].value;
    }
  }
  if(i_UpsellCount==0){
    s_Upsell = "0-0"; //no upsell
  }
  if(b_PersonalisationEnabled){ /* THEN ENFORCE PERSONALISATION */
      if (document.forms[0].prnOption && document.forms[0].prnOption.value.length > 0 && document.forms[0].prnOption.value != "UpsellItem0") {
          if (document.forms[0].prnOption != g_CurrentPersonalisationUpsellId) { //it's not the default option
			//so set the value from the active text box
		    if (document.getElementById(document.forms[0].prnOption.value)) {
		        var s_TMPPRNName = document.getElementById(document.forms[0].prnOption.value).id.replace("UpsellItem", "UpsellItemText");
		        var s_TMPPRNLabel = document.getElementById(document.forms[0].prnOption.value).id.replace("UpsellItem", "UpsellItemLabel");
				if(document.getElementById(s_TMPPRNName).value.length==0){
					alert("To add this personalisation item to your basket, you need to enter the text that you would like to appear on this product.");
					return;	
				}
				var s_PRNChallenge = "";
				
				if(document.getElementById(s_TMPPRNName)){
					s_PersonalisationText = document.getElementById(s_TMPPRNName).value;
				}
				else
				{
				    s_TMPPRNName = document.getElementById(document.forms[0].prnOption.value).id.replace("UpsellItem", "UpsellItemLabel");
					if(document.getElementById(s_TMPPRNName)){
						s_PersonalisationText = document.getElementById(s_TMPPRNName).innerText;
					}				
				}	
				
				if(document.getElementById(s_TMPPRNLabel)){
					s_PRNChallenge += "You have chosen the ";
					if(document.getElementById(s_TMPPRNLabel).innerText!=null){
						s_PRNChallenge += document.getElementById(s_TMPPRNLabel).innerText.toUpperCase();				
					}
					else //Firefox fix (yes, I said Firefox fix... not IE fix. IE is the majority. Freetards).
					{
						s_PRNChallenge += document.getElementById(s_TMPPRNLabel).textContent.toUpperCase();
					}
					s_PRNChallenge += " personalisation option.\n\n";
				}
				s_PRNChallenge += "Are you happy with the following text to appear on this gift?\n\n";
				s_PRNChallenge += "     " + s_PersonalisationText + "     \n\n";
				s_PRNChallenge += "Click OK for yes, or click CANCEL to alter the text.";
				
				if(confirm(s_PRNChallenge)!=true){
					return;
				}
			}		
		}  
		else
		{
			alert("Please choose which type of personalistion you would like.");
			return;
		}
	}
	else
	{
		alert("Please choose which type of personalistion you would like.");
		return;
	}
  }
if (document.forms[0].balloonText && document.forms[0].balloonOption) {
    s_BalloonOption = document.forms[0].balloonOption.value;
    s_BalloonText = document.forms[0].balloonText.value;
  }
  
  AdjustBasketLink(s_CurrentProductId,2,s_CurrentCountryId,i_Selected, s_Upsell, s_PersonalisationText, s_BalloonText, s_BalloonOption);
  return;
}

/*************************************************/
/*  Caching support: Add to basket event         */
/*************************************************/
function AddToQuery(){

  var i_Variant = 0;
  var i_Selected = 1;
  var i_Upsell = 0;
  var s_Upsell = "";
  var i_UpsellCount = 0;
  for(i_Variant=0;i_Variant<document.getElementsByName("frmVariantOption").length;i_Variant++){
    if(document.getElementsByName("frmVariantOption")[i_Variant].checked){
      i_Selected = i_Variant + 1;
      break;
    }
  }
  
  AdjustQueryLink(s_CurrentProductId,i_Selected);
  return;
}

/*************************************************/
/*  FloatBox repositions floating boxes to an    */
/*  anchor target.                               */
/*************************************************/
function FloatBox(sFloat,sAnchor,iWidth,iSpacingTop,bAddComfortZone){
  var oAnchor = document.getElementById(sAnchor);
  var oFloat = document.getElementById(sFloat);
  var oSpirit = document.getElementById("SpiritLevel");
  var iSpirit = 0;
  var bDebug = false;
  
  var iVersion = 1;
  
  if(iVersion==1){ 
	/* 
		FINAL, RESTRUCTURED HTML, BROWSER WILL NOW AUTOMATICALLY
		TAKE CARE OF WHERE EACH BOX STARTS, BUT, WE STILL ENFORCE
		OUR FLOAT CALCULATION, WHICH DISPLAYS MORE NEATLY THAN 
		WHEN A BROWSER CALCULATES. (i.e. appears shrinkwrapped).
	*/
	if(oAnchor!=null&&oFloat!=null){
	
		//so we can see that the block has been adjusted (debugging)
		bDebug?oFloat.style.backgroundColor = (g_BoxFloat_Count%2==0?"#FF00FF":"#0FFFF0"):null;
		bDebug?oAnchor.style.backgroundColor = (g_BoxFloat_Count%2==0?"#FF00FF":"#0FFFF0"):null;
		
		bDebug?window.status = "ANC oH " + oAnchor.offsetHeight + "| " + window.status.substring(0,100):null;
		bDebug?window.status = "ANC oT " + oAnchor.offsetTop + "| " + window.status.substring(0,100):null;
		
		if(g_BoxFloat_Count==0){
			if( //Firefox 2, GoogleChrome
				(BrowserDetect.browser=="Firefox"&&BrowserDetect.version=="2")
				||
				(BrowserDetect.browser=="GoogleChrome")			
			){
				i_Spirit = oFloat.offsetTop;			
			}
			else //rest
			{
				i_Spirit = oFloat.offsetTop+oAnchor.offsetTop;
			}
			
		}
		
		if(
			(BrowserDetect.browser=="Firefox")
			||
			(BrowserDetect.browser=="GoogleChrome")			
		)
		{
			if((oFloat.offsetTop-i_Spirit)<oAnchor.offsetHeight){
				bDebug?window.status = "A FT " + oFloat.offsetTop + "| " + window.status.substring(0,100):null;
			}
			else
			{
				bDebug?window.status = "B FT " + oFloat.offsetTop + "| " + window.status.substring(0,100):null;
				oFloat.style.width = iWidth + oAnchor.offsetWidth;
			}
		}
		else
		{
			if((oFloat.offsetTop)<oAnchor.offsetHeight){
				bDebug?window.status = "A FT " + oFloat.offsetTop + "| " + window.status.substring(0,100):null;
			}
			else
			{
				bDebug?window.status = "B FT " + oFloat.offsetTop + "| " + window.status.substring(0,100):null;
				oFloat.style.width = iWidth + oAnchor.offsetWidth;
			}
		}
		
		g_BoxFloat_Count++;
	}  
  }
}

function nf_LogonStatusString(LogonStatusData){
	var c_LogonStatus_Num  = 0;
	var c_LogonStatus_Description  = 1;
	var c_LogonStatus_FirstName  = 2;
	var c_LogonStatus_LastName  = 3;
	var c_LogonStatus_UserId  = 4;
	
	var s_Data_Num = 0;
	var s_Data_Description = "";
	var s_Data_FirstName = "";
	var s_Data_LastName = "";
	var s_Data_UserId = 0;

	var s_EndKey = "EOL";
	
	var a_Object = LogonStatusData.split("|");
    
	if(a_Object[0]=="OK"){

		var i_Item = 0; 

		for (i_Item=1; i_Item<a_Object.length; i_Item++) 
		{ 
			var a_StatusData = a_Object[i_Item].split(",");
			
			var i_Data = 0;
			
			for (i_Data=0; i_Data<a_StatusData.length; i_Data++) 
			{
				if(i_Data==c_LogonStatus_Num){
					s_Data_Num = URLDecode(a_StatusData[i_Data])*1;
				}
				else if(i_Data==c_LogonStatus_Description){
					s_Data_Description = URLDecode(a_StatusData[i_Data]);
				}
				else if(i_Data==c_LogonStatus_FirstName){
					s_Data_FirstName = URLDecode(a_StatusData[i_Data]);
				}
				else if(i_Data==c_LogonStatus_LastName){
					s_Data_LastName = URLDecode(a_StatusData[i_Data]);
				}
				else if(i_Data==c_LogonStatus_UserId){
					s_Data_UserId = URLDecode(a_StatusData[i_Data])*1;
				}

			}
			
			if(s_Data_Num==200) //logon authenticated
			{
				document.getElementById("NFPanelLoggedNeutral")?document.getElementById("NFPanelLoggedNeutral").style.display="none":null;
				document.getElementById("NFPanelLoggedOff")?document.getElementById("NFPanelLoggedOff").style.display="none":null;
				document.getElementById("NFPanelLoggedOn")?document.getElementById("NFPanelLoggedOn").style.display="block":null;
				
				if(document.all){
					document.getElementById("NFPanelLoggedOnName")?document.getElementById("NFPanelLoggedOnName").innerText = s_Data_FirstName + " " + s_Data_LastName:null;
				} else{
					document.getElementById("NFPanelLoggedOnName")?document.getElementById("NFPanelLoggedOnName").textContent = s_Data_FirstName + " " + s_Data_LastName:null;
				}		
				
			}
			else //not currently logged on
			{
				document.getElementById("NFPanelLoggedNeutral")?document.getElementById("NFPanelLoggedNeutral").style.display="none":null;
				document.getElementById("NFPanelLoggedOn")?document.getElementById("NFPanelLoggedOn").style.display="none":null;
				document.getElementById("NFPanelLoggedOff")?document.getElementById("NFPanelLoggedOff").style.display="block":null;
			}
		}
	}
	return "";
}

function nf_PetalStatusString(PetalStatusData){

	var c_Petals_PetalCountActual  = 0;
	var c_Petals_BouquetsAvailable  = 1;
	var c_Petals_PetalCount  = 2;
	var c_Petals_PetalsToNextLevel  = 3;
	
	var s_Data_PetalCountActual = 0;
	var s_Data_BouquetsAvailable = 0;
	var s_Data_PetalCount = 0;
	var s_Data_PetalsToNextLevel = 0;
	
	var a_Object = PetalStatusData.split("|");
    
	if(a_Object[0]=="OK"&&URLDecode(a_Object[1])!="No results."){
		var i_Item = 0; 

		for (i_Item=1; i_Item<a_Object.length; i_Item++) 
		{ 
			var a_StatusData = a_Object[i_Item].split(",");
			
			var i_Data = 0;
			
			for (i_Data=0; i_Data<a_StatusData.length; i_Data++) 
			{
				if(i_Data==c_Petals_PetalCountActual){
					s_Data_PetalCountActual = a_StatusData[i_Data]*1;
				}
				else if(i_Data==c_Petals_BouquetsAvailable){
					s_Data_BouquetsAvailable = a_StatusData[i_Data]*1;
				}
				else if(i_Data==c_Petals_PetalCount){
					s_Data_PetalCount = a_StatusData[i_Data]*1;
				}
				else if(i_Data==c_Petals_PetalsToNextLevel){
					s_Data_PetalsToNextLevel = a_StatusData[i_Data]*1;
				}
			}
		}
		
		var s_Dialog = "";
		
		s_Dialog += "<img src=\"" + s_ProjectPath + "/layout/images/fp_petals_";
		if(s_Data_PetalCount=="0"&&s_Data_BouquetsAvailable>0){
			s_Dialog += s_Data_PetalCount<0?"0":""+s_Data_PetalCount;
			s_Dialog += s_Data_PetalCount;		
		}
		else
		{
			s_Dialog += s_Data_PetalCount<10?"0":""+s_Data_PetalCount;
			s_Dialog += s_Data_PetalCount;
		}
		s_Dialog += ".gif\" border=\"0\" />";

		
		s_Dialog += "You currently have " + (s_Data_PetalCount>0?"<b>"+GetWordForNumber(s_Data_PetalCount)+" petals</b>":"no petals");
		if(s_Data_BouquetsAvailable>0){
			s_Dialog += ", and <b>" + (s_Data_BouquetsAvailable==1?"one bouquet":GetWordForNumber(s_Data_BouquetsAvailable)+" bouquets") + "</b> available.";
		}
		else
		{
			s_Dialog += ".";
		}
		s_Dialog += "&nbsp; You need " + GetWordForNumber((s_Data_PetalsToNextLevel==0&&s_Data_PetalCount==0?10:s_Data_PetalsToNextLevel)) + " more " + (s_Data_PetalsToNextLevel==1?"petal":"petals") + " to get your next free bouquet.";
		
		document.getElementById("NFPanelPetalsOn")?document.getElementById("NFPanelPetalsOn").innerHTML=s_Dialog:null;
		document.getElementById("NFPanelPetalsOn")?document.getElementById("NFPanelPetalsOn").style.display="block":null;
		
		document.getElementById("NFPanelPetalsOn")?document.getElementById("NFPanelPetalsOn").parentElement.style.display="block":null;		
		document.getElementById("PanelPetalAdvert")?document.getElementById("PanelPetalAdvert").style.display="none":null;
		
		 
	}
	if(a_Object[0]=="OK"&&URLDecode(a_Object[1])=="No results.")
	{
		document.getElementById("PanelPetalAdvert")?document.getElementById("PanelPetalAdvert").style.display="block":null;
		document.getElementById("NFPanelPetalsOn")?document.getElementById("NFPanelPetalsOn").parentElement.style.display="none":null;
	}
	
	self.setTimeout("_fn_FTA();", 1000)
	
	if(a_Object[0]!="OK")
	{
		//alert("Error");
	}
	return "";
}

function nf_SubscribeToNewsletter(){
	b_SignupForNewsletterInProgress = true;
	document.forms[0].action = s_ProjectPath+"/_activecom/prd/subscribetonewsletter.asp";
	document.forms[0].ErrorUrl.value = s_ProjectPath+"/Logon.htm";
	if(document.getElementById("NewsletterSignupAddress"))
	{	
		document.forms[0].ReturnUrl.value = location.href;
		if(!JSCheckEmailAddress(document.getElementById("NewsletterSignupAddress").value)){
			alert("The address you have entered does not appear to be\na valid e-mail address.  Please correct the \naddress before continuing.");
			document.getElementById("NewsletterSignupAddress").select();
		}
		else
		{
			document.forms[0].submit();
		}
	}
}

function nf_LogonNow(){
    b_LogonInProgress = true;
	document.forms[0].action = s_ProjectPath+"/_activecom/prd/logon.asp";
	document.forms[0].ErrorUrl.value = s_ProjectPath+"/Logon.htm";
	if(location.href.toLowerCase().indexOf(s_ProjectPath.toLowerCase()+"/logon.htm")==-1){
		document.forms[0].ReturnUrl.value = location.href;
	}
	else
	{
		if(document.forms[0].ReturnUrl.value.length==0){
			document.forms[0].ReturnUrl.value = s_ProjectPath+"/MyAccount/";
		}
		else
		{
			document.forms[0].ReturnUrl.value = document.forms[0].ReturnUrl.value;
		}
	}
	document.forms[0].submit();
}

function nf_ForgotPasswordNow(){
    b_ForgotPasswordInProgress = true;
	document.forms[0].action = s_ProjectPath+"/_activecom/prd/forgotpassword.asp";
	document.forms[0].ErrorUrl.value = s_ProjectPath+"/ForgotPassword.aspx";
	if(location.href.toLowerCase().indexOf(s_ProjectPath.toLowerCase()+"/ForgotPassword.htm")==-1){
		document.forms[0].ReturnUrl.value = location.href;
	}
	else
	{
		if(document.forms[0].ReturnUrl.value.length==0){
			document.forms[0].ReturnUrl.value = s_ProjectPath+"/ForgotPassword.htm";
		}
		else
		{
			document.forms[0].ReturnUrl.value = document.forms[0].ReturnUrl.value;
		}
	}
	document.forms[0].submit();
}

function nf_SelectRelevantVariant(nfFormItemName){
	var sQueryString = "";

	var aQS;
	var sTmp;
	
	sQueryString = location.search.substr(1,location.search.length-1);
	
	var s_PD_Key_CurrentOption = "varopt";
	var s_PD_Value_CurrentOption = "0";
	var i_PD_Value_CurrentOption = 0;
	
	aQS = sQueryString.split("&");
	
	for (i = 0; i < aQS.length; i++) {
		if (aQS[i].substr(0,s_PD_Key_CurrentOption.length+1)==s_PD_Key_CurrentOption+"=") {
			s_PD_Value_CurrentOption = aQS[i].substring(s_PD_Key_CurrentOption.length + 1);
		}
	}
	
	switch(s_PD_Value_CurrentOption){
		case "2":
			i_PD_Value_CurrentOption = 1;
			break;
		case "3":
			i_PD_Value_CurrentOption = 2;
			break;
		case "4":
			i_PD_Value_CurrentOption = 3;
			break;
		case "5":
			i_PD_Value_CurrentOption = 4;
			break;
		default:
			i_PD_Value_CurrentOption = 0;				
	}
	
	selectFormItemRadioOption(nfFormItemName, "NFProductVariant_Name_", i_PD_Value_CurrentOption);
}

function nf_SelectRelevantVariantForce(VariantOption){
	selectFormItemRadioOption("frmVariantOption", "NFProductVariant_Name_", VariantOption-1);
}

function selectFormItemRadioOption(nfFormItemName, nfFormItemLabelNamePrfx, CurrentOption){

	for (i = 0; i < document.getElementsByName(nfFormItemName).length; i++) {
		document.getElementById(nfFormItemLabelNamePrfx+(i+1))?document.getElementById(nfFormItemLabelNamePrfx+(i+1)).className = "unBoldMe":null;
	}

	//bold
	document.getElementById(nfFormItemLabelNamePrfx+(CurrentOption+1))?document.getElementById(nfFormItemLabelNamePrfx+(CurrentOption+1)).className = "boldMe":null;

	if(document.getElementsByName(nfFormItemName).length>0){
	
		//select
		document.getElementsByName(nfFormItemName)?document.getElementsByName(nfFormItemName)[CurrentOption].checked = true:null;		
	
	}
}

function SearchNow(){
	if(!b_LogonInProgress&&!b_ForgotPasswordInProgress){
		var s_SearchText = document.getElementById("PanelSearchText").value;
		var s_SearchCountry = document.forms[0].lstCountry ? document.forms[0].lstCountry.options[document.forms[0].lstCountry.selectedIndex].text : "South Africa";
		var b_ResubmitSearch = false;//!self.nf_Search;
		if(b_ResubmitSearch){ //we're on the search page, so just call Ajax search
			s_Active_Search_Value_Text = s_SearchText;
			s_Active_Search_Value_Country = s_SearchCountry;
			s_Active_Search_Value_PageNumber = 1;
			nf_Search(
					s_Active_Search_Value_Text,
					s_Active_Search_Value_Country,
					s_Active_Search_Value_PageNumber,
					-1,
					-1
					);
			return false;
		}
		else //we're not on the search page, so go hit the Search page with clear text search
		{
			location.href = s_ProjectPath+"/Search/?Search="+URLEncode(s_SearchText)+"&Country=" + URLEncode(s_SearchCountry) +"&PageNumber=1&PriceStart=-1&PriceStop=-1";
			return false;
		}
	}
	else
	{
		return false;
	}
}

function reportToggle(){
	var o_ERTPanel = document.getElementById("ERTPanel");
	var o_ERTMessage = document.getElementById("ERTMessage");
	var o_ERTStatus = document.getElementById("ERTStatus");
	if(o_ERTPanel){
		if(b_BusyReporting){ //hide it, toggle off
			o_ERTPanel.style.display = "none";			
			o_ERTMessage.blur();
			b_BusyReporting = false;
		}
		else //show it, and toggle on
		{
			o_ERTPanel.style.display = "block";
			o_ERTMessage.focus();
			b_BusyReporting = true;
			o_ERTStatus?o_ERTStatus.innerHTML="&nbsp;":null;
		}
	}
}

function showDateRestrictions(){
	document.getElementById("RestrictionArea")?document.getElementById("RestrictionArea").style.display="inline-block":null;
	document.getElementById("RestrictionAreaLink")?document.getElementById("RestrictionAreaLink").style.display="none":null;
}
function hideDateRestrictions(){
	document.getElementById("RestrictionArea")?document.getElementById("RestrictionArea").style.display="none":null;
	document.getElementById("RestrictionAreaLink") ? document.getElementById("RestrictionAreaLink").style.display = "inline-block" : null;
}

function TogglePersonalisationUpsell(PRNUpsellToggleId){
	var o_PRNOld = document.getElementById(g_CurrentPersonalisationUpsellId);
	var o_PRNNew = document.getElementById(PRNUpsellToggleId);
	var o_PRNDefault = document.getElementById("UpsellItem0");
	
	if(PRNUpsellToggleId!=g_CurrentPersonalisationUpsellId){
		if(o_PRNOld){o_PRNOld.checked = false; }
		if(o_PRNNew){o_PRNNew.checked = true; g_CurrentPersonalisationUpsellId = PRNUpsellToggleId;}
		document.forms[0].prnOption.value = o_PRNNew.id;
	}
	else
	{
		if(o_PRNNew){o_PRNNew.checked = false; }
		if(o_PRNDefault){o_PRNDefault.checked = true; g_CurrentPersonalisationUpsellId = o_PRNDefault.id;}
		if (o_PRNDefault) { document.forms[0].prnOption.value = o_PRNDefault.id; } else { document.forms[0].prnOption.value = "" }
	}
}

function NetFloristGenericPopup(NFUrlPopup,NFWindowNamePopup) {
  msgWindow=window.open(NFUrlPopup,NFWindowNamePopup,'toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 0,resizable= 1,copyhistory= 0,width=250,height=250');
  msgWindow.focus();
}
function RA191() {
  msgWindow=window.open('http://ww1.netflorist.co.za/nf_info_product_ra191.asp' ,'ProductInfoWindow','toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 0,resizable=0,copyhistory= 0,width=460,height=391');
  msgWindow.focus();
}
function RA192() {
  msgWindow=window.open('http://ww1.netflorist.co.za/nf_info_product_ra192.asp' ,'ProductInfoWindow','toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 1,resizable= 0,copyhistory= 0,width=460,height=391');
  msgWindow.focus();
}
function RA194() {
  msgWindow=window.open('http://ww1.netflorist.co.za/nf_info_product_ra194.asp' ,'ProductInfoWindow','toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 1,resizable= 0,copyhistory= 0,width=460,height=391');
  msgWindow.focus();
}
function RA195() {
  msgWindow=window.open('http://ww1.netflorist.co.za/nf_info_product_ra195.asp' ,'ProductInfoWindow','toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 1,resizable= 0,copyhistory= 0,width=460,height=391');
  msgWindow.focus();
}
function RA196() {
  msgWindow=window.open('http://ww1.netflorist.co.za/nf_info_product_ra196.asp' ,'ProductInfoWindow','toolbar= 0,location= 0,directories= 0,status= 0,menubar= 0,scrollbars= 1,resizable= 0,copyhistory= 0,width=460,height=391');
  msgWindow.focus();
}

/* Pankaj 2011-11-07 14.31  Following functions are added to implement Show/Hide functionality on Product Details Page*/
/* Code Starts*/
function ShowLongDesc() {
    var eleToShow = document.getElementById('LongDesc');
    var eleToHide = document.getElementById('Desc');

    if (!document.getElementById)
        return
    if (eleToShow.style.display == "none") {

        eleToShow.style.display = "inline"
        eleToHide.style.display = "none"
    }
    else {
        eleToShow.style.display = "none"
        eleToHide.style.display = "inline"
    }

}
function HideLongDesc() {
    var eleToShow = document.getElementById('Desc');
    var eleToHide = document.getElementById('LongDesc');

    if (!document.getElementById)
        return
    if (eleToShow.style.display == "inline") {

        eleToShow.style.display = "none"
        eleToHide.style.display = "inline"
    }
    else {
        eleToShow.style.display = "inline"
        eleToHide.style.display = "none"
    }
    /* Code Ends*/
}
