﻿function InitDropDown(sender,args)
{
    sender.behavior.set_zIndex(200000);
}
function SetYear(p_Stage, p_VintageId)
{
    document.getElementById("Body_hid_PostBackType").value = "year;" + p_Stage + ";" + p_VintageId;
    document.getElementById("Body_btn_Click").click();
}
function SetStage (p_Stage)
{
    document.getElementById("Body_hid_PostBackType").value = "stage;" + p_Stage;
    document.getElementById("Body_btn_Click").click();
}
function HideUnhideDna()
{
    if(document.getElementById("ViewMore").style.display == "none")
    {
        document.getElementById("ViewMore").style.display = "block"
        document.getElementById("Body_WineDna_lbl_HideUnHide").innerHTML = document.getElementById("Body_WineDna_lbl_LessDetails").innerHTML
    }
    else
    {
        document.getElementById("ViewMore").style.display = "none"
        document.getElementById("Body_WineDna_lbl_HideUnHide").innerHTML = document.getElementById("Body_WineDna_lbl_MoreDetails").innerHTML
    }
}
function OpenClosePanel (p_PanelId, p_ImageId)
{
    var Image = document.getElementById(p_ImageId);
    var LastIndex = Image.src.lastIndexOf('/'); 
    var Url = Image.src.substring(0, LastIndex);
    
   if(document.getElementById(p_PanelId).style.display == "none")
   {
        document.getElementById(p_PanelId).style.display = "block"
        Image.src = Url + "/Arrow_ClosePanel.png";
   }
   else
   {
        document.getElementById(p_PanelId).style.display = "none"
        Image.src = Url + "/Arrow_OpenPanel.png";
   }
}
function ShowExtended()
{
    document.getElementById("Col_Left").className = "TextbarLeftExt";
    document.getElementById("Col_Middle").className = "TextsearchbarMiddleExt";
    document.getElementById("Col_Right").className = "TextbarRightExt";
    document.getElementById("Aro_Left").className = "TextbarLeftExt";
    document.getElementById("Aro_Middle").className = "TextsearchbarMiddleExt";
    document.getElementById("Aro_Right").className = "TextbarRightExt";
    document.getElementById("Tas_Left").className = "TextbarLeftExt";
    document.getElementById("Tas_Middle").className = "TextsearchbarMiddleExt";
    document.getElementById("Tas_Right").className = "TextbarRightExt";
    document.getElementById("Gen_Left").className = "TextbarLeftExt";
    document.getElementById("Gen_Middle").className = "TextsearchbarMiddleExt";
    document.getElementById("Gen_Right").className = "TextbarRightExt";
    
    //Show the extended panels
    var Color = document.getElementById("ColourExtended").style;
    var Smell = document.getElementById("AromaExtended").style;
    var Taste = document.getElementById("TasteExtended").style;
    var Total = document.getElementById("TotalExtended").style;
    var ExtendedLink = document.getElementById("Body_lbl_ExtendedNote").style;
    var shortLink = document.getElementById("Body_lbl_ShortNote").style;
    var ScoreType = document.getElementById("Body_hid_ScoreType");
    
    //Set scoreType=1 ; means extended
    ScoreType.value = "1";
    
    //Rating controls
    var RatingColor = document.getElementById("Body_rat_ColourSimple").RatingBehavior;
    var RatingSmell = document.getElementById("Body_rat_AromaSimple").RatingBehavior;
    var RatingTaste = document.getElementById("Body_rat_TasteSimple").RatingBehavior;
    var RatingTotal = document.getElementById("Body_rat_GenImpressionSimple").RatingBehavior;
    
    Color.display = "block";
    Smell.display = "block";
    Taste.display = "block";
    Total.display = "block";

    ExtendedLink.display = "none";
    shortLink.display = "block";    

    //Put simple rating controls on readonly
    RatingColor._readOnly = true;
    RatingSmell._readOnly = true;
    RatingTaste._readOnly = true;
    RatingTotal._readOnly = true;
    }
