var propertyCount=new Array();var searchedCustomNo="";var searchedCustomValue="";var propertyList=new Array();var countedProps=0;var shippingTotalProductsNo=1;var currentShippingItem=1;var lastQuickSearchKwd='';var quickSearchIframe=null;function BasketTotalCallback(res)
{if(res&&res.value)
{var totalsContainer=document.getElementById("headerBasket");if(totalsContainer)
{totalsContainer.innerHTML=res.value;}}}
function CalculateBasketTotals()
{Header.GetBasketTotal(BasketTotalCallback);}
function SetPageCallBack(res)
{}
function SetLastVisitedPage()
{if(typeof MasterPage!="undefined"&&MasterPage!=null)
{MasterPage.SetLastVisitedPage(window.location.pathname,SetPageCallBack);}}
function ErrorMessageCallBack(res)
{var ajaxErrorDiv=document.getElementById("ajaxError");if(ajaxErrorDiv&&res.value)
{var errorUL=ajaxErrorDiv.getElementsByTagName("ul");if(errorUL[0])
{errorUL[0].innerHTML="";for(var i=0;i<res.value.length;i++)
{if(res.value[i].Field!=null)
{errorUL[0].innerHTML+="<li>"+res.value[i].Field+" - "+res.value[i].Message+"</li>";}
else
{errorUL[0].innerHTML+="<li>"+res.value[i].Message+"</li>";}}}
ajaxErrorDiv.className=ajaxErrorDiv.className.replace("hide","");}}
function GetErrorMessage()
{if(BasketPage)
{BasketPage.GetErrorMessage(ErrorMessageCallBack);}}
function CouponsCallBack(res)
{var basketCoupons=document.getElementById("basketCoupons");var getErrorMessage=false;if(basketCoupons)
{if(res&&res.value)
{if(res.value.length>0)
{var htmlCoupons=basketCoupons.getElementsByTagName("DIV");if(htmlCoupons.length>0)
{for(var i=0;i<htmlCoupons.length;i++)
{var div=htmlCoupons[i];if(div.id!="")
{if(!CouponExistsInCollection(div.id,res.value))
{basketCoupons.removeChild(div);getErrorMessage=true;}}}}}
else
{basketCoupons.innerHTML="";basketCoupons.className+=" hide";getErrorMessage=true;}}}
if(getErrorMessage)
{GetErrorMessage();}}
function GetBasketCoupons()
{var basketCoupons=document.getElementById("basketCoupons");if(basketCoupons&&BasketPage)
{BasketPage.GetRemovedCoupons(CouponsCallBack);}}
function CouponExistsInCollection(couponCode,couponCollection)
{if(couponCollection==null||couponCollection.length==0)
return false;else
{for(var i=0;i<couponCollection.length;i++)
{if(couponCollection[i].Code==couponCode)
{return true;}}}
return false;}
function AddProductCountToProperty(productNo,customNo)
{if(propertyCount&&propertyCount.length>0)
{for(var i=0;i<propertyCount.length;i++)
{var elem=propertyCount[i].split('^');if(elem[0]==customNo)
{elem[1]+=productNo;propertyCount[i]=elem[0]+"^"+elem[1];break;}}}}
function HideExcessHTML()
{if(propertyCount&&propertyCount.length>0)
{for(var i=0;i<propertyCount.length;i++)
{var elem=propertyCount[i].split('^');if(elem[1]==0)
{var mainPropContainer=document.getElementById('rnk-filter-'+elem[0].replace('span-',''));if(mainPropContainer)
{mainPropContainer.className="hide";}}}}}
function IncreaseAddedNo()
{countedProps++;if(countedProps==propertyList.length)
{HideExcessHTML();}}
function ProductCountCallBack(res)
{if(res&&res.value)
{if(res.value!='')
{var ret=res.value.split("^");if(ret&&ret.length==3)
{var currentProperty=document.getElementById(ret[0]+"-"+ret[1]);var propertyLI=document.getElementById("li-"+ret[0]+"-"+ret[1]);if(ret[2]>0)
{if(currentProperty)
{currentProperty.innerHTML=ret[2];AddProductCountToProperty(ret[2],ret[0]);}}
else
{propertyLI.className="hide";}
IncreaseAddedNo();}}}}
function AddCustomToArray()
{if(searchedCustomNo&&searchedCustomNo!='')
{if(propertyCount&&propertyCount.length>0)
{var customFound=false;for(var i=0;i<propertyCount.length;i++)
{if(propertyCount[i].indexOf(searchedCustomNo)!=-1)
{customFound=true;break;}}
if(customFound==false)
{propertyCount.push(searchedCustomNo+"^0");}}
else
{propertyCount.push(searchedCustomNo+"^0");}}}
function ProductCount(customNo,customValue,addSqlString)
{if(typeof SearchFilters!="undefined"&&SearchFilters!==null)
{searchedCustomNo=customNo;searchedCustomValue=customValue;AddCustomToArray();SearchFilters.GetProductNumberForValue(customNo,customValue,addSqlString,ProductCountCallBack);}
else
{document.write("");}}
function AddPropertyToArray(customNo,customValue,addSqlString)
{var propertyLine=new Array();propertyLine[0]=customNo;propertyLine[1]=customValue;propertyLine[2]=addSqlString;propertyList.push(propertyLine);var test='';}
function SetFilterHMTL(productNoResult)
{if(productNoResult&&productNoResult.length==4)
{var currentProperty=document.getElementById(productNoResult[0]+"-"+productNoResult[1]);var propertyLI=document.getElementById("li-"+productNoResult[0].replace("span-","")+"-"+productNoResult[1]);if(productNoResult[3]>0)
{if(currentProperty)
{currentProperty.innerHTML=productNoResult[3];AddProductCountToProperty(productNoResult[3],productNoResult[0]);}}
else
{if(propertyLI)
{propertyLI.className="hide";}}
IncreaseAddedNo();}}
function CountProductsCallBack(res)
{if(res&&res.value&&res.value.length>0)
{for(var i=0;i<res.value.length;i++)
{SetFilterHMTL(res.value[i]);}
HideUsingClass('rnk_filter_loader');ShowUsingClass('rnk_applied_filters');ShowUsingClass('rnk_search_filter');}}
function CountProducts(totalAddedProperties)
{if(typeof AjaxPro!="undefined"&&AjaxPro!==null)
{AjaxPro.timeoutPeriod=15000;AjaxPro.onTimeout=function(b,res){return false;}}
HideUsingClass('rnk_applied_filters');HideUsingClass('rnk_search_filter');ShowUsingClass('rnk_filter_loader');if(propertyList&&propertyList.length==totalAddedProperties)
{for(var i=0;i<propertyList.length;i++)
{searchedCustomNo=propertyList[i][0];searchedCustomValue=propertyList[i][1];AddCustomToArray();}
if(typeof SearchFilters!="undefined"&&SearchFilters!==null)
{SearchFilters.GetProductNumberForFilterList(propertyList,CountProductsCallBack);}}}
function GetShippingTaxCallBack(res)
{if(res&&res.value)
{HideUsingClass('rnk_loader');RemoveIframe('rnk-shipping-popup');HideUsingClass('rnk-shipping-popup');if(shippingTotalProductsNo==1)
{if(res.value.length>1)
{var productPageOutput=document.getElementById('tax-'+currentShippingItem);var prodPageLink=document.getElementById('shippLink-'+currentShippingItem);if(productPageOutput)
{productPageOutput.innerHTML=res.value[1]+'&nbsp;';}
if(prodPageLink)
{prodPageLink.innerHTML='alt oras';}}}
else
{for(var i=0;i<shippingTotalProductsNo;i++)
{var productPageOutput=document.getElementById('tax-'+(i+1));var prodPageLink=document.getElementById('shippLink-'+(i+1));if(productPageOutput)
{productPageOutput.innerHTML=res.value[i]+'&nbsp;';}
if(prodPageLink)
{prodPageLink.innerHTML='alt oras';}}}}
shippingTotalProductsNo=1;}
function GetShippingTax(cityDDL,stateDDLId,productWeight)
{var weigths=productWeight.split("^");shippingTotalProductsNo=weigths.length;var stateDDL=document.getElementById(stateDDLId);if(typeof Header!="undefined"&&Header!=null&&cityDDL!=null&&stateDDL!=null)
{if(cityDDL.options[cityDDL.selectedIndex].value>0&&stateDDL.options[stateDDL.selectedIndex].value)
{ShowUsingClass('rnk_loader');var cityId=cityDDL.options[cityDDL.selectedIndex].value;var cityName=cityDDL.options[cityDDL.selectedIndex].text;var stateId=stateDDL.options[stateDDL.selectedIndex].value;var stateName=stateDDL.options[stateDDL.selectedIndex].text;if(shippingTotalProductsNo==1)
{Header.GetShippingTotal(stateId,stateName,cityId,cityName,productWeight,GetShippingTaxCallBack);}
else
{Header.GetMultiShippingTotal(stateId,stateName,cityId,cityName,weigths,GetShippingTaxCallBack);}}}}
function QuickSearchCallBack(res)
{if(res&&res.value)
{quickSearchResNo=parseInt(res.value[0]);var quickHolder=document.getElementById('quickSearch');if(quickSearchResNo>0)
{if(quickHolder)
{quickHolder.innerHTML=res.value[1];if(quickHolder.className.indexOf('hideDiv')>0)
{ShowUsingClass('quickSearch');}
if(IsIE())
{var parent=quickHolder.parentElement;var iFrame=document.createElement("IFRAME");iFrame.setAttribute("src","javascript:'<html></html>'");iFrame.setAttribute("border","0");iFrame.className="quick_search_iFrame";iFrame.style.height=quickHolder.offsetHeight;if(quickSearchIframe!=null)
{parent.removeChild(quickSearchIframe);}
quickSearchIframe=iFrame;parent.appendChild(iFrame);}
var link=document.getElementById('quick_search_a'+res.value[0]);if(link)
{link.focus();}}}
else
{if(IsIE())
{var parent=quickHolder.parentElement;if(quickSearchIframe!=null)
{parent.removeChild(quickSearchIframe);quickSearchIframe=null;}}
quickHolder.innerHTML='';HideUsingClass('quickSearch');}}}
function QuickSearch(kwd,minLength,siteRoot,e)
{var key;if(window.event){key=e.keyCode;}
else if(e.which){key=e.which;}
var input=document.getElementById('ctl00_header_kwd');if((key>=48&&key<=57)||(key>=65&&key<=90)||(key>=96&&key<=105)||(key==8)||(key==46)||(key==190)||(key==222)||(key==109))
{quickSearchCurrentLink=-1;if(kwd.length>=minLength)
{if(lastQuickSearchKwd!=kwd)
{if(typeof SearchBox!="undefined"&&SearchBox!=null)
{lastQuickSearchKwd=kwd;input.setAttribute("autocomplete","off");SearchBox.QuickSearch(kwd,QuickSearchCallBack);}}}
else
{input.removeAttribute("autocomplete");lastQuickSearchKwd='';quickSearchResNo=0;quickSearchCurrentLink=-1;if(IsIE())
{var quickHolder=document.getElementById('quickSearch');var parent=quickHolder.parentElement;if(quickSearchIframe!=null)
{parent.removeChild(quickSearchIframe);quickSearchIframe=null;}}
HideUsingClass('quickSearch');}
return true;}
else
{if(key==13&&input)
{CrossPostASPForm(siteroot+'/All/Page-1.aspx');return false;}}}
function ClearCombo(ddlElement)
{for(i=ddlElement.options.length-1;i>=0;i--)
{ddlElement.removeChild(ddlElement.options[i]);}}
var cityCombo=null;function GetCitiesForState(stateDDLid,cityDDLid)
{var stateCombo=document.getElementById(stateDDLid);cityCombo=document.getElementById(cityDDLid);var selectedState=-1;if(stateCombo.selectedIndex>0)
{selectedState=stateCombo.options[stateCombo.selectedIndex].value;}
if(selectedState>0)
{if(stateCombo&&cityCombo)
{ClearCombo(cityCombo);var objOption=document.createElement("option");objOption.text="Lista se incarca ...";objOption.value="-1";if(document.all&&!window.opera)
{cityCombo.add(objOption);}
else
{cityCombo.add(objOption,null);};cityCombo.disabled=true;if(typeof CheckoutPage!='undefined'&&CheckoutPage!=null)
{CheckoutPage.GetCitiesForState(selectedState,GetCitiesCallBack);}
else
{if(typeof EditAddresses!='undefined'&&EditAddresses!=null)
{EditAddresses.GetCitiesForState(selectedState,GetCitiesCallBack);}}}}
else
{ClearCombo(cityCombo);var objOption=document.createElement("option");objOption.text="Alegeti mai intai un judet";objOption.value="-1";if(document.all&&!window.opera)
{cityCombo.add(objOption);}
else
{cityCombo.add(objOption,null);};cityCombo.disabled=true;}}
function GetCitiesCallBack(res)
{if(res&&res.value&&cityCombo)
{ClearCombo(cityCombo);PopulateCityCombo(cityCombo,res.value,0);if(res.value.length>1)
{cityCombo.disabled=false;}}}
function PopulateCityCombo(ddlElement,values,selectedIndex)
{for(var i=0;i<values.length;i++)
{var objOption=document.createElement("option");objOption.text=values[i].Name;objOption.value=values[i].Id;if(document.all&&!window.opera)
{ddlElement.add(objOption);}
else
{ddlElement.add(objOption,null);};}
ddlElement.selectedIndex=selectedIndex;}