﻿
function TrimAll(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
    sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
    sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function ClearSearchInputText()
{   
    if(document.getElementById('txtSearchInput') != null && TrimAll(document.getElementById('txtSearchInput').value) =='Search the site')
    {
        //document.getElementById('txtSearchInput').value = "";
        document.getElementById('txtSearchInput').select();
        return;
    } 
}

function RetainSearchInputText()
{
    if(document.getElementById('txtSearchInput') != null && TrimAll(document.getElementById('txtSearchInput').value) == '')
    {
        document.getElementById('txtSearchInput').value = 'Search the site';
        return;
    } 
}

function keyPressEnterInp(evt)
{       
    var charCode = (evt.which) ? evt.which : event.keyCode    
    if (charCode == 13)
    {
       GoFunctionality('testinput');       
       return false;
    }
}


function GoFunction(strSearch)
{   
    strSearch = document.getElementById("txtSearch").value;   
    //  document.getElementById("lblUserMsg1").style.display="none";
    if((document.getElementById("txtSearch").value =="") || (document.getElementById("txtSearch").value =="Search the site"))
     {  
		document.getElementById("lblSearchMsg").style.display="inline";
        document.getElementById("txtSearch").focus();
        return false;
     }
     else
     {
       document.getElementById("lblSearchMsg").style.display="none";             
       
       win=window.open("Common/SearchPage.aspx?strSearch="+strSearch+"",'win','toolbars=no,scrollbars=yes,resizable=no,width=650,height=600');
       popWidth=650;
       popHeight=600;
       screenW = screen.width;
       screenH = screen.height;
       xPos= ((screenW - (popWidth+4))/2);
       yPos= ((screenH - (popHeight+20))/2);
       win.moveTo(xPos,yPos);
       return false;
    }
}

function GoFunctionality()
{   
    if((document.getElementById("txtSearchInput").value =="") || (document.getElementById("txtSearchInput").value =="Search the site"))
     {  
		document.getElementById("lblSearchMsg").style.display="inline";
        document.getElementById("txtSearchInput").focus();
        return false;
     } 
   else 
   {
        var strSearch = document.getElementById('txtSearchInput').value;
        document.getElementById("lblSearchMsg").style.display="none";
        if(strSearch != "" && strSearch != 'Search the site')
        {
            win=window.open("../Common/SearchPage.aspx?strSearch="+strSearch,"win","toolbars=no,scrollbars=yes,resizable=no,width=650,height=600,top=" + ((screen.height - (600+20))/2) + ",left=" + ((screen.width - (650+4))/2));
        }
        else
        {
            return false;
        }
   }   
   return true;
}


function roundNumber(rnum, rlength) 
{ 
    return Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}

function enableOrDisableSubproductCheckbox(selectedcheckbox,prodid)
{
    document.getElementById('lblErrorMessage').style.display = "none";
    if(selectedcheckbox.id.split("_").length == 5)
    {
        if(!selectedcheckbox.checked)
        {
            var subgrid = document.getElementById(selectedcheckbox.id.replace("chkProduct","gvwSubProducts"));
            
            if(subgrid != null && subgrid.rows.length > 0)
            {
                var rowCount;
                for (i=2; i<=subgrid.rows.length+1; i++)
                {
                    if(i <=9)
                        rowCount = "0"+i;
                    else
                        rowCount = i;
                        
                    if(document.getElementById(subgrid.id + "_ctl" + rowCount + "_chkSubProduct").checked)
                    {
                        //It is not possible to order a subproduct without ordering the associated product 
                        document.getElementById('lblErrorMessage').innerHTML = "It is not possible to order a subproduct without ordering the associated product";
                        document.getElementById('lblErrorMessage').style.display = "inline";
                        selectedcheckbox.checked = true;
                        return false;
                    } 
                    
                }     
            }
            else 
            {
                if(document.getElementById("hdnProdIds").value.indexOf("@" + prodid + "@") != -1)
                {
                    document.getElementById('lblErrorMessage').innerHTML = "It is not possible to order a subproduct without ordering the associated product";
                    document.getElementById('lblErrorMessage').style.display = "inline";
                    selectedcheckbox.checked = true;
                    return false;
                }
            }
        }
    }
    else
    {
        if(selectedcheckbox.checked)
        {
            var str = selectedcheckbox.id.split("_");
            var parentcheckbox = str[0] + "_" + str[1] + "_" + str[2] + "_" + str[3] + "_chkProduct" ;
            if(!document.getElementById(parentcheckbox).checked)
            {
                document.getElementById('lblErrorMessage').innerHTML = "It is not possible to order a subproduct without ordering the associated product";
                document.getElementById('lblErrorMessage').style.display = "inline";
                selectedcheckbox.checked = false;
                return false;
            }
        }
    }
    
    return true;
}

function calcPrice(ctlCheckbox,exvat,vat,pslink,prodid)
{
    if(!enableOrDisableSubproductCheckbox(ctlCheckbox,prodid))
    {
        return;
    }
    document.getElementById('hdnCategoryProductClicked').value = "1";
    
    if(ctlCheckbox.checked)
    {
        document.getElementById('hdnPslinks').value = document.getElementById('hdnPslinks').value + "@" + pslink + "@";
    }
    else 
    {
        if(document.getElementById('hdnPslinks').value.length > 0)
            document.getElementById('hdnPslinks').value = document.getElementById('hdnPslinks').value.replace("@" + pslink + "@","") 
    } 
    //alert(document.getElementById('hdnCountSuppliers').value);
    if(!isNaN(exvat))
    {
          if(ctlCheckbox.checked)
          {
                document.getElementById('hdnExVAT').value = parseFloat(document.getElementById('hdnExVAT').value) +  parseFloat(exvat);
                document.getElementById('hdnVAT').value = parseFloat(document.getElementById('hdnVAT').value) +  parseFloat(vat);
          }
          else 
          {
                document.getElementById('hdnExVAT').value = parseFloat(document.getElementById('hdnExVAT').value) -  parseFloat(exvat);
                document.getElementById('hdnVAT').value = parseFloat(document.getElementById('hdnVAT').value) -  parseFloat(vat);
          }  
          if(parseInt(document.getElementById('hdnNoofPOAs').value) < 1)
          {
              //document.getElementById('lblExVatT').innerText = roundNumber(document.getElementById('hdnExVAT').value,2);
              //document.getElementById('lblVatT').innerText = roundNumber(document.getElementById('hdnVAT').value,2);
              //document.getElementById('lblIncVatT').innerText =roundNumber(parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText),2); 
              
              document.getElementById('lblExVatT').innerText = parseFloat(document.getElementById('hdnExVAT').value).toFixed(2);
              document.getElementById('lblVatT').innerText = parseFloat(document.getElementById('hdnVAT').value).toFixed(2);
              document.getElementById('lblIncVatT').innerText = (parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText)).toFixed(2);
          } 
          
    } 
    else 
    {
        if(ctlCheckbox.checked)
        {
            document.getElementById('lblExVatT').innerText = "POA";
            document.getElementById('lblVatT').innerText = "POA";
            document.getElementById('lblIncVatT').innerText = "POA";
            document.getElementById('hdnNoofPOAs').value = parseInt(document.getElementById('hdnNoofPOAs').value) + 1;
            
           
        }
        else 
        {
            document.getElementById('hdnNoofPOAs').value = parseInt(document.getElementById('hdnNoofPOAs').value) - 1;
            if(parseInt(document.getElementById('hdnNoofPOAs').value) < 1)
            {
                //document.getElementById('lblExVatT').innerText = roundNumber(document.getElementById('hdnExVAT').value,2);
                //document.getElementById('lblVatT').innerText = roundNumber(document.getElementById('hdnVAT').value,2);
                //document.getElementById('lblIncVatT').innerText = roundNumber(parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText),2); 
                
                document.getElementById('lblExVatT').innerText = parseFloat(document.getElementById('hdnExVAT').value).toFixed(2);
                document.getElementById('lblVatT').innerText = parseFloat(document.getElementById('hdnVAT').value).toFixed(2);
                document.getElementById('lblIncVatT').innerText = (parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText)).toFixed(2);
               
            } 
        }
        
    }
    //alert(document.getElementById('hdnNoofPOAs').value);
}

