//jQuery.noConflict();

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */


jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


/* based on jQuery Image Magnify script v1.1
* This notice must stay intact for usage 
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code

* Nov 16th, 09 (v1.1): Adds ability to dynamically apply/reapply magnify effect to an image, plus magnify to a specific width in pixels.
* Feb 8th, 11 (v1.11): Fixed bug that caused script to not work in newever versions of jQuery (ie: v1.4.4)
*/

//jQuery.noConflict()

jQuery.imageMagnify={
	dsettings: {
		magnifyby: 3, //default increase factor of enlarged image
		magnifyto:400,
		duration: 500, //default duration of animation, in millisec
		imgopacity: 0.5 //opacify of original image when enlarged image overlays it
 	},
	cursorcss: 'url(magnify.cur), -moz-zoom-in', 
	cursorcsssmall: 'url(zoomout.cur) , -moz-zoom-out',
	zIndexcounter: 100,

	refreshoffsets:function($window, $target, warpshell){
		var $offsets=$target.offset();
		var winattrs={x:$window.scrollLeft(), y:$window.scrollTop(), w:$window.width(), h:$window.height()};
		warpshell.attrs.x=$offsets.left; //update x position of original image relative to page
		warpshell.attrs.y=$offsets.top;
		warpshell.newattrs.x=winattrs.x+winattrs.w/2-warpshell.newattrs.w/2;
		warpshell.newattrs.y=winattrs.y+winattrs.h/2-warpshell.newattrs.h/2;
		if (warpshell.newattrs.x<winattrs.x+5){ //no space to the left?
			warpshell.newattrs.x=winattrs.x+5;	
		}
		else if (warpshell.newattrs.x+warpshell.newattrs.w > winattrs.x+winattrs.w){//no space to the right?
			warpshell.newattrs.x=winattrs.x+5;
		}
		if (warpshell.newattrs.y<winattrs.y+5){ //no space at the top?
			warpshell.newattrs.y=winattrs.y+5;
		}
	},
    // this does the magify on the passed target ref so can be used elsewhere
 	magnify:function($, $target, options){
		var setting={}; //create blank object to store combined settings
		var setting=jQuery.extend(setting, this.dsettings, options);
		var attrs=(options.thumbdimensions)? {w:options.thumbdimensions[0], h:options.thumbdimensions[1]} : {w:$target.outerWidth(), h:$target.outerHeight()};
		var newattrs={};
		var bigtitle=$target.attr('alt');
		newattrs.w=(setting.magnifyto)? setting.magnifyto : Math.round(attrs.w*setting.magnifyby);
		newattrs.h=(setting.magnifyto)? Math.round(attrs.h*newattrs.w/attrs.w) : Math.round(attrs.h*setting.magnifyby);
		$target.css('cursor', jQuery.imageMagnify.cursorcss);
		if ($target.data('imgshell')){
			$target.data('imgshell').$clone.remove();
			$target.css({opacity:1}).unbind('click.magnify');
		}	
		// this key ie clone orig img and hide it for the moment rel idicates a different image that will have to be fetched!
		
		var $clone=$target.clone().css({position:'absolute', left:0, top:0, visibility:'hidden', border:'1px solid gray', cursor:'pointer'}).appendTo(document.body);
		
		
		$clone.attr('title', bigtitle);
		$clone.data('$relatedtarget', $target) //save $target image this enlarged image is associated with
		$target.data('imgshell', {$clone:$clone, attrs:attrs, newattrs:newattrs});
		$target.bind('click.magnify', function(e){ 
			var $this=$(this).css({opacity:setting.imgopacity});
			var imageinfo=$this.data('imgshell');
			jQuery.imageMagnify.refreshoffsets($(window), $this, imageinfo); //refresh offset positions of original and warped images
			var $clone=imageinfo.$clone;
			$clone.stop().css({zIndex:++jQuery.imageMagnify.zIndexcounter, left:imageinfo.attrs.x, top:imageinfo.attrs.y, width:imageinfo.attrs.w, height:imageinfo.attrs.h, opacity:0, visibility:'visible', display:'block'})
			.animate({opacity:1, left:imageinfo.newattrs.x, top:imageinfo.newattrs.y, width:imageinfo.newattrs.w, height:imageinfo.newattrs.h}, setting.duration,
			function(){ //callback function after warping is complete
			
			    //none added ADD Title and close icon etc 		
				$clone.css({opacity:1.0}); 
				
				$clone.css({ border:'10px solid white'}); 
				$clone.css('cursor', jQuery.imageMagnify.cursorcsssmall);
				
				//$clone.wrap('<div class="bigcaption" ></div>').after('<img style="position: absolute; left: 0; top: 0; z-index:100;" title="click to close" src="/media/images/graphics/icons/reduce.png">');
                // this goes into end of above chain ? $clone.css({width: $(this).siblings('img').width() -10 , opacity: 0.6, display: 'block'});
                // .after('<div><span class="bold"><img title="click to enlarge" class="enlarger"  src="/media/images/graphics/icons/reduce.png">' + $(this).attr('alt') + '</span></div>')
   
                $clone.addClass( 'shadow' );

				
			}); //end animate
		}) //end click
		$clone.click(function(e){ //action when magnified image is clicked on
			var $this=$(this);
			var imageinfo=$this.data('$relatedtarget').data('imgshell');
			jQuery.imageMagnify.refreshoffsets($(window), $this.data('$relatedtarget'), imageinfo) //refresh offset positions of original and warped images
			$this.stop().animate({opacity:0, left:imageinfo.attrs.x, top:imageinfo.attrs.y, width:imageinfo.attrs.w, height:imageinfo.attrs.h},  setting.duration,
			function(){
				$this.hide();
				$this.data('$relatedtarget').css({opacity:1}); //reveal original image
			}) //end animate
		}) //end click
	}
};

