/* <![CDATA[ */  
function G(){};
		var GL = new G();
		//
		G.prototype.popupThanks = function(msg, close){
			$('#popupThanks').html(msg);
			$.blockUI({
				message: $('#popupThanks'),
				css: {  
				        padding:        0, 
				        margin:         0, 
				        width:          '30%',  
				        top:            '40%',  
				        left:           '35%',  
				        textAlign:      'center',  
				        color:          '',  
				        border:         '', 
				        backgroundColor:'', 
				        cursor:         'wait' 
				    }
			});
			if(!close){
				setTimeout($.unblockUI, 2000); 
			}
		}

		G.prototype.popupClose = function(){
			$.unBlockUI();
		}
		G.prototype.embedSong = function(path, object){
    		$(object).flash(
    		    { 
    		      src: 'images/flash/mini.swf',
    		      width: 35,
    		      height: 14,
    		      salign: 'tl',
    		      wmode: 'transparent',
    		      flashvars: { lf: path}
    		    },
    		    { version: 8 }
    		);
		}
		G.prototype.cartNotifier = function(s){
		//	alert("yo");
		/*
			if($.cookie('cartPrice') > 0){
				$('.cart-text').text("Du har visst lagt prylar fšr ungefŠr " + $.cookie('cartPrice') + " spŠnn i karschen!");
				$('#cart-notifier').slideDown();
			}else{
				$('#cart-notifier').hide();
			}
			$('.cart-link').unbind('click');
			if(s){
				$('.cart-link').click(function(){
					Shop.viewCart();
				});
			}else{
				$('.cart-link').click(function(){
					location.href = "/varuhuset?showCart=true";
				});
			}
			*/
		}
		/*
		G.prototype.getImage = function(src, size, class){
			
			var cls = "";
			if(class){
				cls = 'class="'+class+'"';
			}
			ret = '<img '+cls+' src="/images/image.php/'+src+'?width='+size+'&height='+size+'&cropratio=1:1&image=/images/uploaded/'+src+'" alt="jhkj" />';
			return ret;
			
		}
	*/
	G.prototype.Slimbox = function(){
		$("a[rel^='lightbox']").slimbox({
			overlayOpacity: .7,
			resizeDuration: 200,
			easing: "easeOutElastic",
			captionAnimationDuration: 0,
			counterText: "Fotografi {x} av {y}",
			closeKeys: [27, 70],
			nextKeys: [39, 83]}, null, function(el) {
			return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
		});
	}
	function loadImage(id, obj, thumb){
		$(obj).css({
			width: thumb[1] + "px"
		});
		var url = "http://picasaweb.google.com/data/entry/api/user/joseelsantos/photoid/"+id+"?alt=json&kind=photo&imgmax="+thumb[0]+"&callback=?";
		$.getJSON(url,function(data){ 
			var picture = data.entry;
			$(obj).attr('href', picture.content.src);
			//console.log($(obj));
			var img = new Image();
			$(img).load(function () {
				$(this).hide();
			    $(obj)
			    	.append(this)
			    	$(this).fadeIn();
				})
			    .error(function () {
			    })
			    .attr({
			    	src: picture.content.src,
			    	rel: 'lightbox',
			    	width: thumb[1]
			    })
		});
	}
	
	function loadThumb(id, obj, thumb){
		//console.log(thumb);
		if(thumb[2]){
			$(obj).css({
				width: thumb[1] + "px",
				height: thumb[2] + "px"
			});
		}else{
			$(obj).css({
				width: thumb[1] + "px"
			});
		}
		
		//
		var url = "http://picasaweb.google.com/data/entry/api/user/joseelsantos/photoid/"+id+"?alt=json&kind=photo&imgmax=512&thumbsize="+thumb[0]+"&callback=?";
		$.getJSON(url,function(data){ 
			var picture = data.entry;
			$(obj).attr('href', picture.content.src);
			var img = new Image();
			$(img)
				.load(function () {
  				$(this).hide()
				$(obj)
				    .append(this)
				    $(this).fadeIn();
				})
				.error(function () {
				})
				.attr({
				    src: picture.media$group.media$thumbnail[0].url,
				    rel: 'lightbox',
				    width: thumb[1],
				    height: thumb[2]
			})
		});
	}
	
	G.prototype.returnSizes = function(obj){
		var ret = new Array();
		if($(obj).hasClass('s32')){
		    ret[0] = "32c";
		    ret[1] = "32";
		    ret[2] = "32";
		}
		if($(obj).hasClass('s48')){
		    ret[0] = "48c";
		    ret[1] = "44";
		    ret[2] = "44";
		}
		if($(obj).hasClass('s72')){
		    ret[0] = "72c";
		    ret[1] = "72";
		    ret[2] = "72";
		}
		if($(obj).hasClass('s90')){
		    ret.push("144c");
		    ret.push("90");
		    ret.push("90");
		}
		if($(obj).hasClass('s144')){
		    ret.push("144c");
		    ret.push("144");
		    ret.push("144");
		}
		if($(obj).hasClass('s376')){
		    ret.push("400");
		    ret.push("376");
		}		
		if($(obj).hasClass('s180')){
		    ret.push("200");
		    ret.push("160");
		}
		return ret;
	}
	G.prototype.SearchImages = function(){
		var to = this;
		$(".g_photo").each(function(i){
			//alert($(this).attr('rel'));
			var thumb = to.returnSizes($(this));
			loadImage($(this).attr('id'), $(this), thumb);
		});	
		$(".g_thumb").each(function(i){
			//alert($(this).attr('rel'));
			var thumb = to.returnSizes($(this));
			loadThumb($(this).attr('id'), $(this), thumb);
		});	
	}
	$(document).ready(function(){
		//GL.cartNotifier(false);
		$('a').focus(function(){
			$(this).blur();
		});
		// Popup
		$("#popupThanks").hide();
		$("#popupImage").hide();
		
		if(typeof window.init_sidebar_newsletter == 'function') {
			init_sidebar_newsletter()
		}
		if(typeof window.init == 'function') {
			init();
		}
		$("textarea").toggleVal({focusClass: "formFocus"});
		$("input").toggleVal({focusClass: "formFocus"});

		$('a.email').each(function(){
			e = this.rel.replace('/','@');
			this.href = 'mailto:' + e;
			//$(this).text();
		});
		//
		$(".tweet").tweet({
          join_text: "auto",
          username: "glesbygdn",
          avatar_size: 10,
          count: 3,
          auto_join_text_default: "-", 
          auto_join_text_ed: "we",
          auto_join_text_ing: "we were",
          auto_join_text_reply: "we replied",
          auto_join_text_url: "we were checking out",
          loading_text: "loading tweets..."
        });
	});
	function markPage(p){
		$('#'+p).addClass("marked");
	}
/* ]]> */ 