function extract(s) {
return s.split("#!").join("/").split("/").pop();
}
$(function() {
$('.top_filter_item_active').live('click',function(event) {
event.preventDefault();
$(this).remove();
$('#'+$(this).attr('id')).attr('class', 'filter_item');
var n=$(this).attr('id').split("_");
if($("#selected_filter").is(':empty'))
{
$(".clear_filter").hide();
}
loadNewItem('remove',n[0],n[1],$(this).attr('title'),$(this).attr('href'));
});
$('.filter_item_active').live('click',function(event) {
event.preventDefault();
$(this).attr('class', 'filter_item');
$('#'+$(this).attr('name')+'_'+$(this).attr('rel')+'.filter_top_item').remove();
if($("#selected_filter").is(':empty'))
{
$(".clear_filter").hide();
}
loadNewItem('remove',$(this).attr('name'),$(this).attr('rel'),$(this).attr('title'),$(this).attr('href'));
});
$('.filter_item').live('click',function(event) {
$(this).attr('class', 'filter_item_active');
event.preventDefault();
/*var cur_id = $(this).attr('id');
var cur_rel = $(this).attr('rel');*/
var path = window.location.href.split(BASE_URI)[1].split("#!").join("/").split("//").join("/");
if($("#selected_filter").is(':empty'))
{
$(".clear_filter").hide();
}
else
{
$('.clear_filter').show();
}
if (path.charAt(0) !== "/") {
path = "/" + path;
}
ca = path.split('/');
va = path.split('~');
if(!window.location.hash)
{
$.blockUI({ message: '
Please Wait...
',css: {
border: '2px solid #ffffff',
color: '#ffffff',
padding: '4px',
backgroundColor: '#000000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
'border-radius': '10px',
opacity: .8,
textAlign: 'center'
} });
window.location.hash = '!' + $(this).attr('name')+ '=' +$(this).attr('rel');
only_first_cat = ca[1].split("?");
if(typeof(ca[2]) != 'undefined')
{
fire_url = BASE_URI+only_first_cat[0]+'/'+ca[2]+'?'+$(this).attr('name')+ '=' +$(this).attr('rel');
}
else
{
if(typeof(only_first_cat[1]) != 'undefined')
{
catlog = only_first_cat[1].split('?');
catlogB = only_first_cat[1].split('=');
fire_url = BASE_URI+only_first_cat[0]+'&'+$(this).attr('name')+ '=' +$(this).attr('rel');
}
else
{
fire_url = BASE_URI+only_first_cat[0]+'&'+$(this).attr('name')+ '=' +$(this).attr('rel');
}
}
$('html, body').animate({scrollTop: '0px'}, 500);
$.ajax({
type: "GET",
//url: $(this).attr('href')+'&'+window.location.hash,
url: fire_url,
dataType: "html",
//data:'selection_id='+$(this).attr('rel'),
success: function(html) {
$.unblockUI();
content = $(".result_div",html);
$('.result_div').html(content);
}
});
if($(this).attr('name') != 'page')
{
$("#selected_filter").prepend(''+$(this).attr('title')+'');
$("#selected_filter").show();
$('.clear_filter').show();
}
else
{
if($("#selected_filter").is(':empty'))
{
$(".clear_filter").hide();
}
else
{
$('.clear_filter').show();
}
}
}
else
{
loadNewItem('add',$(this).attr('name'),$(this).attr('rel'),$(this).attr('title'),$(this).attr('href'));
}
});
});
var needfire = '';
$(function() {
$.extend({
getUrlVars: function(){
if(!window.location.hash)
{
return 'none';
}
else
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('#!') + 1).split('/');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
if (hash[0].indexOf('!') == -1)
{
}
else
{
hashX = hash[0].split('!');
hash[0] = hashX[1];
}
vars.push(hash[0]);
vars[hash[0]] = (hash[1].indexOf('?')>0)? unescape(hash[1].replace(/\+/g, " ")).slice(0,hash[1].replace(/\+/g, " ").indexOf('?')):unescape(hash[1].replace(/\+/g, " "));
}
return vars;
}
},
getUrlVar: function(name){
if(name == 'sort')
{
//return $.getUrlVars()[String(name)];
return $('#current_sort').val();
}
else
{
return $.getUrlVars()[name];
}
}
});
if (window.location.hash.length > 1) { loadHash(); }
});
jQuery(window).on('hashchange', function(){
if(needfire == '1')
{
}
else
{
loadHash();
}
needfire = '0';
});
(function ($) {
$.createHashKey = function (hash, key, text) {
var result = (text.length > 0) ? (hash.length > 0) ? '/' + key + '=' + text.replace(/,/g, "~").replace(/ /g, '-') : key + '=' + text.replace(/,/g, "~").replace(/ /g, '-') : '';
return result;
}
})
(jQuery);
(function ($) {
$.getSelectedCheckBox = function (key) {
var result = "";
$(key).each(function () {
if ($(this).hasClass('filter_item_active')) {
result += (result.length > 0) ? "," + $(this).attr("rel") : $(this).attr("rel");
}
});
return result;
}
})
(jQuery);
(function ($) {
$.checkArray = function (text, value) {
var list = text.toLowerCase().split(',');
for (var i = 0; i < list.length; i++)
if (list[i] == value) return true;
return false;
}
})
(jQuery);
(function ($) {
/* $(document).ready(function()
{
var url = $.getParam("color");
alert(url);
});
*/
$.getParam = function(querystring)
{
//get querystring(s) without the ?
var urlParams = decodeURI( window.location.search.substring(1) );
var result = new RegExp(querystring + '=([^]*)').exec( urlParams );
if (!result)
return null;
else
return result[1] || "empty string"; ///NOTE: replace "empty string" by "" - this was just to serve as a visual apercue
}
})
(jQuery);
function loadNewItem(type,a,b,c,href)
{
$.blockUI({ message: 'Please Wait...
',css: {
border: '2px solid #ffffff',
color: '#ffffff',
padding: '4px',
backgroundColor: '#000000',
opacity: .8,
textAlign: 'center'
} });
/*var cur_id = $(this).attr('id');
var cur_rel = $(this).attr('rel');*/
var path = window.location.href.split(BASE_URI)[1].split("#!").join("/").split("//").join("/");
if (path.charAt(0) !== "/") {
path = "/" + path;
}
ca = path.split('/');
va = path.split('~');
only_first_cat = ca[1].split("?");
if(typeof(ca[2]) != 'undefined')
{
if (ca[2].toLowerCase().indexOf("?") >= 0)
{
root_ca = ca[2].split("?");
new_base_url = BASE_URI+root_ca[0]+'&';
}
else
{
search_ca = ca[1].split("search");
if(typeof(search_ca[1]) != 'undefined')
{
new_base_url = BASE_URI+only_first_cat[0]+'&'+ca[2]+'&';
}
else
{
if(typeof(only_first_cat[1]) != 'undefined')
{
only_first_cat = ca[1].split("?");
catlog = only_first_cat[1].split('?');
catlogB = only_first_cat[1].split('=');
new_base_url = BASE_URI+only_first_cat[0]+'/'+ca[2]+'&';
}
else
{
new_base_url = BASE_URI+only_first_cat[0]+'&';
//alert('NEW:'+new_base_url);
}
}
}
}
else
{
if (ca[1].toLowerCase().indexOf("?") >= 0)
{
root_ca = ca[1].split("?");
new_base_url = BASE_URI+root_ca[0]+'&';
}
else
{
new_base_url = BASE_URI+only_first_cat[0]+'&';
}
}
final_url = '';
var range = getRange();
var var_celebrity = $.getSelectedCheckBox("[name=celebrity]");
var var_color = $.getSelectedCheckBox("[name=color]");
var var_style = $.getSelectedCheckBox("[name=style]");
var var_fabric = $.getSelectedCheckBox("[name=fabric]");
var var_work = $.getSelectedCheckBox("[name=work]");
var var_occasion = $.getSelectedCheckBox("[name=occasion]");
var var_shipping_time = $.getSelectedCheckBox("[name=shipping_time]");
var var_catalog = $.getSelectedCheckBox("[name=catalog]");
var var_components = $.getSelectedCheckBox("[name=components]");
if(type == 'price_order_lh')
{
var sor = $('#price_lh').attr('rel');
$('#price_lh').addClass('active');
$('#price_hl').removeClass('active');
$('#sort_new').removeClass('active');
$('#ready_ship').removeClass('active');
}
else if(type == 'price_order_hl')
{
var sor = $('#price_hl').attr('rel');
$('#price_hl').addClass('active');
$('#price_lh').removeClass('active');
$('#sort_new').removeClass('active');
$('#ready_ship').removeClass('active');
}
else
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('#!') + 1).split('/');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
if(hash[0] == 'sort' && hash[1] == 'p.price')
{
var new_price = 'price';
}
if(hash[0] == 'order' && hash[1] == 'ASC')
{
var new_order = 'ASC';
}
if(hash[0] == 'order' && hash[1] == 'DESC')
{
var new_order = 'DESC';
}
if(!typeof(new_order))
{
var new_order = 'ADD';
}
}
if(type == 'sort_new')
{
var sor = $('#sort_new').attr('rel');
$('#sort_new').addClass('active');
$('#price_hl').removeClass('active');
$('#price_lh').removeClass('active');
$('#ready_ship').removeClass('active');
}
else if(new_price == 'price' && new_order == 'ASC')
{
var sor = $('#price_lh').attr('rel');
$('#sort_new').removeClass('active');
$('#price_hl').removeClass('active');
$('#price_lh').addClass('active');
$('#ready_ship').removeClass('active');
}
else if(new_price == 'price' && new_order == 'DESC')
{
var sor = $('#price_hl').attr('rel');
$('#sort_new').removeClass('active');
$('#price_hl').addClass('active');
$('#price_lh').removeClass('active');
$('#ready_ship').removeClass('active');
}
else
{
$('#sort_new').removeClass('active');
$('#price_hl').removeClass('active');
$('#price_lh').removeClass('active');
$('#ready_ship').removeClass('active');
if($('#current_sort').val() == '')
{
$('#sort_new').addClass('active');
}
if($('#current_sort').val() == 'p.product_id'){
$('#sort_new').addClass('active');
}
if($('#current_sort').attr('rel') == 'p.price/order=ASC'){
$('#price_lh').addClass('active');
}
if($('#current_sort').attr('rel') == 'p.price/order=DESC'){
$('#price_hl').addClass('active');
}
var sor = $('#current_sort').attr('rel');
if($('#current_sort').length)
{
//alert($('#current_sort').length);
}
else
{
var sor = 'p.product_id/order=DESC';
}
}
}
var pag = $.getSelectedCheckBox("[name=page]");
_hashVal = '';
_hashVal += $.createHashKey(_hashVal, 'celebrity', var_celebrity);
_hashVal += $.createHashKey(_hashVal, 'color', var_color);
_hashVal += $.createHashKey(_hashVal, 'style', var_style);
_hashVal += $.createHashKey(_hashVal, 'fabric', var_fabric);
_hashVal += $.createHashKey(_hashVal, 'work', var_work);
_hashVal += $.createHashKey(_hashVal, 'occasion', var_occasion);
_hashVal += $.createHashKey(_hashVal, 'shipping_time', var_shipping_time);
_hashVal += $.createHashKey(_hashVal, 'catalog', var_catalog);
_hashVal += $.createHashKey(_hashVal, 'components', var_components);
_hashVal += $.createHashKey(_hashVal, 'page', pag);
_hashVal += $.createHashKey(_hashVal, 'sort', sor);
if(type == 'ready_ship')
{
var sorby = $('#ready_ship').attr('rel');
$('#ready_ship').addClass('active');
$('#price_hl').removeClass('active');
$('#price_lh').removeClass('active');
$('#sort_new').removeClass('active');
_hashVal += $.createHashKey(_hashVal, 'sort_by', sorby);
}
_hashVal += (range.length > 0) ? (_hashVal.length > 0) ? '/price=' + range : 'price=' + range : '';
final_url = _hashVal;
window.location.hash = '!' + _hashVal;
ready_target = _hashVal.replace('#!','').replace('/','&');
var ready_targetF = ready_target.replace(/[/\\*]/g,'&');
fire_url = new_base_url+ready_targetF;
$('html, body').animate({scrollTop: '0px'}, 500);
$.ajax({
type: "GET",
//url: $(this).attr('href')+'&'+window.location.hash,
url: fire_url,
dataType: "html",
//data:'selection_id='+$(this).attr('rel'),
success: function(html) {
$.unblockUI();
content = $(".result_div",html);
$('.result_div').html(content);
//$("#overlay").hide();
}
});
if(type =='add')
{
if((typeof a != 'undefined') && (a != 'page') && (typeof b != 'undefined') && (b != 'undefined'))
{
$("#selected_filter").prepend(''+c+'');
$("#selected_filter").show();
$('.clear_filter').show();
}
}
if(type =='price')
{
$("#selected_filter").prepend(''+c+'');
$("#selected_filter").show();
$('.clear_filter').show();
}
}
function loadHash() {
loadData();
}
function loadData() {
var var_celebrity = $.getUrlVar('celebrity');
var var_color = $.getUrlVar('color');
var var_style = $.getUrlVar('style');
var var_fabric = $.getUrlVar('fabric');
var var_work = $.getUrlVar('work');
var var_occasion = $.getUrlVar('occasion');
var var_shipping_time = $.getUrlVar('shipping_time');
var var_catalog = $.getUrlVar('catalog');
var var_components = $.getUrlVar('components');
var range = $.getUrlVar('price');
var pag = $.getUrlVar('page');
var order = $.getUrlVar('order');
var sort_by = $.getUrlVar('sort_by');
var sortp = $.getUrlVar('sort');
//var sortp = 'p.product_id';
$.blockUI({ message: 'Please Wait...
',css: {
border: '2px solid #ffffff',
color: '#ffffff',
padding: '4px',
backgroundColor: '#000000',
opacity: .8,
textAlign: 'center'
} });
var path = window.location.href.split(BASE_URI)[1].split("#!").join("/").split("//").join("/");
if (path.charAt(0) !== "/") {
path = "/" + path;
}
ca = path.split('/');
va = path.split('~');
only_first_cat = ca[1].split("?");
if(typeof(ca[2]) != 'undefined')
{
//new_base_url = BASE_URI+ca[2]+'?';
if (ca[2].toLowerCase().indexOf("?") >= 0)
{
root_ca = ca[2].split("?");
new_base_url = BASE_URI+root_ca[0]+'&';
}
else
{
new_base_url = BASE_URI+only_first_cat[0]+'&';
}
}
else
{
if (ca[1].toLowerCase().indexOf("?") >= 0)
{
root_ca = only_first_cat[0].split("?");
new_base_url = BASE_URI+root_ca[0]+'&';
}
else
{
new_base_url = BASE_URI+only_first_cat[0]+'&';
}
}
var GaCodepath = "";
var var_celebrity = $.getUrlVar('celebrity');
if (var_celebrity){
GaCodepath = GaCodepath + "&celebrity=" + var_celebrity;
checkValue('[name=celebrity]', var_celebrity);
}
var var_color = $.getUrlVar('color');
if (var_color){
GaCodepath = GaCodepath + "&color=" + var_color;
checkValue('[name=color]', var_color);
}
var var_style = $.getUrlVar('style');
if (var_style){
GaCodepath = GaCodepath + "&style=" + var_style;
checkValue('[name=style]', var_style);
}
var var_fabric = $.getUrlVar('fabric');
if (var_fabric){
GaCodepath = GaCodepath + "&fabric=" + var_fabric;
checkValue('[name=fabric]', var_fabric);
}
var var_work = $.getUrlVar('work');
if (var_work){
GaCodepath = GaCodepath + "&work=" + var_work;
checkValue('[name=work]', var_work);
}
var var_occasion = $.getUrlVar('occasion');
if (var_occasion){
GaCodepath = GaCodepath + "&occasion=" + var_occasion;
checkValue('[name=occasion]', var_occasion);
}
var var_shipping_time = $.getUrlVar('shipping_time');
if (var_shipping_time){
GaCodepath = GaCodepath + "&shipping_time=" + var_shipping_time;
checkValue('[name=shipping_time]', var_shipping_time);
}
var var_catalog = $.getUrlVar('catalog');
if (var_catalog){
GaCodepath = GaCodepath + "&catalog=" + var_catalog;
checkValue('[name=catalog]', var_catalog);
}
var var_components = $.getUrlVar('components');
if (var_components){
GaCodepath = GaCodepath + "&components=" + var_components;
checkValue('[name=components]', var_components);
}
if (pag){
GaCodepath = GaCodepath + "&page=" + pag;
checkValue('[name=page]', pag);
}
if (range){
GaCodepath = GaCodepath + "&price=" + range;
checkPrice(range);
}
fire_url = new_base_url+GaCodepath;
if(order)
{
fire_url = fire_url+'&order='+order;
}
if(sortp)
{
fire_url = fire_url+'&sort='+sortp;
}
if(sort_by)
{
fire_url = fire_url+'&sort_by='+sort_by;
}
//$( window ).load(function() {
$.ajax({
type: "GET",
url: fire_url,
dataType: "html",
success: function(html) {
$.unblockUI();
content = $(".result_div",html);
$('.result_div').html(content);
}
});
//});
}
function checkValue(ctrl, text) {
text = text.replace(/~/g, ' ');
$(ctrl).each(function () {
if ($(this).hasClass('filter_item_active')) $(this).toggleClass("filter_item_active");
if (text.toLowerCase().indexOf($(this).attr("rel").toLowerCase()) > -1) {
$(this).attr('class', 'filter_item_active');
/*if ($.checkArray(text, $(this).attr("rel").toLowerCase())) {
$(this).toggleClass("filter_item_active");
addSelection($(this), $(this).attr("rel"));
}*/
}
});
}
function CreateEl(tag, css) {
var x = document.createElement(tag);
x.className = css;
return (x);
}
$('#price_lh').live('click',function(event) {
event.preventDefault();
var path = window.location.href.split(BASE_URI)[1].split("#!").join("/").split("//").join("/");
if (path.charAt(0) !== "/") {
path = "/" + path;
}
ca = path.split('/');
va = path.split('~');
only_first_cat = ca[1].split("?");
if(typeof(ca[2]) != 'undefined')
{
new_base_url = BASE_URI+only_first_cat[0]+'&'+ca[2]+'&';
}
else if(typeof(ca[1]))
{
new_base_url = BASE_URI+only_first_cat[0]+'&';
}
needfire = '1';
loadNewItem('price_order_lh',$(this).attr('name'),$(this).attr('rel'),$(this).attr('title'),new_base_url+'sort=p.price&order=ASC');
});
$('#price_hl').live('click',function(event) {
event.preventDefault();
var path = window.location.href.split(BASE_URI)[1].split("#!").join("/").split("//").join("/");
if (path.charAt(0) !== "/") {
path = "/" + path;
}
ca = path.split('/');
va = path.split('~');
only_first_cat = ca[1].split("?");
if(typeof(ca[2]) != 'undefined')
{
new_base_url = BASE_URI+only_first_cat[0]+'&'+ca[2]+'&';
}
else
{
new_base_url = BASE_URI+only_first_cat[0]+'&';
}
needfire = '1';
loadNewItem('price_order_hl',$(this).attr('name'),$(this).attr('rel'),$(this).attr('title'),new_base_url+'sort=p.product_id&order=DESC');
});
$('#sort_new').live('click',function(event) {
event.preventDefault();
var path = window.location.href.split(BASE_URI)[1].split("#!").join("/").split("//").join("/");
if (path.charAt(0) !== "/") {
path = "/" + path;
}
ca = path.split('/');
va = path.split('~');
only_first_cat = ca[1].split("?");
if(typeof(ca[2]) != 'undefined')
{
new_base_url = BASE_URI+only_first_cat[0]+'&'+ca[2]+'&';
}
else
{
new_base_url = BASE_URI+only_first_cat[0]+'&';
}
$('#sort_by').val('');
needfire = '1';
loadNewItem('sort_new',$(this).attr('name'),$(this).attr('rel'),$(this).attr('title'),new_base_url+'sort=p.product_id&order=DESC');
});
$('#ready_ship').live('click',function(event) {
event.preventDefault();
var path = window.location.href.split(BASE_URI)[1].split("#!").join("/").split("//").join("/");
if (path.charAt(0) !== "/") {
path = "/" + path;
}
ca = path.split('/');
va = path.split('~');
new_base_url = BASE_URI+ca[1]+'&';
needfire = '1';
loadNewItem('ready_ship',$(this).attr('name'),$(this).attr('rel'),$(this).attr('title'),new_base_url+'sort_by=readytoship');
});