function calcBundlePrice(ctlCheckbox,exvat,vat,bundleid)
{
    document.getElementById('hdnBundleClicked').value = "1";
    if(ctlCheckbox.checked)
    {
        document.getElementById('hdnBundleIds').value = document.getElementById('hdnBundleIds').value + "@" + bundleid + "@";
        var subgrid = document.getElementById(ctlCheckbox.id.replace("chkBundleProduct","gvwBundleProducts"));
        if(subgrid != null && subgrid.rows.length > 0)
        {
            var rowCount;
            var prodsuplinkid;
            var tmpbundleId = bundleid + ":";
            var gridlength = subgrid.rows.length+1;
            for (i=2; i<=gridlength; i++)
            {
                if(i <=9)
                    rowCount = "0"+i;
                else
                    rowCount = i;
                prodsuplinkid = document.getElementById(subgrid.id + "_ctl" + rowCount + "_btnProdSupLinkId").value;
                if( i < gridlength)
                    tmpbundleId = tmpbundleId + prodsuplinkid + ",";
                else 
                     tmpbundleId = tmpbundleId + prodsuplinkid;
            }
            document.getElementById('hdnBundleProdSuppLinkIds').value = document.getElementById('hdnBundleProdSuppLinkIds').value + "@" + tmpbundleId + "@";
        }
    }
    else 
    {
        if(document.getElementById('hdnBundleIds').value.length > 0)
            document.getElementById('hdnBundleIds').value = document.getElementById('hdnBundleIds').value.replace("@" + bundleid + "@","") 
    } 
    if(!isNaN(exvat))
    {
          if(ctlCheckbox.checked)
          {
                document.getElementById('hdnExVAT').value = parseFloat(document.getElementById('hdnExVAT').value) +  parseFloat(exvat);
                document.getElementById('hdnVAT').value = parseFloat(document.getElementById('hdnVAT').value) +  parseFloat(vat);
          }
          else 
          {
                document.getElementById('hdnExVAT').value = parseFloat(document.getElementById('hdnExVAT').value) -  parseFloat(exvat);
                document.getElementById('hdnVAT').value = parseFloat(document.getElementById('hdnVAT').value) -  parseFloat(vat);
          }  
          if(parseInt(document.getElementById('hdnNoofPOAs').value) < 1)
          {
              //document.getElementById('lblExVatT').innerText = roundNumber(document.getElementById('hdnExVAT').value,2);
              //document.getElementById('lblVatT').innerText = roundNumber(document.getElementById('hdnVAT').value,2);
              //document.getElementById('lblIncVatT').innerText =roundNumber(parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText),2); 
              
              document.getElementById('lblExVatT').innerText = parseFloat(document.getElementById('hdnExVAT').value).toFixed(2);
              document.getElementById('lblVatT').innerText = parseFloat(document.getElementById('hdnVAT').value).toFixed(2);
              document.getElementById('lblIncVatT').innerText = (parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText)).toFixed(2);
             
          } 
          
    } 
    else 
    {
        if(ctlCheckbox.checked)
        {
            document.getElementById('lblExVatT').innerText = "POA";
            document.getElementById('lblVatT').innerText = "POA";
            document.getElementById('lblIncVatT').innerText = "POA";
            
            document.getElementById('hdnNoofPOAs').value = parseInt(document.getElementById('hdnNoofPOAs').value) + 1;
            
          
        }
        else 
        {
            document.getElementById('hdnNoofPOAs').value = parseInt(document.getElementById('hdnNoofPOAs').value) - 1;
            if(parseInt(document.getElementById('hdnNoofPOAs').value) < 1)
            {
                //document.getElementById('lblExVatT').innerText = roundNumber(document.getElementById('hdnExVAT').value,2);
                //document.getElementById('lblVatT').innerText = roundNumber(document.getElementById('hdnVAT').value,2);
                //document.getElementById('lblIncVatT').innerText = roundNumber(parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText),2); 
                
                document.getElementById('lblExVatT').innerText = parseFloat(document.getElementById('hdnExVAT').value).toFixed(2);
                document.getElementById('lblVatT').innerText = parseFloat(document.getElementById('hdnVAT').value).toFixed(2);
                document.getElementById('lblIncVatT').innerText = (parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText)).toFixed(2);
              
            } 
        }
        
    }
}