function ShowShort()
{
    document.getElementById("Col_Left").className = "TextbarLeft";
    document.getElementById("Col_Middle").className = "TextsearchbarMiddle";
    document.getElementById("Col_Right").className = "TextbarRight";
    document.getElementById("Aro_Left").className = "TextbarLeft";
    document.getElementById("Aro_Middle").className = "TextsearchbarMiddle";
    document.getElementById("Aro_Right").className = "TextbarRight";
    document.getElementById("Tas_Left").className = "TextbarLeft";
    document.getElementById("Tas_Middle").className = "TextsearchbarMiddle";
    document.getElementById("Tas_Right").className = "TextbarRight";
    document.getElementById("Gen_Left").className = "TextbarLeft";
    document.getElementById("Gen_Middle").className = "TextsearchbarMiddle";
    document.getElementById("Gen_Right").className = "TextbarRight";
    
    //Hide the extended panels
    var Color = document.getElementById("ColourExtended").style;
    var Smell = document.getElementById("AromaExtended").style;
    var Taste = document.getElementById("TasteExtended").style;
    var Total = document.getElementById("TotalExtended").style;
    var ExtendedLink = document.getElementById("Body_lbl_ExtendedNote").style;
    var shortLink = document.getElementById("Body_lbl_ShortNote").style;
    var ScoreType = document.getElementById("Body_hid_ScoreType");
    
    //Set scoreType=9 ; means short
    ScoreType.value = "0";
    
    //Rating controls
    var RatingColor = document.getElementById("Body_rat_ColourSimple").RatingBehavior;
    var RatingSmell = document.getElementById("Body_rat_AromaSimple").RatingBehavior;
    var RatingTaste = document.getElementById("Body_rat_TasteSimple").RatingBehavior;
    var RatingTotal = document.getElementById("Body_rat_GenImpressionSimple").RatingBehavior;
    
    Color.display = "none";
    Smell.display = "none";
    Taste.display = "none";
    Total.display = "none";
    
    ExtendedLink.display = "block";
    shortLink.display = "none";
    
    //Put simple rating controls on editable
    RatingColor._readOnly = false;
    RatingSmell._readOnly = false;
    RatingTaste._readOnly = false;
    RatingTotal._readOnly = false;
}
function AddItem(p_TagName, p_TagId, p_PanelId, p_TagType)
{
  var l_Cont = true;
  var l_Panel = document.getElementById(p_PanelId);
  
    if(document.all) //IE
    {
    for (var x = l_Panel.firstChild ; x!= null && l_Cont; x = x.nextSibling)
        if(x.style.display == "none")
            {
                //Stop the loop
                l_Cont = false;
                //Display the block
                x.style.display = "block";
                
                //Set the tagname
                var l_Nameblock = x.firstChild;
                l_Nameblock.innerHTML = p_TagName;
                
                //Set the Id
                var l_IdBlock = l_Nameblock.nextSibling;
                l_IdBlock.innerHTML = p_TagId;
            }
       else
            {
                var l_Nameblock = x.firstChild;   
                if(l_Nameblock.innerHTML == p_TagName)
                    l_Cont = false;
            }
    }
    else   //Other
    {
        for (var x = l_Panel.firstElementChild ; x!= null && l_Cont; x = x.nextElementSibling)
        if(x.style.display == "none")
            {
                //Stop the loop
                l_Cont = false;
                
                //Display the block
                x.style.display = "block";
                
                //Set the tagname
                var l_Nameblock = x.firstElementChild;
                l_Nameblock.innerHTML = p_TagName;
                
                //Set the Id
                var l_IdBlock = l_Nameblock.nextElementSibling;
                l_IdBlock.innerHTML = p_TagId;
            }    
        else
            {
                var l_Nameblock = x.firstElementChild;   
                if(l_Nameblock.innerHTML == p_TagName)
                    l_Cont = false;
            }
    }
    
    SetHiddenField(p_PanelId, p_TagType);
     
}
function SetHiddenField(p_PanelId, p_TagType)
{
    var l_Tags = "";
    var l_HiddenTagField;
    var l_Panel = document.getElementById(p_PanelId);
    
    switch (p_TagType)
    {
        case 0:
            l_HiddenTagField = document.getElementById("Body_hid_Color");
            break;
            
        case 1:
            l_HiddenTagField = document.getElementById("Body_hid_Aroma");
            break;
            
        case 2:
            l_HiddenTagField = document.getElementById("Body_hid_Taste");
           break;
    }
   
    if(document.all) //IE
    {
    for (var x = l_Panel.firstChild ; x!= null; x = x.nextSibling)
        if(x.style.display != "none")
            {
                var l_Nameblock = x.firstChild;
                var l_IdBlock = l_Nameblock.nextSibling;
                l_Tags += l_IdBlock.innerHTML + ",";
            }
    }
    else   //Other
    {
        for (var x = l_Panel.firstElementChild ; x!= null; x = x.nextElementSibling)
        if(x.style.display != "none")
            {
                var l_Nameblock = x.firstElementChild;
                var l_IdBlock = l_Nameblock.nextElementSibling;
                l_Tags += l_IdBlock.innerHTML + ",";
            } 
    }
    l_HiddenTagField.value = l_Tags;
}
function RemoveItem (p_TagNo, p_PanelId, p_TagType)
{
  var l_Cont = true;
  var l_Counter = 1;
  var l_Panel = document.getElementById(p_PanelId);
  
    if(document.all) //IE
    {
    for (var x = l_Panel.firstChild ; x!= null && l_Cont; x = x.nextSibling)
        if(l_Counter == p_TagNo)
            {
                //Stop the loop
                l_Cont = false;
                //Display the block
                x.style.display = "none";
                
                //Empty the tagname
                var l_Nameblock = x.firstChild;
                l_Nameblock.innerHTML = "";
                
                //Empty the Id
                var l_IdBlock = l_Nameblock.nextSibling;
                l_IdBlock.innerHTML = "";
            }
        else
            //Raise the counter
            l_Counter++;
    }
    else   //Other
    {
        for (var x = l_Panel.firstElementChild ; x!= null && l_Cont; x = x.nextElementSibling)
        if (l_Counter == p_TagNo)
            {
                //Stop the loop
                l_Cont = false;
                
                //Display the block
                x.style.display = "none";
                
                //Empty the tagname
                var l_Nameblock = x.firstElementChild;
                l_Nameblock.innerHTML = "";
                
                //Empty the Id
                var l_IdBlock = l_Nameblock.nextElementSibling;
                l_IdBlock.innerHTML = "";
            }    
        else
            //Raise the counter
            l_Counter++;

    }
    SetHiddenField(p_PanelId, p_TagType);    
}
function TagAromaShowPopup()
{
    document.getElementById("Body_Aroma_btn_ShowAromaPopup").click();
}
function TagsAromaYes()
{
    document.getElementById("Body_Aroma_btn_AromaYes").click();
}
function TagsAromaCancel()
{
    document.getElementById("Body_Aroma_btn_CancelAromaPopup").click();
}
function CopyToFormAroma()
{
    var l_CopyTo = document.getElementById("Body_Aroma_lbl_Tag_CopyTo").innerHTML;
    var l_TagField = document.getElementById("Body_lbl_AromaKeyWords");
   
    l_TagField.innerHTML = "";
    if(document.getElementById("Body_Aroma_lbl_Keyword1").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Aroma_lbl_Keyword1").innerHTML + "<br>";
    if(document.getElementById("Body_Aroma_lbl_Keyword2").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Aroma_lbl_Keyword2").innerHTML + "<br>";
    if(document.getElementById("Body_Aroma_lbl_Keyword3").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Aroma_lbl_Keyword3").innerHTML + "<br>";
    if(document.getElementById("Body_Aroma_lbl_Keyword4").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Aroma_lbl_Keyword4").innerHTML + "<br>";
    if(document.getElementById("Body_Aroma_lbl_Keyword5").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Aroma_lbl_Keyword5").innerHTML;
}  


function TagColourShowPopup()
{
    document.getElementById("Body_Colour_btn_ShowColourPopup").click();
}
function TagsColourYes()
{
    document.getElementById("Body_Colour_btn_ColourYes").click();
}
function TagsColourCancel()
{
    document.getElementById("Body_Colour_btn_CancelColourPopup").click();
}
function CopyToFormColour()
{
    var l_CopyTo = document.getElementById("Body_Colour_lbl_Tag_CopyTo").innerHTML;
    var l_TagField = document.getElementById("Body_lbl_ColourKeyWords");
   
    l_TagField.innerHTML = "";
    if(document.getElementById("Body_Colour_lbl_Keyword1").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Colour_lbl_Keyword1").innerHTML + "<br>";
    if(document.getElementById("Body_Colour_lbl_Keyword2").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Colour_lbl_Keyword2").innerHTML + "<br>";
    if(document.getElementById("Body_Colour_lbl_Keyword3").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Colour_lbl_Keyword3").innerHTML + "<br>";
    if(document.getElementById("Body_Colour_lbl_Keyword4").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Colour_lbl_Keyword4").innerHTML + "<br>";
    if(document.getElementById("Body_Colour_lbl_Keyword5").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Colour_lbl_Keyword5").innerHTML;
}  


function TagTasteShowPopup()
{
    document.getElementById("Body_Taste_btn_ShowTastePopup").click();
}
function TagsTasteYes()
{
    document.getElementById("Body_Taste_btn_TasteYes").click();
}
function TagsTasteCancel()
{
    document.getElementById("Body_Taste_btn_CancelTastePopup").click();
}
function CopyToFormTaste()
{
    var l_CopyTo = document.getElementById("Body_Taste_lbl_Tag_CopyTo").innerHTML;
    var l_TagField = document.getElementById("Body_lbl_TasteKeyWords");
   
    l_TagField.innerHTML = "";
    if(document.getElementById("Body_Taste_lbl_Keyword1").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Taste_lbl_Keyword1").innerHTML + "<br>";
    if(document.getElementById("Body_Taste_lbl_Keyword2").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Taste_lbl_Keyword2").innerHTML + "<br>";
    if(document.getElementById("Body_Taste_lbl_Keyword3").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Taste_lbl_Keyword3").innerHTML + "<br>";
    if(document.getElementById("Body_Taste_lbl_Keyword4").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Taste_lbl_Keyword4").innerHTML + "<br>";
    if(document.getElementById("Body_Taste_lbl_Keyword5").innerHTML != "")
        l_TagField.innerHTML += document.getElementById("Body_Taste_lbl_Keyword5").innerHTML;
}  

function VintageShowPopup()
{
    document.getElementById("Body_AddVintage_btn_ShowVintagePopup").click();
    document.getElementById("Body_AddVintage_txt_year").focus();
}
function VintageYes()
{
    document.getElementById("Body_AddVintage_btn_VintageYes").click();
    document.getElementById("Body_hid_Vintage").value = document.getElementById("Body_AddVintage_txt_year").value;
}
function VintageCancel()
{
    document.getElementById("Body_AddVintage_btn_CancelVintagePopup").click();
}
function SubmitVintage()
{
    document.getElementById("Body_btn_SubmitVintage").click();
}
function SubmitNote()
{
    document.getElementById("WhichControl").value = "SubmitTastingNote";
    document.forms[0].submit();
}
function AddToWineCellarShowPopup (p_WineId, p_Vintage)
{
    document.getElementById('Body_hid_WineId').value = p_WineId;
    
    document.getElementById('Body_AddToWineCellar_btn_ShowPopup').click();
    document.getElementById('Body_AddToWineCellar_txt_year').value = document.getElementById('Body_WineDna_hid_ActiveYear').value;
    
    if(p_Vintage == "true")
        document.getElementById('Body_AddToWineCellar_txt_year').focus();
    else    
    {
        document.getElementById("Vintage").style.display = "none";
         document.getElementById('Body_AddToWineCellar_txt_NoOfbottles').focus();
    }
}
function AddToWineCellarSubmit()
{
    document.getElementById('Body_btn_SubmitWineCellar').click();
}
function WishListNonVintageAddedShowPopup(p_WineId)
{
  
    document.getElementById('Body_FavWishVintage_txt_year').value = "";
    document.getElementById('Body_hid_WineId').value = "0;" + p_WineId;
    document.getElementById('Body_btn_SubmitFavourite').click();
}
function WishListVintageAddedShowPopup(p_WineId)
{
  
    document.getElementById('Body_hid_WineId').value = "0;" + p_WineId;
    document.getElementById('Body_FavWishVintage_txt_year').value = document.getElementById('Body_WineDna_hid_ActiveYear').value;
    document.getElementById('Body_FavWishVintage_btn_ShowPopup').click();
    document.getElementById('Body_FavWishVintage_txt_year').focus();
}
function FavouriteVintageAddedShowPopup(p_WineId)
{

    document.getElementById('Body_hid_WineId').value = "1;" + p_WineId;
    document.getElementById('Body_FavWishVintage_txt_year').value = document.getElementById('Body_WineDna_hid_ActiveYear').value;  
    document.getElementById('Body_FavWishVintage_btn_ShowPopup').click();
    document.getElementById('Body_FavWishVintage_txt_year').focus();   
}
function FavouriteNonVintageAddedShowPopup(p_WineId)
{

    document.getElementById('Body_FavWishVintage_txt_year').value = "";
    document.getElementById('Body_hid_WineId').value = "1;" + p_WineId;
    document.getElementById('Body_btn_SubmitFavourite').click();
}
function AddFavWish()
{
    document.getElementById('Body_btn_SubmitFavourite').click();
}
function NotLoggedIn()
{
    __doPostBack('NotLoggedIn',"");
}
