/* 	
	Index of this JS File

	(01) Top Bar left and right menu hover jQuery effects
	(02) Flickr Photos
	(03) Portfolio & Blog Image Hover Zoom, Details icons and effects
	(04) Pretty Photo and Hide Boxes
	(05) Top Menu Settings
	(06) Rotate Content - Footer Testimonials and Additional Footer Quotes
	(07) Tab Script
	(08) Simple and Accordation Toggles
	(09) Hide Information Boxes (Close Button)
	(10) Filterable Pack / Sortable Portfolio
	(11) Testimonial Rotator
	(12) Image Hover Fade Effect
	(13) Custom Popup
	(14) Contact Form
	(16) Search Form
	(17) Tooltip
	(18) Twitter Updates
	(19) Ordered List
	(20) Custom Popup	
*/

/* ========================================================== 
	(01) Top Bar left and right menu hover jQuery effects
============================================================ */

$(document).ready(function(){
   $("#top-bar-right ul li").fadeTo("normal", 0.3);
   $("#top-bar-right ul li").hover(function(){
   $(this).fadeTo("normal", .8);
   },function(){
   $(this).fadeTo("normal", 0.3);
   });
});
						   
$(document).ready(function(){
   $("#top-bar-left ul li").fadeTo("normal", 0.5);
   $("#top-bar-left ul li").hover(function(){
   $(this).fadeTo("normal", 1.0);
   },function(){
   $(this).fadeTo("normal", 0.5);
   });
});

/* ========================================================== 
	(02) Flickr Photos
============================================================ */

$(document).ready(function(){	
	$('#cbox').jflickrfeed({
		limit: 6,
		qstrings: {
			id: '52031461@N05'  /* << Replace your flickr id with theme flickr sample id */
			
			/* How to find my flickr User ID?
			You can find your flickr id from this URL : http://www.flickr.com/services/api/explore/?method=flickr.people.getInfo
			Login to your flickr account and then go to above URL. You will find your flickr id from right side in "Useful Values" section. */			
			
		},
		itemTemplate: '<li>'+
						'<a class="fade-img2" href="{{image}}" title="{{title}}" rel="prettyPhoto[flickrGallery123]">' +
							'<img src="{{image_s}}" alt="{{title}}" />' +
						'</a>' +
					  '</li>'
	}, function(data) {
		$('#cbox a').prettyPhoto();
	});
});

/* ========================================================================= 
	(03) Portfolio & Blog Image Hover Zoom, Details icons and effects
============================================================================ */

jQuery(document).ready(function() {	
	
	var $portfolioImage = jQuery('.img-one-full,.img-one-half,.img-one-third,.img-one-fourth,.blog1-post-img,.blog2-post-img,.blog-single-img');	
	
	$portfolioImage.hover(function(){
		jQuery(this).find('img.portfolio-image').stop(true, true).animate({opacity: 0.8},400);			
	}, function(){		
		jQuery(this).find('img.portfolio-image ').stop(true, true).animate({opacity: 1},400);			
	});	
	
	var $portfolio1Column = jQuery('.img-one-full');	
	var $portfolio2Column = jQuery('.img-one-half');	
	var $portfolio3Column = jQuery('.img-one-third');	
	var $portfolio4Column = jQuery('.img-one-fourth');	
	var $blog1PostImg = jQuery('.blog1-post-img');	
	var $blog2PostImg = jQuery('.blog2-post-img');	
	var $blogSinglePage = jQuery('.blog-single-img');	
	
	jQuery('.zoom-icon, .details-icon').css({'opacity':'0','visibility':'visible'});
	
	$portfolio1Column.hover(function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 1, left: 238},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1, left: 290},400);
	}, function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 0, left: 200},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0, left: 326},400);	
	});
	
	$portfolio2Column.hover(function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 1, left: 187},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1, left: 237},400);
	}, function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 0, left: 150},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0, left: 273},400);		
	});
	
	$portfolio3Column.hover(function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 1, left: 104},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1, left: 154},400);
	}, function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 0, left: 70},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0, left: 181},400);		
	});
	
	$portfolio4Column.hover(function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 1, left: 63},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1, left: 113},400);
	}, function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 0, left: 28},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0, left: 148},400);		
	});
	
	$blog1PostImg.hover(function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 1, left: 55},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1, left: 105},400);
	}, function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 0, left: 23},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0, left: 138},400);		
	});
	
	$blog2PostImg.hover(function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 1, left: 229},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1, left: 281},400);
	}, function(){			
		jQuery(this).find('.details-icon').stop(true, true).animate({opacity: 0, left: 156},400);
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0, left: 355},400);		
	});
	
	$blogSinglePage.hover(function(){			
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1},400);
	}, function(){					
		jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0},400);		
	});

});