function changePrice(newexvat,oldexvat,newvat,oldvat,oldpslink,newpslink)
{
    if(document.getElementById('hdnPslinks').value.length > 0)
       document.getElementById('hdnPslinks').value = document.getElementById('hdnPslinks').value.replace("@" + oldpslink + "@","")
   
    document.getElementById('hdnPslinks').value = document.getElementById('hdnPslinks').value + "@" + newpslink + "@"; 

    if(!isNaN(newexvat) && !isNaN(oldexvat))
    {
       document.getElementById('hdnExVAT').value = parseFloat(document.getElementById('hdnExVAT').value) +  parseFloat(newexvat) - parseFloat(oldexvat);
       document.getElementById('hdnVAT').value = parseFloat(document.getElementById('hdnVAT').value) +  parseFloat(newvat) - parseFloat(oldvat);
       if(parseInt(document.getElementById('hdnNoofPOAs').value) < 1)
       {
          //document.getElementById('lblExVatT').innerText = roundNumber(document.getElementById('hdnExVAT').value,2);
          //document.getElementById('lblVatT').innerText = roundNumber(document.getElementById('hdnVAT').value,2);
          //document.getElementById('lblIncVatT').innerText =roundNumber(parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText),2); 
          
          document.getElementById('lblExVatT').innerText = parseFloat(document.getElementById('hdnExVAT').value).toFixed(2);
          document.getElementById('lblVatT').innerText = parseFloat(document.getElementById('hdnVAT').value).toFixed(2);
          document.getElementById('lblIncVatT').innerText = (parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText)).toFixed(2);
          
       } 
    }
    else if(!isNaN(newexvat))
    {
       document.getElementById('hdnExVAT').value = parseFloat(document.getElementById('hdnExVAT').value) +  parseFloat(newexvat);
       document.getElementById('hdnVAT').value = parseFloat(document.getElementById('hdnVAT').value) +  parseFloat(newvat);
       
       document.getElementById('hdnNoofPOAs').value = parseInt(document.getElementById('hdnNoofPOAs').value) - 1;
       
       if(parseInt(document.getElementById('hdnNoofPOAs').value) < 1)
       {
          //document.getElementById('lblExVatT').innerText = roundNumber(document.getElementById('hdnExVAT').value,2);
          //document.getElementById('lblVatT').innerText = roundNumber(document.getElementById('hdnVAT').value,2);
          //document.getElementById('lblIncVatT').innerText =roundNumber(parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText),2); 
        
          document.getElementById('lblExVatT').innerText = parseFloat(document.getElementById('hdnExVAT').value).toFixed(2);
          document.getElementById('lblVatT').innerText = parseFloat(document.getElementById('hdnVAT').value).toFixed(2);
          document.getElementById('lblIncVatT').innerText = (parseFloat(document.getElementById('lblExVatT').innerText) + parseFloat(document.getElementById('lblVatT').innerText)).toFixed(2);  
        
       } 
    }
    else if(!isNaN(oldexvat))
    {
        document.getElementById('hdnNoofPOAs').value = parseInt(document.getElementById('hdnNoofPOAs').value) + 1;
        
        document.getElementById('hdnExVAT').value = parseFloat(document.getElementById('hdnExVAT').value) -  parseFloat(oldexvat);
        document.getElementById('hdnVAT').value = parseFloat(document.getElementById('hdnVAT').value) -  parseFloat(oldvat);
        
        document.getElementById('lblExVatT').innerText = "POA";
        document.getElementById('lblVatT').innerText = "POA";
        document.getElementById('lblIncVatT').innerText = "POA";
      
    
    
    }
}

