/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
 (function ($) {

;(function(){

	var hLink;
	var hLinkTitle;
    var open = false;
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 20;
		yOffset = 5;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		

	
		var hoverIntentTooltip = {
	           over: addTipHover,
	           timeout: 1000,
	           out: removeTipHover
		};
		
		

		
	$("a.tooltip, img.tooltip").hoverIntent(hoverIntentTooltip);
	

	function addTipHover(e){	
	 if(this.title != ""){
         open = true;
		 if($('#tooltip').length >0){
		   hLink.title = hLinkTitle;		
		   $("#tooltip").remove();
		   open = false;
		 }
		 hLink = this;
		 hLinkTitle = this.title;
		this.t = this.title;
		this.title = "";	

		$("body").append("<span id='tooltip' ><span class='tipbox' style='position:relative'>"+ this.t +"</span></span>");
		//alert($("#tooltip").css('height'));
		$("#tooltip")
			.css("left",(e.pageX + yOffset) + "px")
			.css("z-index", 999999)
			.css('position', 'absolute')
			.fadeIn("fast");	
			
	    $("#tooltip").css("top",(e.pageY - ($("#tooltip").height()/2)) + "px");
        }
    };
	function removeTipHover(e){
	if(open == true){
	e.target.title = $('#tooltip span').html();
	 $('#tooltip').remove();
	 open = false;
    };	
	}
			
};

})();
})(jQuery);