/* ========================================================== 
	(04) Pretty Photo and Hide Boxes
============================================================ */

$(document).ready(function(){ 
	$("a[rel^='prettyPhoto']").prettyPhoto(); 	 /* Pretty Photo */
	hide_boxes();					 /* Infoboxes close button */	
});

/* ========================================================== 
	(05) Top Menu Settings
============================================================ */

$(document).ready(function(){ 
	$("ul.sf-menu").supersubs({ 
		minWidth:    7,   // minimum width of sub-menus in em units 
		maxWidth:    77,   // maximum width of sub-menus in em units 
		extraWidth:  -1    // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family 
	}).superfish();  // call supersubs first, then superfish, so that subs are 
					 // not display:none when measuring. Call before initialising 
					 // containing tabs for same reason. 
});

/* ============================================================================ 
	(06) Rotate Content - Footer Testimonials and Additional Footer Quotes
=============================================================================== */

$(document).ready(function() {					
	$('.rotate-content').quote_rotator({						
		rotation_speed: 8000,
		pause_on_hover: true,						
		buttons: true
	});
	$('.slide-quotes').quote_rotator({						
		rotation_speed: 5000,						
		pause_on_hover: true,						
		buttons: true
	});
});

/* ========================================================== 
	(07) Tab Script
============================================================ */

$(document).ready(function() {

	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

});

/* ========================================================== 
	(08) Simple and Accordation Toggles
============================================================ */

$(document).ready(function(){	
	// Simple Toggle script start
	$(".toggle_container").hide();
	$("p.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle(350);
	});
	
	$(".toggle_container2").hide();
	$("p.trigger2").click(function(){
		$(this).toggleClass("active2").next().slideToggle(350);
	});
	
	//--Toggle Accrordation Script
	
	//Set default open/close settings
	$('.acc_container').hide(); //Hide/close all containers
	//$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

	//On Click
	$('.acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
			//$(this).toggleClass('active').previous().slideUp(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
			$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container	
		}else{
			$(this).toggleClass('active').next().slideUp();
		}
		return false; //Prevent the browser jump to the link anchor
	});
	
	//Set default open/close settings
	$('.acc_container2').hide(); //Hide/close all containers
	//$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

	//On Click
	$('.acc_trigger2').click(function(){
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('.acc_trigger2').removeClass('active2').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
			$(this).toggleClass('active2').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container	
		}else{
			$(this).toggleClass('active2').next().slideUp();
		}
		return false; //Prevent the browser jump to the link anchor
	});
	
});

/* ========================================================== 
	(09) Hide Information Boxes (Close Button)
============================================================ */

$(document).ready(function(){ 	
	hide_boxes();
});

function hide_boxes(){
	$('span.hide-boxes,span.hide-boxes2').click(function() {
		$(this).parent().fadeOut();					   
	});	
}

/* ========================================================== 
	(10) Filterable Pack / Sortable Portfolio
============================================================ */
$(function(){
	$('.sortablePortfolio').mobilyselect({
		collection: 'all',
		animation: 'fade',
		duration: 300,
		listClass: 'sortableContent',
		btnsClass: 'sortableLinks',
		btnActiveClass: 'active',
		elements: 'li',
		onChange: function(){},
		onComplete: function(){}
	});
});	
/* ========================================================== 
	(11) Testimonial Rotator
============================================================ */