jQuery.fn.imageMagnify=function(options){
	var $=jQuery;
	return this.each(function(){ //return jQuery obj
		var $imgref=$(this);
		if (this.tagName!="IMG")
			return true //skip to next matched element
		if (parseInt($imgref.css('width'))>0 && parseInt($imgref.css('height'))>0 || options.thumbdimensions){ //if image has explicit width/height attrs defined
			jQuery.imageMagnify.magnify($, $imgref, options);
		}
		else if (this.complete){ //account for IE not firing image.onload
			jQuery.imageMagnify.magnify($, $imgref, options);
		}
		else{
			$(this).bind('load', function(){
				jQuery.imageMagnify.magnify($, $imgref, options);
			})
		}
	})
};

jQuery.fn.applyMagnifier=function(options){ //dynamic version of imageMagnify() to apply magnify effect to an image dynamically
	var $=jQuery;
	return this.each(function(){ //return jQuery obj
		var $imgref=$(this);
		if (this.tagName!="IMG")
			return true; //skip to next matched element
		
	})	

};


//** The following applies the magnify effect to images with class="magnify" and optional "data-magnifyby" and "data-magnifyduration" attrs
//** It also looks for links with attr rel="magnify[targetimageid]" and makes them togglers for that image

// can use another trigger instead of .magnify




/*
	jquery.fbjlike.js - http://socialmediaautomat.com/jquery-fbjlike-js.php
	based on: jQuery OneFBLike v1.1 - http://onerutter.com/open-source/jquery-facebook-like-plugin.html
	Copyright (c) 2010 Jake Rutter modified 2011 by Stephan Helbig
	This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.
*/

(function($){  
$.fn.fbjlike = function(options) {  
	
  //Set the default values, use comma to separate the settings 
  var defaults = {  
	appID: '147921828636160',
	userID: '',
	siteTitle: '',
	siteName: '',
	siteImage: '',
	href:false,
	mode: 'insert',
	buttonWidth: 450,
	buttonHeight: 60,
	showfaces: false,
	font: 'lucida grande',
	layout: 'standard',	//normal , box_count|button_count|standard
	action: 'like',		
	send:false,
	comments:false,
	numPosts:10,
	colorscheme: 'light',
	lang: 'en_GB',
	hideafterlike:false,
	googleanalytics:false,							
	googleanalytics_obj: 'pageTracker',	
	onlike: function(){return true;},
	onunlike: function(){return true;}
}  

var options =  $.extend(defaults, options);  
	
  return this.each(function() {  
  var o = options;  
  var obj = $(this);
  if(!o.href)
  	var dynUrl = document.location;
  else
  	var dynUrl = o.href;
  var dynTitle = document.title;
  
 
  
  // Add Meta Tags for additional data - options
  if(o.appID!='')$('head').append('<meta property="fb:app_id" content="'+o.appID+'"/>');
  if(o.userID!='')$('head').append('<meta property="fb:admins" content="'+o.userID+'"/>');
  if(o.siteTitle!='')$('head').append('<meta property="og:title" content="'+o.siteTitle+'"/>');
  if(o.siteName!='')$('head').append('<meta property="og:site_name" content="'+o.siteName+'"/>');
  if(o.siteImage!='')$('head').append('<meta property="og:image" content="'+o.siteImage+'"/>');
  
 

  
  // Add #fb-root div - mandatory - do not remove
  $('body').append('<div id="fb-root"></div>');
  $('#fb-like iframe').css('height','35px !important');
  
  (function() {
    var e = document.createElement('script');
    e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/'+o.lang+'/all.js';
    $('#fb-root').append(e);
  }());
	
  // setup FB Developers App Link - do not touch
  window.fbAsyncInit = function() {
    FB.init({appId: o.appID, status: true, cookie: true, xfbml: true});
    FB.Event.subscribe('edge.create', function(response) {
		  if(o.hideafterlike)$(obj).hide();
		  if(o.googleanalytics){
				if(o.googleanalytics_obj!='_gaq'){
					pageTracker._trackEvent('facebook', 'liked', dynTitle);
				} else {
		  		_gaq.push(['_trackEvent','facebook', 'liked', dynTitle]);
		  	}
		  }
		  o.onlike.call(response);
		});
    FB.Event.subscribe('edge.remove', function(response) {
		  if(o.googleanalytics){
				if(o.googleanalytics_obj!='_gaq'){
					pageTracker._trackEvent('facebook', 'unliked', dynTitle);
				} else {
		  		_gaq.push(['_trackEvent','facebook', 'unliked', dynTitle]);
		  	}
		  }
		  o.onunlike.call(response);
		});
  };
  var tSend = '';
  if(o.send)tSend = ' send="true"';
  var thtml = '<fb:like href="'+dynUrl+'" width="'+o.buttonWidth+'" height="'+o.buttonHeight+'" show_faces="'+o.showfaces+'" font="'+o.font+'" layout="'+o.layout+'" action="'+o.action+'" colorscheme="'+o.colorscheme+'"'+tSend+'/>';
  
	if(o.comments){
  	thtml += '<'+'div style="clear:both;"></div><fb:comments href="'+dynUrl+'" num_posts="'+o.numPosts+'" width="'+o.buttonWidth+'"></fb:comments>';
  }
  if(o.mode=='append')$(obj).append(thtml);
  else $(obj).html(thtml);
	
  });  
}  
})(jQuery);