;
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);;
(function ($) {


var clonedNum = 0;
var hitMemory = -1;
var currency_codes = {
AF: "AFA",
AL: "ALL",
DZ: "DZD",
AS: "EUR",
AD: "EUR",
AO: "AOK",
AI: "XCD",
AG: "XCD",
AR: "ARP",
AM: "AMD",
AW: "ANG",
AU: "AUD",
AT: "EUR",
AZ: "AZM",
BS: "BSD",
BH: "BHD",
BD: "BDT",	 
BB: "BBD",
BY: "BYR",
BE: "EUR",
BZ: "BZD",
BJ: "XOF",
BM: "BMD",
BT: "INR",
BO: "BOB",
BA: "BAK",
BW: "BWP",
BV: "NOK",
BR: "BRR",
IO: "USD",
BN: "BND",
BG: "BGL",
BF: "XOF",
BI: "BIF",
KH: "KHR",
CM: "XAF",
CA: "CAD",
CV: "CVE",
KY: "KYD",
CF: "XAF",
TD: "XAF",
CL: "CLP",
CN: "CNY",
CX: "AUD",
CC: "AUD",
CO: "COP",
KM: "KMF",
CG: "XAF",
CD: "CDF",
CK: "NZD",
CR: "CRC",
HR: "HRK",
CU: "CUP",
CY: "CYP",
CZ: "CSK",
DK: "DKK",
DJ: "DJF",
DM: "XCD",
DO: "DOP",
TP: "IDR",
EC: "ECS",
EG: "EGP",
SV: "SVC",
GQ: "XAF",
ER: "ETB",
EE: "EEK",
ET: "ETB",
FK: "FKP",
FO: "DKK",
FJ: "FJD",
FI: "EUR",
FR: "EUR",
GF: "EUR",
PF: "XPF",
TF: "EUR",
GA: "XAF",
GM: "GMD",
GE: "GEL",
DE: "EUR",
GH: "GHC",
GI: "GIP",
GR: "EUR",
GL: "DKK",
GD: "XCD",
GP: "EUR",
GU: "USD",
GT: "GTQ",
GN: "GNF",
GW: "XOF",
GY: "GYD",
HT: "HTG",
HM: "AUD",
HN: "HNL",
HK: "HKD",
HU: "HUF",
IS: "ISK",
IN: "INR",
ID: "IDR",
IR: "IRR",
IQ: "IQD",
IE: "EUR",
IL: "ILS",
IT: "EUR",
CI: "XOF",
JM: "JMD",
JP: "JPY",
JO: "JOD",
KZ: "KZT",
KE: "KES",
KI: "AUD",
KP: "KPW",
KR: "KRW",
KW: "KWD",
KG: "KGS",
LA: "LAK",
LV: "LVL",
LB: "LBP",
LS: "LSL",
LR: "LRD",
LY: "LYD",
LI: "CHF",
LT: "LTL",
LU: "EUR",
MO: "MOP",
MK: "MKD",
MG: "MGF",
MW: "MWK",
MY: "MYR",
MV: "MVR",
ML: "XOF",
MT: "MTL",
MH: "USD",
MQ: "EUR",
MR: "MRO",
MU: "MUR",
YT: "EUR",
MX: "MXP",
FM: "USD",
MD: "MDL",
MC: "EUR",
MN: "MNT",
MS: "XCD",
MA: "MAD",
MZ: "MZM",
MM: "MMK",
NA: "NAD",
NR: "AUD",
NP: "NPR",
NL: "EUR",
AN: "ANG",
NC: "XPF",
NZ: "NZD",
NI: "NIO",
NE: "XOF",
NG: "NGN",
NU: "NZD",
NF: "AUD",
MP: "USD",
NO: "NOK",
OM: "OMR",
PK: "PKR",
PW: "USD",
PA: "PAB",
PG: "PGK",
PY: "PYG",
PE: "PEN",
PH: "PHP",
PN: "NZD",
PL: "PLZ",
PT: "EUR",
PR: "USD",
QA: "QAR",
RE: "EUR",
RO: "ROL",
RU: "RUR",
RW: "RWF",
KN: "XCD",
LC: "XCD",
VC: "XCD",
WS: "EUR",
SM: "EUR",
ST: "STD",
SA: "SAR",
SN: "XOF",
SC: "SCR",
SL: "SLL",
SG: "SGD",
SK: "SKK",
SI: "EUR",
SB: "SBD",
SO: "SOS",
ZA: "ZAR",
GS: "GBP",
ES: "EUR",
LK: "LKR",
SD: "SDD",
SR: "SRG",
SJ: "NOK",
SZ: "SZL",
SE: "SEK",
CH: "CHF",
SY: "SYP",
TW: "TWD",
TJ: "TJR",
TZ: "TZS",
TH: "THB",
TG: "XOF",
TK: "NZD",
TO: "TOP",
TT: "TTD",
TN: "TND",
TR: "TRY",
TM: "TMM",
TC: "USD",
TV: "AUD",
UG: "UGX",
UA: "UAH",
AE: "AED",
GB: "GBP",
US: "USD",
UM: "USD",
UY: "UYU",
UZ: "UZS",
VU: "VUV",
VA: "EUR",
VE: "VEB",
VN: "VND",
VG: "USD",
VI: "USD",
WF: "XPF",
EH: "MAD",
YE: "YER",
YU: "YUN",
ZM: "ZMK",
ZW: "ZWD"};

var currency_symbols = {
	GBP: "&pound;",
	EUR: "&euro;",
	USD: "&#36;",
	JPY: "&yen;"
};
  
var firstLoad = true; //only trigger js for size list once

  Drupal.viewsSlideshowSlideCounter.transitionBegin = function (options) {
    $('#views_slideshow_slide_counter_' + options.slideshowID ).find('.selected').removeClass('selected');
	$('#views_slideshow_slide_counter_' + options.slideshowID + ' .counter_' +(options.slideNum + 1)).addClass('selected');
    //$('#views_slideshow_slide_counter_' + options.slideshowID + ' .num').text(options.slideNum + 10);
  }

Drupal.behaviors.general = {
  attach: function() {			
  
     tooltip();
     	  
     //$('#main-menu-links .expanded ul').css('display','none');
	 $('#main-menu-links .expanded').hover(function(){

	  $(this).find('ul').css('display','block');
	  }, function(){
	    $(this).find('ul').css('display','none');
	  });
	  
  	//If we dont already know the country of the current user, find it and add to cookie
	if($.cookie('country') == null){
	  $.ajax({
      url:'http://api.wipmania.com/jsonp?callback=?',
      dataType: 'json',
      data: '',
      success: function(json, textStatus, jqXHR) {
	            getCountry(false, json);
	 },
	 error:  function(xhr, msg, ex) {
	           getCountry(true, null);
     }
   });

   }
   
   else{
        //add the necessary code to allow for currency conversions
   var cur_symb = "";
   if(currency_symbols[$.cookie('currency')]){
     cur_symb = currency_symbols[$.cookie('currency')];
	 $('.currency').not('.dd').attr('rel', 'GBP:'+$.cookie('currency')+':'+cur_symb);
   }else{
     $('.currency').not('.dd').attr('rel', 'GBP:'+$.cookie('currency'));
   }
   $('.pound_symb').css('display','none');
   $('.currency.dd').attr('rel', 'GBP:'+$('#edit-field-product-currency-und').val());
   $('.dom_fixed').not('.cust').css('display','none');
   

   //change default currency
   $('#curr_dd').change(function(){
      $.cookie('country', $('#curr_dd option:selected').val() , { expires: 28, path: '/' });
	  $.cookie('currency', currency_codes[$('#curr_dd option:selected').val()] , { expires: 28, path: '/' });
	  location.reload();
   });
   
   if($.cookie('country') != null){
     if($('#curr_dd option[value='+$.cookie('country')+']').length > 0){
	   $('#curr_dd option[value='+$.cookie('country')+']').attr('selected', 'selected');
	 }else{
	    $('select#curr_dd').append('<option value='+$.cookie('country')+'>'+$.cookie('currency')+'</option>');
		$('select#curr_dd option:last').attr('selected','selected');
	 }
   }
  }
   
   $('.node-add-to-cart').click(function(){
     if($.cookie('cart_qty') == null){
	  $.cookie('cart_qty', 1 , { expires: 1, path: '/' });
	 }else{
	  $.cookie('cart_qty', parseInt($.cookie('cart_qty'))+1 , { expires: 1, path: '/' });
	 }
   });
   
   $('.image .form-submit').click(function(){
     if($.cookie('cart_qty') != null && $.cookie('cart_qty') > 0){
	  $.cookie('cart_qty', parseInt($.cookie('cart_qty'))-1 , { expires: 1, path: '/' });
	 }
   });
   
    if($.cookie('cart_qty') != null && $.cookie('cart_qty') != 0){
	  $('#shop_qty').html("&nbsp;("+$.cookie('cart_qty')+")");
	}
   

   
   //catalog page
   //filter is selected
   $('#catalog_nav input').change(function(){
     var pathname = window.location.search;
	 var pval = getURLParameter('page');
	 pathname = pathname.replace('&page='+pval, "");
	 pathname = pathname.replace('page='+pval, "");
	 var ext_path = '';
     if($(this).attr('checked')){
	   if(pathname.indexOf('?') >= 0 ){
	    if($(this).hasClass('cat_all')){
		  $.each($(this).parents('.menu_div').find('input[name=cat]') ,function(index,value){
		    if(!$(this).attr('checked')){
			  ext_path += $(this).attr('rel');
			}
		  });
		}
         window.location.href = window.location.pathname+pathname+ext_path+$(this).attr('rel');
	   }else{
	   if($(this).hasClass('cat_all')){
		  $.each($(this).parents('.menu_div').find('input[name=cat]') ,function(index,value){
		    if(!$(this).attr('checked')){
			  ext_path += $(this).attr('rel');
			}
		  });
		}
	     window.location.href = window.location.pathname+"?"+pathname+ext_path+$(this).attr('rel');
	   }
	  }else{
	    pathname = pathname.replace($(this).attr('rel'), "");
	    if($(this).attr('rel').indexOf('cat[]') >0){
		$.each($(this).parents('.menu_div').find('input[name=cat]') ,function(index,value){
		    if($(this).attr('checked')){
			  pathname = pathname.replace($(this).attr('rel'), "");
			}
		  });
		  }
		  
		if($(this).attr('rel').indexOf('category_tid') >0){
		var cur = $(this);
		  $.each($(this).parents('ul').find('input[checked=yes]'), function(index,value){
		    if(cur.val() != $(value).val()){
			 if(pathname.indexOf($(value).attr('rel')) <= 0){
			   pathname = pathname + $(value).attr('rel');
			 }
			}
		  });
		}
		if($(this).attr('rel').indexOf('category_tid') >0 && pathname.indexOf('cat[]') > 0){
		 var boo =$(this).parents('.menu_div').find('input[name=cat_all]').attr('rel');
          pathname = pathname.replace(boo,"");
         }		
		
		if(pathname.indexOf('category_tid') < 0 && pathname.indexOf('sizes_value') >= 0){
		  pathname = removeSizes(pathname); //remove legs too
		}
		window.location.href = window.location.pathname+pathname;
	  }
   });
   
   
   $('#catalog_nav input[checked=yes]').parents('.menu_div').css('display','block');
   $('#catalog_nav .menu_title').click(function(){
      $(this).next('.menu_div').slideToggle('slow');
	});
	
	//product page display/hide model size
	$('.product_mini_imgs a').click(function(){
	  if($(this).hasClass('main_small_img')){
	    $('.model_size').css('visibility', 'visible');
	  }else{
	    $('.model_size').css('visibility', 'hidden');
	  }
	});
	
	$('.page-profile-designer-profile .col_sel').change(function(){
	   window.location.href = window.location.pathname+"?collection="+$(this).val();
	});
	$('.page-profile-designer-profile .lb_col_sel').change(function(){
	   window.location.href = window.location.pathname+"?lb_collection="+$(this).val();
	});
	
	$('.page-view-inspiration .inspir_hp_item, .page-industry-network .inspir_hp_item').hover(
	  function(){
	    $(this).find('.inspir_hp_trans').css('display','block');
	  },
	  function(){
	    $(this).find('.inspir_hp_trans').css('display','none');
	  });
	
    $('#block-block-14 ul ul, #block-block-15 ul ul, #block-block-19 ul ul').css('display','none');
	$('#block-block-14 .link_highl, #block-block-15 .link_highl, #block-block-19 .link_highl').next().css('display','block');
	$('#block-block-14 a.expand, #block-block-15 a.expand, #block-block-19 a.expand').click(function(){
	  $(this).next().slideToggle('slow');
	  return false;
	});
	
	 $('.page-designer-directory #sidebar-first .form-text').blur(function() {
          var val = $(this).val();
          if (!val) {
            $('#tellus-pages-designer-search-form').addClass('simple-subscription-empty');
            $(this).val("Search...");
          } 
          else if (val == "Search...") {
            $('#tellus-pages-designer-search-form').addClass('simple-subscription-empty');
          };    
        }).focus(function() {
          if ($('#tellus-pages-designer-search-form').hasClass('simple-subscription-empty')) {
            $(this).val("");
            $('#tellus-pages-designer-search-form').removeClass('simple-subscription-empty');
          }
        }).blur();
		
		$('#tellus-subscribe-list-anonym-form .form-text').blur(function() {
          var val = $(this).val();
          if (!val) {
            $('#tellus-subscribe-list-anonym-form').addClass('simple-subscription-empty');
            $(this).val("E-mail address...");
          } 
          else if (val == "E-mail address...") {
            $('#tellus-subscribe-list-anonym-form').addClass('simple-subscription-empty');
          };    
        }).focus(function() {
          if ($('#tellus-subscribe-list-anonym-form').hasClass('simple-subscription-empty')) {
            $(this).val("");
            $('#tellus-subscribe-list-anonym-form').removeClass('simple-subscription-empty');
          }
        }).blur();
		
		$('#search-block-form .form-text').blur(function() {
          var val = $(this).val();
          if (!val) {    
            $(this).val("Search");
          }    
        }).focus(function() {
          
            $(this).val("");
            
       
        }).blur();

												
		$('.designers_vids a').click(function(){
   		  $('#vid_div').attr('style', 'position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:#000;z-index:1000').css('opacity','0.7');
		});

		
		$('#vid_div').click(function(){
		  $('.embed_vid').remove(); 
		  $('#vid_div').attr('style', 'position:relative');
		});
		
		$('.node-type-portfolio .designers_other a').live('click', function(){
		  var big_img = $(this).find('img').attr('src').replace('uc_product_list','detailed_product');
		  $('.inspir_main_img img').attr('src', big_img);
		});
		
		$('#seo_txt h1, #seo_txt h2').click(function(){
		  $('#seo_txt').find('.expanded').slideUp('fast').removeClass('expanded');
		  $('.'+$(this).attr('id')).slideToggle('slow').addClass('expanded');
		});
	
function removeSizes(pathname){

  $.each($('#catalog_nav #size_div input[name=size]'), function(index,value){
	pathname = pathname.replace($(this).attr('rel'), "");
  });
  return pathname;
}
function getURLParameter(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
}

function getCountry(failed, json) {

     if(failed){
       $.cookie('country', "GB" , { expires: 28, path: '/' });
	   $.cookie('currency', "GBP" , { expires: 28, path: '/' });
	  }else{
	   $.cookie('country', json.address.country_code , { expires: 28, path: '/' });
	   $.cookie('currency', currency_codes[json.address.country_code] , { expires: 28, path: '/' });
	  }
	  
	  if($('#curr_dd option[value='+$.cookie('country')+']').length > 0){
	    $('#curr_dd option[value='+$.cookie('country')+']').attr('selected', 'selected');
	  }else{
	    $('select#curr_dd').append('<option value='+$.cookie('country')+'>'+$.cookie('currency')+'</option>');
		$('select#curr_dd option:last').attr('selected','selected');
	  }
	  
	     //add the necessary code to allow for currency conversions
      var cur_symb = "";
      if(currency_symbols[$.cookie('currency')]){
        cur_symb = currency_symbols[$.cookie('currency')];
	    $('.currency').not('.dd').attr('rel', 'GBP:'+$.cookie('currency')+':'+cur_symb);
      }else{
        $('.currency').not('.dd').attr('rel', 'GBP:'+$.cookie('currency'));
      }
      $('.pound_symb').css('display','none');
      $('.currency.dd').attr('rel', 'GBP:'+$('#edit-field-product-currency-und').val());
      $('.dom_fixed').not('.cust').css('display','none');
   
      $('.currency').each(function(i,domEle){$(domEle).convertCurrency(false);return true;}); 
	  
	     //change default currency
      $('#curr_dd').change(function(){
        $.cookie('country', $('#curr_dd option:selected').val() , { expires: 28, path: '/' });
	    $.cookie('currency', currency_codes[$('#curr_dd option:selected').val()] , { expires: 28, path: '/' });
	    location.reload();
      });
   
     
       if($('#curr_dd option[value='+$.cookie('country')+']').length > 0){
	     $('#curr_dd option[value='+$.cookie('country')+']').attr('selected', 'selected');
	   }else{
	    $('select#curr_dd').append('<option value='+$.cookie('country')+'>'+$.cookie('currency')+'</option>');
		$('select#curr_dd option:last').attr('selected','selected');
	  }
	  

}
}
}
})(jQuery);