function openDescription(prodId)
{
    window.open("ProductDescription.aspx?prodid="+ prodId ,"prodId","toolbars=yes,scrollbars=yes,resizable=no,width=446,height=350,top=" + ((screen.height - 370)/2) + ",left=" + ((screen.width - 450)/2)); 
}

function startMouse()
{
    document.getElementById('hdnMouseClicked').value = "1";
}

function stopMouse()
{
    document.getElementById('hdnMouseClicked').value = "0";
}

function SetProgressPosition(e) 
{
    if(document.getElementById('hdnMouseClicked').value == "1")
    {
        var posx = 0;
        var posy = 0;
        if (!e) var e = window.event;
        if (e.pageX || e.pageY) {
            posx = e.pageX;
            posy = e.pageY;
        }
        else if (e.clientX || e.clientY) {
            posx = e.clientX + document.documentElement.scrollLeft;
            posy = e.clientY + document.documentElement.scrollTop;
        }
        document.getElementById('divProgress').style.left = posx - 8 + "px";
        document.getElementById('divProgress').style.top = posy - 8 + "px";
    }
}

function productsValidation(msgprod,msgsup)
{
    document.getElementById('lblErrorMessage').innerText = "";
    if(document.getElementById('hdnPslinks').value.length == 0 && document.getElementById('hdnBundleIds').value.length == 0)
    {
        document.getElementById('lblErrorMessage').innerText = msgprod;
        alert(msgprod);
        return false;
    }
    else 
    {
        var nonsupp = document.getElementById('hdnPslinks').value.indexOf('-');
        if(nonsupp == -1)
        {
            return true;
        }
        else
        {
            document.getElementById('lblErrorMessage').innerText = msgsup;
            alert(msgsup); 
            return false;
        }
    }   
}

