

jQuery(function(){
	var val1=jQuery("#search-2 .widget-title").hide().text();

	jQuery("#s").DefaultValue(val1);
	jQuery(".button, .wp-pagenavi").find("a").each(function(){
		
		jQuery(this).addClass("btn_rounded");
	var content=jQuery(this).html();
	var newcontent='<span>'+content+'</span>';
	jQuery(this).html(newcontent);
	});
		jQuery(".current, .submit-button").each(function(){
		
		jQuery(this).addClass("btn_rounded");
	var content=jQuery(this).html();
	var newcontent='<span>'+content+'</span>';
	jQuery(this).html(newcontent);
	});
	
	
	jQuery("#top").click(function(e){
		e.preventDefault();
		jQuery("html, body").animate({ scrollTop: 0}, 500 );
		
	});
jQuery("#commentform").validate();

jQuery('#searchform div').append('<a class="submit" href="#submit">&nbsp;</a>');

	var submitter = jQuery("#searchform a");
	
	submitter.click(function(e){
		e.preventDefault();
			jQuery(this).parents("form").submit();
		
	});

	jQuery("#nav_bar").css({
		
		marginLeft: (jQuery("#nav_bar").parent().width() - jQuery("#nav_bar").outerWidth() ) /2,
		visibility: "visible",
		opacity: "0"
		
	}).animate({opacity: 1}, 500);
	
	jQuery("#main_menu").find("a:last").addClass("last").end().fadeIn();
	jQuery("#header .logo").fadeIn();
	
	jQuery("form").forms();
	
	jQuery("#content .article table").each(function(){
		
		var table = jQuery(this);
		
		table.css("visibility", "visible").css("opacity", "0");
		
		table.find("tr").each(function(i, val){
			if( i % 2 ){ jQuery(this).addClass("odd"); }
		});
		
		table.animate({opacity:"1"}, {duration:500});
		
	});

	jQuery("#feedback table").each(function(){
		
		var table = jQuery(this);
		
		
		table.find("td").each(function(i, val){
			if( i % 2 ){}
			else{ jQuery(this).addClass("first"); }
		}).end().find("tr").each(function(i, val){
			if( i % 2 ){}
			else{ jQuery(this).addClass("odd"); }
		})
		
		table.css("visibility", "visible");
	});
	
//jQuery(".article_image").image_crop();
	
	jQuery(".article_list .text").each(function(){
		
		if( jQuery(this).height() == 17 ){ jQuery(this).addClass("margined");}
		
	});

var i=0 ;
var count=0;
skype=new Array() ;
obj=new Array();

var hn = window.location.hostname;
var hn = '' ;
url=hn+'/wp-content/themes/bmn/tagx.php' ;

	jQuery(".skype").each(function(i){
		skype[i]=jQuery(this).attr("rel") ;
		obj[i]=jQuery(this).find(".status");
		count=i;

	});


i=0 ;
if (skype.length>0) { 
	get_status(skype,obj,i) ;
}
function get_status(skype,obj,i) {
		data='skypeid='+skype[i];
		jQuery.ajax({
				url:url,
				data:data,
				cache: false,
				crossDomain: true,
				success: function (html) {

					newsrc="http://www.balticmedianews.eu/wp-content/themes/bmn/static/imgs/skype/"+html+".png" ;
					obj[i].attr("src",newsrc) ;
					obj[i].addClass("status2");
					if (i!=count) {
						i++;
						get_status(skype,obj,i)
					}
				},
				error:function (xhr, ajaxOptions, thrownError){
						} 
			 
			});




	}

});	


jQuery.fn.image_crop = function(){
	
	jQuery(this).each(function(){
		load_image( jQuery(this) );
	});
	
	function load_image( obj ){
		var img = obj.find("img");
		var tmp = new Image();
		tmp.onload = function(){
			resize( obj );
		};
		tmp.src = img.attr("src");
	};
	
	function resize( obj ){
		
		var max_width = obj.width();
		var max_height = obj.height();
		
		var img = obj.find("img");
		
		if( img.height() > max_height ){ img.css("height", max_height); }
		
		img.css({
			
			left: (max_width - img.width() ) /2,
			top: (max_height - img.height() ) /2,
			visibility: "visible",
			display: "none"
			
		}).fadeIn();
		
	};
	
};


jQuery.fn.DefaultValue = function(text){
    return this.each(function(){
		//Make sure we're dealing with text-based form fields
		if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
			return;
		
		//Store field reference
		var fld_current=this;
		
		//Set value initially if none are specified
        if(this.value=='') {
			this.value=text;
		} else {
			//Other value exists - ignore
			return;
		}
		
		//Remove values on focus
		jQuery(this).focus(function() {
			if(this.value==text || this.value=='')
				this.value='';
		});
		
		//Place values back on blur
		jQuery(this).blur(function() {
			if(this.value==text || this.value=='')
				this.value=text;
		});
		
		//Capture parent form submission
		//Remove field values that are still default
		jQuery(this).parents("form").each(function() {
			//Bind parent form submit
			jQuery(this).submit(function() {
				if(fld_current.value==text) {
					fld_current.value='';
				}
			});
		});
    });
};
jQuery.fn.forms = function(){
	
	var main = jQuery(this);
	

	
	main.find("input[value]:not(input[type='submit']), textarea[value]").each(function(){
		
		var input = jQuery(this);
		var value = input.val();
		var label = input.attr("value");
		
		if( !value ){
			input.val(label);
		};
		
		input.focus(function(){
			if(input.val() == label){
				input.val("");
			};
		});
		
		input.blur(function(){
			if( input.val().length == 0 ){
				
				input.val( label );
				
			};
		});
		
	});
	
	main.find("input, textarea").each(function(){
		
		var input = jQuery(this);
		var parent = input.parent().parent();
		
		input.hover(function(){
			
			input.addClass("hover");
			if( parent.is(".form") ){
				parent.addClass("hover");
			};
			
			
		}, function(){
			
			input.removeClass("hover");
			if( parent.is(".form") ){
				parent.removeClass("hover");
			};
		});
		
		input.focus(function(){
			
			input.addClass("focus");
			if( parent.is(".form") ){
				parent.addClass("focus");
			};
		});
		
		input.blur(function(){
			
			input.removeClass("focus");
			if( parent.is(".form") ){
				parent.removeClass("focus");
			};
		});
		
		
	});

};


