$(document).ready(function(){

    /* *** reklamodawcy tooltip *** */
    $(".tTip").tooltip({
	offset: [-5, -260],
	tip: '#dynatip',
	opacity: 0.9,
	onShow: function() {
	    var dom_id = this.getTrigger().attr('id').substr(4);
        //alert(dom_id);
        $('#dynatip .middle').html('<p style="text-align: center;"><img src="/static/netshare/img/ajax-loader.gif" alt="Trwa pobieranie danych, proszę czekać..." /></p>');
	    $.ajax({
		type: "GET",
		url: "/ajax/dom-cat-prices/domainid/"+dom_id,
		success: function(content)
		{
		    $('#dynatip .middle').html(content);
		}
	    });
	}
    }).dynamic( {
	bottom: {
	    offset: [5, -260],
	    bounce: false
	}
    });

    /* *** obsługa inputa wyszukiwarki i newslettera *** */
    $('input#search, input#newsletter').focus(function() {
	if (this.value == this.defaultValue)
	{
	    this.value = "";
	}
	else
	{
	    this.select();
	}
    }).blur(function(){
	if ($.trim($(this).val()) == "")
	{
	    $(this).val(this.defaultValue);
	}
    });

    /* *** obsługa selecta od kategorii *** */
    $("form#form_category select").change(function() {
	$("form#form_category").submit();
    });

    /* *** obsługa faq *** */
    $(".faq_link").click(function () {
	var id = $(this).attr("rel");
	var protocol = jQuery.url.attr("protocol");
	var host = jQuery.url.attr("host");
	var path = jQuery.url.attr("path");
	if(path != '/wydawcy,faq.html')
	{
	    var url = protocol+"://"+host+"/wydawcy,faq.html#"+id;
	    window.location.href = url;
	}
	else
	{
	    var url2 = protocol+"://"+host+path+"#"+id;
	    window.location.href = url2;
	    location.reload();	  		
	}
	return false;
    });
    var anchor = jQuery.url.attr("anchor");

    if(anchor !== null)
    {
	var img = $("#"+anchor).find("img");
	$("#"+anchor).removeClass("exp");
	$("#"+anchor).addClass("col");
	$("#"+anchor+" .question").css("color", "#621358");
	$('#ans_'+anchor).toggle();
	$(img).attr("src", "/static/netshare/img/ico_col.gif");
	$(img).attr("class", "col");
    }



    $(".faq_single .question").click(function () {
	var parent = $(this).parent();
	var id = parent.attr("id");
	var img = $(this).find("img");

	if(parent.hasClass("col"))
	{
	    parent.removeClass("col");
	    parent.addClass("exp");
	    $(this).css("color", "#333333");
	    $('#ans_'+id).toggle();
	    $(img).attr("src", "/static/netshare/img/ico_exp.gif");
	    $(img).attr("class", "exp");
	}
	else
	{
	    parent.removeClass("exp");
	    parent.addClass("col");
	    $(this).css("color", "#621358");
	    $('#ans_'+id).toggle();
	    $(img).attr("src", "/static/netshare/img/ico_col.gif");
	    $(img).attr("class", "col");
	}
	return;
    });

	/* *** slider z korzyściami *** */
	$("#slider").easySlider({
		auto: true,
		continuous: true
	});

	$(function() {
		$("img.mini").overlay({expose: '#000', effect: 'apple'});

	});

	$("img.mini").click(function()
      {
		$("#big_image").attr('src', '') ;
        $("#big_image").attr('src', $(this).attr('big_src')) ;
      });

      /* *** prezentacja online *** */

    $(function() {
	$("a.offert_online").overlay({
	    expose: '#000000',
	    effect: 'apple',
	    onBeforeLoad: function() {
		var wrap = this.getContent().find(".overlay_wrap");
		wrap.load(this.getTrigger().attr("href"));
	    }

	});
    });

    $(function() {
	$("a.overlay_img").overlay({
	    expose: '#000000',
	    onBeforeLoad: function() {
		var wrap = this.getContent().find(".overlay_wrap");
		wrap.html('<img src="'+ this.getTrigger().attr("href") + '" alt="" />');
	    }

	});
    });


    $('#formedia .single-article h3').each(function() {
        $(this).addClass('sIFR-ignore');
    });

    $("#references_content .ref_box:last-child p.author").css("border",0);

});

//function close_img(){
//	var r = $("img.mini").overlay({api: true});
//	r.close();
//	document.getElementById("big_image").src = '/static/netshare/img/help.gif';
//}