function PostCodeValidation()
{ 
    
    var str = TrimAll(document.getElementById("txtPostCode").value);
    if(str.length == 0)
    {
        document.getElementById("lblPostcode").innerText="Please enter a postcode";
	    document.getElementById("lblPostcode").style.display="inline";
	    document.getElementById("txtPostCode").focus();
	    return false
    }
    else 
    {
        var regexpnumber = /^([A-Z]|[a-z])([0-9]|[0-9]{2}|([A-Z]|[a-z])[0-9]|([A-Z]|[a-z])[0-9]{2}|[0-9]([A-Z]|[a-z])|([A-Z]|[a-z])[0-9]([A-Z]|[a-z]))( [0-9]([A-Z]|[a-z])([A-Z]|[a-z]))$/; 
        if(document.getElementById("txtPostCode").value.search(regexpnumber) == -1)
        {
            document.getElementById("lblPostcode").innerText="The postcode was not recognised, please try again";
	        document.getElementById("lblPostcode").style.display="inline";
	        document.getElementById("txtPostCode").focus();
	        return false;
	    }
	    else
	    {
	         document.getElementById("lblPostcode").style.display="none";
	         //document.getElementById('lblProcessing').innerText = "Processing..."; 
	         return true;
	    }
    } 
    	   
}
    
 ////Used for Price Guide guest page log-in button validations.
function validateLoginPG()
{
    document.getElementById("divProgress").style.display="none";
    var userpwd="Please enter your User Name and Password";
    var user="Please enter your User Name";
    var password="Please enter your password";
    document.getElementById("lblSearchMsg").style.display="none";
    if((document.getElementById("txtUser").value =="User Name") && (document.getElementById("txtPassword").value==""))
    {       
        document.getElementById("lblUserMsg1").innerText=userpwd;
		document.getElementById("lblUserMsg1").style.display="inline";
		document.getElementById("txtUser").focus();
		return false;
		
	}	
	

	else if(document.getElementById("txtUser").value !="" && document.getElementById("txtPassword").value =="")
	{
	    document.getElementById("lblUserMsg1").innerText=password;
		document.getElementById("lblUserMsg1").style.display="inline";
		document.getElementById("txtPasswordText").focus();
		return false;
	}
    
    else if(document.getElementById("txtUser").value =="" || document.getElementById("txtUser").value == "User Name"  && document.getElementById("txtPassword").value!="" )
    {    
        document.getElementById("lblUserMsg1").innerText=user; 
		document.getElementById("lblUserMsg1").style.display="inline";
		document.getElementById("txtUser").focus();
		return false;
		
	}
	else
	{ 
	   document.getElementById("lblUserMsg1").style.display="none";
		document.getElementById("txtUser").focus();
		////This hidden variable is used in price guide guest page to skip gridview loading and pre-render calculations when user clicks log-in btn.
		//document.getElementById("hdnLogout").value = "1";
		return true;
	}
}   
function executeQuery(ctlButton,ctlFocus)
{
    if(event.keyCode == 13)
    {
       document.getElementById(ctlButton).click();
       document.getElementById(ctlFocus).focus();
       return false;
    } 
    else 
        return true;   
} 

function DisplayErrorMessage(msg)
{
    document.getElementById("lblUserMsg1").innerText=msg;
    document.getElementById("lblUserMsg1").style.display="inline";
   
}



function SetCollapse2()
{
    SetProductCollapse();
    SetBundleCollapse();
    SetSubCollapse();
}