$(document).ready(function(){
	$('#testimonials-rotate .testimonial-slide');
	setInterval(function(){
		$('#testimonials-rotate .testimonial-slide').filter(':visible').fadeOut(1000,function(){
			if($(this).next('div.testimonial-slide').size()){
				$(this).next().fadeIn(1000);
			}
			else{
				$('#testimonials-rotate .testimonial-slide').eq(0).fadeIn(1000);
			}
		});
	},6000); // fadein fadeout slider delay time eg. 1000 it less and 10000 is more.	
});

/* ========================================================== 
	(12) Image Hover Fade Effect
============================================================ */

jQuery(window).load(function() { 	
	jQuery(".fade-img").show();
	jQuery(".fade-img img").fadeTo('normal', 1, function() {		
		$get_id = jQuery(this).parent().parent().attr("lang");
		if($get_id != ""){
			jQuery(this).parent().parent().addClass($get_id);			
			$(this).hover(function(){
				$(this).fadeTo('normal', 0.2);
				
			}, function() {
					$(this).fadeTo('normal', 1);
			});
		}
    });
});

jQuery(window).load(function() { 	
	jQuery(".fade-img2").show();
	jQuery(".fade-img2 img").fadeTo('normal', 1, function() {		
		$get_id = jQuery(this).parent().parent().attr("lang");
		if($get_id != ""){
			jQuery(this).parent().parent().addClass($get_id);			
			$(this).hover(function(){
				$(this).fadeTo('normal', 0.5);
				
			}, function() {
					$(this).fadeTo('normal', 1);
			});
		}
    });
});

/* ========================================================== 
	(13) Custom Popup
============================================================ */

$(document).ready(function() {

//When you click on a link with class of poplight and the href starts with a # 
$('a.poplight[href^=#]').click(function() {
    var popID = $(this).attr('rel'); //Get Popup Name
    var popURL = $(this).attr('href'); //Get Popup href to define size

    //Pull Query & Variables from href URL
    var query= popURL.split('?');
    var dim= query[1].split('&');
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value

    //Fade in the Popup and add close button
    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close" title="Close"><span class="btn_close">Close</span></a>');

    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    //Apply Margin to Popup
    $('#' + popID).css({
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    //Fade in Background
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
    $('#fade').css({'filter' : 'alpha(opacity=30)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=30)'}) is used to fix the IE Bug on fading transparencies 

    return false;
});

//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  //fade them both out
    });
    return false;
});

});

/* ========================================================== 
	(14) Contact Form
============================================================ */

jQuery(document).ready(function(){	
	jQuery("input:text, input:password, textarea").forminput();
	jQuery("#contact_form").contact_form({
			response: "#msg",
			submit: "#submit",
			timer: 4500,
			easing: "",
			speedIn: 700,
			speedOut: 700
	});
});
// Input Field Script
(function($) {
	$.fn.forminput = function() {
		return this.each(function() {
			var $root = $(this);
			var inputValue = $root.val();
			
			function reset() {
				var value = $root.val();
				if(inputValue == value) {
					$root.val("");
				}
			}
			
			function blur() {
				var value = $root.val();
				if(value == "") {
					$root.val(inputValue);
				}
			}
			
			$root.focus(function() {
  				reset();
			});
			$root.blur(function() {
  				blur();
			});
		});
	}
})(jQuery);