;
/**
 * Currency (http://www.reality-xp.com)
 * A jQuery plugin for converting currencies
 * 
 * Version 1.0
 * August 27th, 2008
 *
 * Copyright (c) 2008 Reality XP
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 * 
 **/ 
(function ($) {
//on page load call convert
$(document).ready(function(){
 if($.cookie('country')){
   $('.currency').each(function(i,domEle){$(domEle).convertCurrency(false);return true;});
 }
});

;(function(){
	
var $$;

$$ = jQuery.fn.convertCurrency = function(currencycode) {
	var $this = $(this)
	if ($this.attr('rel'))
	{
	  
		var prms = $this.attr('rel').split(':');	/*"USD:EUR:€"*/
		if($this.hasClass('dd')){
		  if($this.next().text() == ""){
		    $this.next().text("0");
		  }
		  var fAmnt = parseFloat($this.next().text().replace(',', ''));
		}else{
		  if($this.text() == ""){
		    $this.text("0");
		  }
		  var fAmnt = parseFloat($this.text().replace(',' , ''));
		}
		var cCode = currencycode ? ' '+prms[1] : '';
		// check if the exchange rate has been retrieved today
		var cookieVal = $.cookie('currencyrate'+prms[0]+prms[1]);
		if (cookieVal != null)
		{
			frmtCurrency($this,prms[2],fAmnt*parseFloat(cookieVal),cCode,prms[1]);
		}
		else
		{
			try {
				reqAjax = $.ajax({
					type: "POST",
					url: '/currency-ajax.php',
					dataType: "json",
					data: "action=rate" + "&currfrom=" + prms[0] + "&currto=" + prms[1],
					success: function(json, textStatus, jqXHR) {
						switch (json.errcode) {
						case 'ERR-100':
							$.cookie('currencyrate'+prms[0]+prms[1],json.result,{expires: 6, path: '/' });
							frmtCurrency($this,prms[2],fAmnt*parseFloat(json.result),cCode,prms[1]);
							break;
						case 'ERR-200':
							break;
						default:
							break
						}
					},
					error: function(xhr, msg, ex) {
						frmtCurrency($this,'&pound;',fAmnt,cCode,'GBP');
					}
				});
			} catch(e) {
			}
		}
	}
	return this;

	function frmtCurrency(ele,symb,val,code,cls) {
		// round the currency to the nearest .05
		val *= 2.0;
		val = val.toFixed(1) / 2.0;
		val = Math.round(val);
		// build the text in the form: '$' '12.35' 'USD'
		if(cls == 'null' || val == '0.00'){
		 ele.prev().css('display','inline-block');
		 return;
		}
		if(symb == null){
		  var txt = val+" "+cls;
		  ele.text(txt );
		}else{
		  ele.html(symb+val+" "+cls );
		}
		// add the currency code to the element class.
		ele.addClass(cls);
		ele.addClass('converted');
	};

};

})();
})(jQuery);;

