function switchid(id){
	if( $(id).css('display') == 'none' ){
		$(id).fadeIn();
		$.scrollTo(id, 800);
	}
	else{
		$(id).fadeOut();
	}
}


function setAjaxCorner(){
	$('.corner').corner('5px');
}

function ra(url,out){
	$.ajax({
	  	url: url,
	  	context: document.body,
	  	beforeSend: function(){
	  		$('#progress').addClass("progressbar").fadeIn();
	  	},
	  	success: function(data){
	    $(out).html(data);
	  	},
	  	complete: function(){
			$('#progress').removeClass("progressbar").fadeOut();
			setAjaxCorner();
	  	}
	});
}

function rating(url){
	$.ajax({
	  	url: url,
	  	context: document.body,
		success: function(json){

			$('#ratingmsg').fadeIn();
			$('#ratingmsg').html(json.msg);

			if( json.status == '1' ){
				$('#ratingmsg').removeClass('errorlabel');
				$('#ratingmsg').addClass('oklabel').fadeIn();
			}
			else{
				$('#ratingmsg').removeClass('oklabel');
				$('#ratingmsg').addClass('errorlabel').fadeIn();
			}

		},
		dataType: 'json'
	});
}

function sa(url,param,out){
	$.ajax({
		type: 'POST',
		data: $(param).serialize(),
	  	url: url,
	  	context: document.body,
	  	beforeSend: function(){
	  		$('#progress').addClass("progressbar").fadeIn();
	  	},
	  	success: function(data){
	    $(out).html(data);
	  	},
	  	complete: function(){
			$('#progress').removeClass("progressbar").fadeOut();
			setAjaxCorner();
	  	}
	});
}


function setHTML($div, $html){
	$($div).html($html).fadeIn();
}


function linksExternal(){
    if (document.getElementsByTagName) {
        var anchors = document.getElementsByTagName("a");
        for (var i = 0; i < anchors.length; i++) {
            var anchor = anchors[i];
            if (anchor.getAttribute("rel") == "external") {
                anchor.target = "_blank";
					 //alert( anchor );
            }
        }
    }
}

function clicksave(object_id){
	$.ajax({
	  	url: root_url + '/obiekt/clicksave/' + object_id,
		cache: true,
		async: true
	});
}



function publicUpdateObject(){
	//debugger
	var adress = root_url + '/konto/updateobject';
	$.ajax({
   	type: 'POST',
   	url: adress ,
   	data: $("#addobject").serialize() ,
		beforeSend: function(){
			$('#progress').addClass("progressbar").fadeIn();
		},
   	success: function(json){
			$.scrollTo( '#editobjectconteiner', 800);
			$('#formreply').html(json.reply).fadeIn();
		},
		complete: function(){
			$('#progress').removeClass("progressbar").fadeOut();
			setAjaxCorner();
	  	},
   	dataType: 'json'
 	});
}

function publicAddObject(){
	//debugger
	var adress = root_url + '/konto/addobject';
	$.ajax({
   	type: 'POST',
   	url: adress ,
   	data: $("#addobject").serialize() ,
		beforeSend: function(){
			$('#progress').addClass("progressbar").fadeIn();
		},
   	success: function(json){
			$.scrollTo( '#editobjectconteiner', 800);
			$('#formreply').html(json.reply).fadeIn();

		},
		complete: function(){
			$('#progress').removeClass("progressbar").fadeOut();
			setAjaxCorner();
	  	},
   	dataType: 'json'
 	});
}


function changeSubmitButton(){
	$('#stepnoimages').fadeOut();
	$('#stepimage').fadeIn();
}


//<script type="text/javascript">$('.message').corner();</script>


// Koniguracja galerii
hs.graphicsDir = 'templates/default/js/highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.fadeInOut = true;
hs.dimmingOpacity = 0.8;
hs.outlineType = 'rounded-white';
hs.captionEval = 'this.thumb.alt';
hs.marginBottom = 105; // make room for the thumbstrip and the controls
hs.numberPosition = 'caption';

// Add the slideshow providing the controlbar and the thumbstrip
hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	overlayOptions: {
		className: 'text-controls',
		position: 'bottom center',
		relativeTo: 'viewport',
		offsetY: -60
	},
	thumbstrip: {
		position: 'bottom center',
		mode: 'horizontal',
		relativeTo: 'viewport'
	}
});