// Form Script
(function($) {
	$.fn.contact_form = function(options) {
		var defaults = {
			response: "#msg",
			submit: "#submit",
			timer: 4500,
			easing: "",
			speedIn: 700,
			speedOut: 700
		};
		var options = $.extend({}, defaults, options);
		
		return this.each(function () {
			var $root = $(this);
			var $response = $(options.response);
			var $submit = $(options.submit);
			
			function showMsg($timer) {
				$response.css("opacity", 0);
				$response.show().stop().animate({
					opacity: 1
				}, options.speedIn, options.easing, function(){
					interval = setInterval(hideMsg, $timer);
				});
			}
			
			function hideMsg() {
				clearInterval(interval);
				$response.stop().animate({
					opacity:0
				}, options.speedIn, options.easing, function() {
					$response.hide();
					$submit.fadeIn(700);
				});
			}
			
			$root.submit(function(){
				$.ajax({
					type: "POST",
					url: "sendmail.php",
					data: $(this).serialize(),
					success: function(output) {
						$response.ajaxComplete(function() {
							if(output == 'ok') {
								$('#contactdiv').html("<div id='smessage'></div>");
								$('#smessage').html("<h3>Заявка отправлена!</h3>").append("<p>Спасибо! В близжайшее время наш менеджер свяжется с вами.</p>").hide().fadeIn(1500, function() {
								  $('#smessage').append("");
								});
							} else {
								$(this).html(output);
								showMsg(options.timer);
							}
						});
					}
				});
				return false;
			});
		});
	}
})(jQuery);
	
/* ========================================================== 
	(16) Search Form
============================================================ */	
	
jQuery(document).ready(function(){	
	jQuery("#search-input-box").css({"left" : "2px", "display" : "none"});	
	jQuery("#search-icon").click(function(){						 
			if (jQuery("#search-input-box").filter(':hidden').length == 1)	
				jQuery(this).next("#search-input-box").animate({left: "8px", opacity: "toggle"}, "slow")
			else
				jQuery(this).next("#search-input-box").animate({left: "8px", opacity: "toggle"}, "slow")
			return false;
	});		
	
	var $searchinput = jQuery("#search-input-box input");
	var $searchvalue = $searchinput.val();		
	$searchinput.focus(function(){
		if (jQuery(this).val() == $searchvalue) jQuery(this).val("");
	}).blur(function(){
		if (jQuery(this).val() == "") jQuery(this).val($searchvalue);
	});
});	

/* ========================================================== 
	(17) Tooltip
============================================================ */

$(function() {
    
    $('.tipDown').tipsy		({gravity: 'n'});
    $('.tipUp').tipsy		({gravity: 's'});
    $('.tipLeft').tipsy		({gravity: 'e'});
    $('.tipRight').tipsy	({gravity: 'w'});
	$('.tipForm').tipsy		({gravity: 's', trigger:'focus'}); 
    
  });

(function($){$.fn.tipsy=function(options){options=$.extend({},$.fn.tipsy.defaults,options);return this.each(function(){var opts=$.fn.tipsy.elementOptions(this,options);$(this).hover(function(){$.data(this,"cancel.tipsy",true);var tip=$.data(this,"active.tipsy");if(!tip){tip=$('<div class="tipsy"><div class="tipsy-inner"/></div>');tip.css({position:"absolute",zIndex:100000});$.data(this,"active.tipsy",tip);}if($(this).attr("title")||typeof($(this).attr("original-title"))!="string"){$(this).attr("original-title",$(this).attr("title")||"").removeAttr("title");}var title;if(typeof opts.title=="string"){title=$(this).attr(opts.title=="title"?"original-title":opts.title);}else{if(typeof opts.title=="function"){title=opts.title.call(this);}}tip.find(".tipsy-inner")[opts.html?"html":"text"](title||opts.fallback);var pos=$.extend({},$(this).offset(),{width:this.offsetWidth,height:this.offsetHeight});tip.get(0).className="tipsy";tip.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).appendTo(document.body);var actualWidth=tip[0].offsetWidth,actualHeight=tip[0].offsetHeight;var gravity=(typeof opts.gravity=="function")?opts.gravity.call(this):opts.gravity;switch(gravity.charAt(0)){case"n":tip.css({top:pos.top+pos.height,left:pos.left+pos.width/2-actualWidth/2}).addClass("tipsy-north");break;case"s":tip.css({top:pos.top-actualHeight,left:pos.left+pos.width/2-actualWidth/2}).addClass("tipsy-south");break;case"e":tip.css({top:pos.top+pos.height/2-actualHeight/2,left:pos.left-actualWidth}).addClass("tipsy-east");break;case"w":tip.css({top:pos.top+pos.height/2-actualHeight/2,left:pos.left+pos.width}).addClass("tipsy-west");break;}if(opts.fade){tip.css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:0.8});}else{tip.css({visibility:"visible"});}},function(){$.data(this,"cancel.tipsy",false);var self=this;setTimeout(function(){if($.data(this,"cancel.tipsy")){return;}var tip=$.data(self,"active.tipsy");if(opts.fade){tip.stop().fadeOut(function(){$(this).remove();});}else{tip.remove();}},100);});});};$.fn.tipsy.elementOptions=function(ele,options){return $.metadata?$.extend({},options,$(ele).metadata()):options;};$.fn.tipsy.defaults={fade:true,fallback:"",gravity:"n",html:true,title:"title"};$.fn.tipsy.autoNS=function(){return $(this).offset().top>($(document).scrollTop()+$(window).height()/2)?"s":"n";};$.fn.tipsy.autoWE=function(){return $(this).offset().left>($(document).scrollLeft()+$(window).width()/2)?"e":"w";};})(jQuery);