function SetProductCollapse()
{
    var divids = document.getElementById("hdnCollapseIds").value;
    if(divids.length > 0)
    {
        var str = divids.split("@");
        for(i=0;i<str.length-1;i++)
        {
            var strctls =  str[i].split("_");
            var header = strctls[0] + "_" + strctls[1] + "_divHeader";
            var showhide = strctls[0] + "_" + strctls[1] + "_lbnExpand";
            var toggleid = document.getElementById(strctls[0] + "_" + strctls[1] + "_imgToggle");
            toggleid.src = toggleid.src.replace("arrow_down","arrow_right");
            toggleid.alt = "Expand";
            toggleid.onclick = null;
            document.getElementById(header).style.backgroundColor = "#519FED";
            document.getElementById(showhide).innerHTML = "Show Products";
            document.getElementById(str[i]).style.display = "none";
            
        }
    }
}

function SetBundleCollapse()
{
    var divids = document.getElementById("hdnCollapseBundleIds").value;
    if(divids.length > 0)
    {
        var str = divids.split("@");
        for(i=0;i<str.length-1;i++)
        {
            var strctls =  str[i].split("_");
            var header = strctls[0] + "_" + strctls[1] + "_divheader";
            var showhide = strctls[0] + "_" + strctls[1] + "_lbnExpand";
            var toggleid = document.getElementById(strctls[0] + "_" + strctls[1] + "_imgBundleToggle");
            toggleid.src = toggleid.src.replace("arrow_down","arrow_right");
            toggleid.alt = "Expand";
            toggleid.onclick = null;
            document.getElementById(header).style.backgroundColor = "#519fed";
            document.getElementById(showhide).innerHTML = "show products";
            document.getElementById(str[i]).style.display = "none";
            
        }
    }
}

function SetSubCollapse()
{
    var divids = document.getElementById("hdnCollapseSub").value;
    if(divids.length > 0)
    {
        var str = divids.split("@");
        for(i=0;i<str.length-1;i++)
        {
            var strctls =  str[i].split("_");
            var toggleid = document.getElementById(strctls[0] + "_" + strctls[1] + "_" + strctls[2] + "_" + strctls[3] + "_imgToggle");
            toggleid.src = toggleid.src.replace("minus","plus");
            toggleid.alt = "Expand";
            toggleid.onclick = null;
            document.getElementById(str[i]).style.display = "none";
            
        }
    }
}

function RemoveDivId(divid)
{
    document.getElementById("hdnCollapseIds").value = document.getElementById("hdnCollapseIds").value.replace(divid + "@","");
}

function RemoveDivBundleId(divid)
{
    document.getElementById("hdnCollapseBundleIds").value = document.getElementById("hdnCollapseBundleIds").value.replace(divid + "@","");
}

function RemoveDivSubId(divid)
{
    document.getElementById("hdnCollapseSub").value = document.getElementById("hdnCollapseSub").value.replace(divid + "@","");
}

function ToggleEvent(toggle, divid, header, showhide, isproduct)
{
    toggleid =  document.getElementById(toggle);
    if(toggleid.alt != "Expand")
    {
        if(isproduct == "1")
            document.getElementById("hdnCollapseIds").value = document.getElementById("hdnCollapseIds").value + divid + "@" ;
        else
            document.getElementById("hdnCollapseBundleIds").value = document.getElementById("hdnCollapseBundleIds").value + divid + "@" ;
        //alert(document.getElementById("hdnCollapseIds").value);
        toggleid.src = toggleid.src.replace("arrow_down","arrow_right");
        toggleid.alt = "Expand";
        toggleid.onclick = null;
        document.getElementById(header).style.backgroundColor = "#519FED";
        document.getElementById(showhide).innerHTML = "Show Products";
        document.getElementById(divid).style.display = "none";
        return false;
    }
    else 
    {
        toggleid.alt = "Expand";
        return true;
    }
    
}


function ToggleSubEvent(toggle, divid)
{
    toggleid =  document.getElementById(toggle);
    if(toggleid.alt != "Expand")
    {
        document.getElementById("hdnCollapseSub").value = document.getElementById("hdnCollapseSub").value + divid + "@" ;
        toggleid.src = toggleid.src.replace("minus","plus");
        toggleid.alt = "Expand";
        toggleid.onclick = null;
        document.getElementById(divid).style.display = "none";
        return false;
    }
    else 
    {
        toggleid.alt = "Expand";
        return true;
    }
    
}


  