/*!
 * http://www.shamasis.net/projects/ga/
 * Refer jquery.ga.debug.js
 * Revision: 13 V2.x
 */
(function($){$.ga={};$.ga.load=function(uid,callback){jQuery.ajax({type:'GET',url:(document.location.protocol=="https:"?"https://ssl":"http://www")+'.google-analytics.com/ga.js',cache:true,success:function(){if(typeof _gat==undefined){throw"_gat has not been defined";}t=_gat._getTracker(uid);bind();if($.isFunction(callback)){callback(t)}t._trackPageview()},dataType:'script',data:null})};var t;var bind=function(){if(noT()){throw"pageTracker has not been defined";}for(var $1 in t){if($1.charAt(0)!='_')continue;$.ga[$1.substr(1)]=t[$1]}};var noT=function(){return t==undefined}})(jQuery);


 
jQuery(document).ready(function(){	
	
	jQuery('div.titledthumb img').each(function() {
  
   		var title = $(this).attr('alt');
   		if (title == "")  title = "&nbsp;";
   		jQuery(this).addClass('magnify');
    	jQuery(this).wrap('<div class="caption"></div>').after('<div>' + title + '</div>').before('<img class="mag" title="Click photo to enlarge" src="/media/images/graphics/icons/magnify.png">');
    
        jQuery('.caption').width(jQuery(this).width()).children('div').each(function() {
      			jQuery(this).css({width: $(this).siblings('img.magnify').width() -10 , opacity: 0.6, display: 'block'});
    	});
    
  	});
  	
  	var $targets=$('.magnify');
	
    $targets.each(function(i){
		var $target=$(this);
		var options={};
		if ($target.attr('data-magnifyto'))
			options.magnifyto=parseFloat($target.attr('data-magnifyto'));
		if ($target.attr('data-magnifyby'))
			options.magnifyby=parseFloat($target.attr('data-magnifyby'));
		if ($target.attr('data-magnifyduration'))
			options.duration=parseInt($target.attr('data-magnifyduration'));
		$target.imageMagnify(options);
	});
	
  	
  	$(function () {
		var scrollDiv = document.createElement('div');
		$(scrollDiv).attr('id', 'toTop').html('^ Back to Top').appendTo('body');
		if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
			{
				$("#toTop").css("position", "static");
		};    
		$(window).scroll(function () {
		        if ($(this).scrollTop() != 0) {
		            $('#toTop').fadeIn();
		        } else {
		            $('#toTop').fadeOut();
		        }
		    });
		    $('#toTop').click(function () {
		        $('body,html').animate({
		            scrollTop: 0
		        },
		        800);
		    });
	});
		
  	$('#fbjlike').fbjlike();
  	
  	$.ga.load("UA-157077-4", function(pageTracker) {
			pageTracker._setDomainName("www.mymenorca.info");}
			
	 ); 
  	
  	
	
});	





		
	
  	