/* ========================================================== 
	(18) Twitter Updates
============================================================ */

$(function(){ $(".example").each(function(i, e){ eval($(e).text()); }); 

$(".twitter-feeds1").tweet({ 
	username: "rybinskcity",
	count: 1,
	template: "{avatar}{join}{text}{time}"
	});

});			
		
(function($) {

  $.fn.tweet = function(o){
    var s = $.extend({
      username: "rybinskcity",                 // Replace current TWITTER USER ID with your user id
	  count: 2,                                 // [integer]  how many tweets to display?
      loading_text: "Loading Tweets...",        // [string]   optional loading text, displayed while tweets load
	  avatar_size: null,                        // [integer]  height and width of avatar if displayed (48px max)
	  list: null,                               // [string]   optional name of list belonging to username
      favorites: false,                         // [boolean]  display the user's favorites instead of his tweets
      query: null,                              // [string]   optional search query            
      fetch: null,                              // [integer]  how many tweets to fetch via the API (set this higher than 'count' if using the 'filter' option)
      retweets: true,                           // [boolean]  whether to fetch (official) retweets (not supported in all display modes)
      intro_text: null,                         // [string]   do you want text BEFORE your your tweets?
      outro_text: null,                         // [string]   do you want text AFTER your tweets?
	  join_text: "auto",	                    // [string]   optional text in between date and tweet, try setting to "auto"
      auto_join_text_default: "",    		    // [string]   auto text for non verb: "i said" bullocks
      auto_join_text_ed: "",                    // [string]   auto text for past tense: "i" surfed
      auto_join_text_ing: "",           	    // [string]   auto tense for present tense: "i was" surfing
      auto_join_text_reply: "",    				// [string]   auto tense for replies: "i replied to" @someone "with"
      auto_join_text_url: "",   				// [string]   auto tense for urls: "i was looking at" http:...     
      refresh_interval: null ,                  // [integer]  optional number of seconds after which to reload tweets
      twitter_url: "twitter.com",               // [string]   custom twitter url, if any (apigee, etc.)
      twitter_api_url: "api.twitter.com",       // [string]   custom twitter api url, if any (apigee, etc.)
      twitter_search_url: "search.twitter.com", // [string]   custom twitter search url, if any (apigee, etc.)
      template: "{avatar}{join}{time}{text}",   // [string or function] template used to construct each tweet <li> - see code for available vars
      comparator: function(tweet1, tweet2) {    // [function] comparator used to sort tweets (see Array.sort)
        return tweet2["tweet_time"] - tweet1["tweet_time"];
      },
      filter: function(tweet) {                 // [function] whether or not to include a particular tweet (be sure to also set 'fetch')
        return true;
      }
    }, o);

    $.fn.extend({linkUrl:function(){var returning=[];var regexp=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi;this.each(function(){returning.push(this.replace(regexp,function(match){var url=(/^[a-z]+:/i).test(match)?match:"http://"+match;return"<a href=\""+url+"\">"+match+"</a>"}))});return $(returning)},linkUser:function(){var returning=[];var regexp=/[\@]+(\w+)/gi;this.each(function(){returning.push(this.replace(regexp,"@<a href=\"http://"+s.twitter_url+"/$1\">$1</a>"))});return $(returning)},linkHash:function(){var returning=[];var regexp=/(?:^| )[\#]+([\w\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0600-\u06ff]+)/gi;var usercond=(s.username&&s.username.length==1)?'&from='+s.username.join("%2BOR%2B"):'';this.each(function(){returning.push(this.replace(regexp,' <a href="http://'+s.twitter_search_url+'/search?q=&tag=$1&lang=all'+usercond+'">#$1</a>'))});return $(returning)},capAwesome:function(){var returning=[];this.each(function(){returning.push(this.replace(/\b(awesome)\b/gi,'<span class="awesome">$1</span>'))});return $(returning)},capEpic:function(){var returning=[];this.each(function(){returning.push(this.replace(/\b(epic)\b/gi,'<span class="epic">$1</span>'))});return $(returning)},makeHeart:function(){var returning=[];this.each(function(){returning.push(this.replace(/(&lt;)+[3]/gi,"<tt class='heart'>&#x2665;</tt>"))});return $(returning)}});function parse_date(date_str){return Date.parse(date_str.replace(/^([a-z]{3})( [a-z]{3} \d\d?)(.*)( \d{4})$/i,'$1,$2$4$3'))}function relative_time(date){var relative_to=(arguments.length>1)?arguments[1]:new Date();var delta=parseInt((relative_to.getTime()-date)/1000,10);var r='';if(delta<60){r=delta+' секунд назад'}else if(delta<120){r='минут назад'}else if(delta<(45*60)){r=(parseInt(delta/60,10)).toString()+' минут назад'}else if(delta<(2*60*60)){r='часа назад'}else if(delta<(24*60*60)){r=''+(parseInt(delta/3600,10)).toString()+' часов назад'}else if(delta<(48*60*60)){r='дня назад'}else{r=(parseInt(delta/86400,10)).toString()+' дней назад'}return' // &nbsp;около '+r}function build_url(){var proto=('https:'==document.location.protocol?'https:':'http:');var count=(s.fetch===null)?s.count:s.fetch;if(s.list){return proto+"//"+s.twitter_api_url+"/1/"+s.username[0]+"/lists/"+s.list+"/statuses.json?per_page="+count+"&callback=?"}else if(s.favorites){return proto+"//"+s.twitter_api_url+"/favorites/"+s.username[0]+".json?count="+s.count+"&callback=?"}else if(s.query===null&&s.username.length==1){return proto+'//'+s.twitter_api_url+'/1/statuses/user_timeline.json?screen_name='+s.username[0]+'&count='+count+(s.retweets?'&include_rts=1':'')+'&callback=?'}else{var query=(s.query||'from:'+s.username.join(' OR from:'));return proto+'//'+s.twitter_search_url+'/search.json?&q='+encodeURIComponent(query)+'&rpp='+count+'&callback=?'}}return this.each(function(i,widget){var list=$('<ul class="tweet_list">').appendTo(widget);var intro='<p class="tweet_intro">'+s.intro_text+'</p>';var outro='<p class="tweet_outro">'+s.outro_text+'</p>';var loading=$('<p class="loading">'+s.loading_text+'</p>');if(s.username&&typeof(s.username)=="string"){s.username=[s.username]}var expand_template=function(info){if(typeof s.template==="string"){var result=s.template;for(var key in info){var val=info[key];result=result.replace(new RegExp('{'+key+'}','g'),val===null?'':val)}return result}else return s.template(info)};if(s.loading_text)$(widget).append(loading);$(widget).bind("load",function(){$.getJSON(build_url(),function(data){if(s.loading_text)loading.remove();if(s.intro_text)list.before(intro);list.empty();var tweets=$.map(data.results||data,function(item){var join_text=s.join_text;if(s.join_text=="auto"){if(item.text.match(/^(@([A-Za-z0-9-_]+)) .*/i)){join_text=s.auto_join_text_reply}else if(item.text.match(/(^\w+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+) .*/i)){join_text=s.auto_join_text_url}else if(item.text.match(/^((\w+ed)|just) .*/im)){join_text=s.auto_join_text_ed}else if(item.text.match(/^(\w*ing) .*/i)){join_text=s.auto_join_text_ing}else{join_text=s.auto_join_text_default}}var screen_name=item.from_user||item.user.screen_name;var source=item.source;var user_url="http://"+s.twitter_url+"/"+screen_name;var avatar_size=s.avatar_size;var avatar_url=item.profile_image_url||item.user.profile_image_url;var tweet_url="http://"+s.twitter_url+"/"+screen_name+"/status/"+item.id_str;var retweet=(typeof(item.retweeted_status)!='undefined');var retweeted_screen_name=retweet?item.retweeted_status.user.screen_name:null;var tweet_time=parse_date(item.created_at);var tweet_relative_time=relative_time(tweet_time);var tweet_raw_text=retweet?('RT @'+retweeted_screen_name+' '+item.retweeted_status.text):item.text;var tweet_text=$([tweet_raw_text]).linkUrl().linkUser().linkHash()[0];var user='<a class="tweet_user" href="'+user_url+'">'+screen_name+'</a>';var join=((s.join_text)?('<span class="tweet_join"> '+join_text+' </span>'):' ');var avatar=(avatar_size?('<a class="tweet_avatar" href="'+user_url+'"><img src="'+avatar_url+'" height="'+avatar_size+'" width="'+avatar_size+'" alt="'+screen_name+'\'s avatar" title="'+screen_name+'\'s avatar" border="0"/></a>'):'');var time='<span class="tweet_time"><a href="'+tweet_url+'" title="view tweet on twitter">'+tweet_relative_time+'</a></span> ';var text='<span class="tweet_text">'+$([tweet_text]).makeHeart().capAwesome().capEpic()[0]+'</span>';return{item:item,screen_name:screen_name,user_url:user_url,avatar_size:avatar_size,avatar_url:avatar_url,source:source,tweet_url:tweet_url,tweet_time:tweet_time,tweet_relative_time:tweet_relative_time,tweet_raw_text:tweet_raw_text,tweet_text:tweet_text,retweet:retweet,retweeted_screen_name:retweeted_screen_name,user:user,join:join,avatar:avatar,time:time,text:text}});tweets=$.grep(tweets,s.filter).slice(0,s.count);list.append($.map(tweets.sort(s.comparator),function(t){return"<li>"+expand_template(t)+"</li>"}).join('')).children('li:first').addClass('tweet_first').end().children('li:odd').addClass('tweet_even').end().children('li:even').addClass('tweet_odd');if(s.outro_text)list.after(outro);$(widget).trigger("loaded").trigger((tweets.length===0?"empty":"full"));if(s.refresh_interval){window.setTimeout(function(){$(widget).trigger("load")},1000*s.refresh_interval)}})}).trigger("load")})}})(jQuery);
	
/* ========================================================== 
	(19) Ordered List
============================================================ */
	
 $(document).ready(function(){	
    $("ol.steps li:first")
    .addClass("first");	
    $("ol.steps li:last")
    .addClass("last");		
  });	  
  
 /* ========================================================== 
	(20) Custom Popup
============================================================ */

$(document).ready(function() {

//When you click on a link with class of poplight and the href starts with a # 
$('a.poplight[href^=#]').click(function() {
    var popID = $(this).attr('rel'); //Get Popup Name
    var popURL = $(this).attr('href'); //Get Popup href to define size

    //Pull Query & Variables from href URL
    var query= popURL.split('?');
    var dim= query[1].split('&');
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value

    //Fade in the Popup and add close button
    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close" title="Close"><span class="btn_close">Close</span></a>');

    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    //Apply Margin to Popup
    $('#' + popID).css({
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    //Fade in Background
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
    $('#fade').css({'filter' : 'alpha(opacity=30)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=30)'}) is used to fix the IE Bug on fading transparencies 

    return false;
});

//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  //fade them both out
    });
    return false;
});

});
