    function preload_slider()
	{
		var url = document.location.toString().substr(0, document.location.toString().lastIndexOf('/')+1);
	
		var e = $('img.preload:first'); 
		if( e == undefined || $(e).attr('longdesc') == undefined ) return;
		var img = new Image;
		img.onload = function () {$(e).attr("src", $(e).attr('longdesc'));$(e).removeClass('preload');preload_slider();};
		img.onerror = function () {$(e).removeClass('preload');preload_slider();};
		img.onabort = function () {$(e).removeClass('preload');preload_slider();};
		img.src = url+$(e).attr('longdesc');
	};

        function get_Page_Size() {
                var xScroll, yScroll;
                if (window.innerHeight && window.scrollMaxY) {
                        xScroll = window.innerWidth + window.scrollMaxX;
                        yScroll = window.innerHeight + window.scrollMaxY;
                } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                        xScroll = document.body.scrollWidth;
                        yScroll = document.body.scrollHeight;
                } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
                        xScroll = document.body.offsetWidth;
                        yScroll = document.body.offsetHeight;
                }
                var windowWidth, windowHeight;
                if (self.innerHeight) {	// all except Explorer
                        if(document.documentElement.clientWidth){
                                windowWidth = document.documentElement.clientWidth;
                        } else {
                                windowWidth = self.innerWidth;
                        }
                        windowHeight = self.innerHeight;
                } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                        windowWidth = document.documentElement.clientWidth;
                        windowHeight = document.documentElement.clientHeight;
                } else if (document.body) { // other Explorers
                        windowWidth = document.body.clientWidth;
                        windowHeight = document.body.clientHeight;
                }
                // for small pages with total height less then height of the viewport
                if(yScroll < windowHeight){
                        pageHeight = windowHeight;
                } else {
                        pageHeight = yScroll;
                }
                // for small pages with total width less then width of the viewport
                if(xScroll < windowWidth){
                        pageWidth = xScroll;
                } else {
                        pageWidth = windowWidth;
                }
                arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
                return arrayPageSize;
        };


$(document).ready(function () {

    $("body").html($("body").html().replace(/.%małpka%./g,"@"));

    if($(".banner").length>0){
            function ao_down(data,max){
                duration=(500*max)/(max+5);
                tm=((duration*3)/max);
                if(data<=max){
                    $("#dz"+data).animate({
                        top: 100
                    }, duration,"swing",function(){$(this).remove()});
                    setTimeout(function(){
                        ao_down(data+1,max);
                    },tm);
                }else{
                    return false;
                }
            };

            function aoSlide(data,max,podz) {
                if(data>max){
                    data=1;
                }
                if(data==1){
                    data2=max;
                }else{
                    data2=data-1;
                }
                divz='';
                bgimg=$("#bani"+data).attr('src');
                var szer_all=0;
                for(i=0;i<podz;i++){
                    if((i+1)==podz){
                        szer=$(".banner").width()-szer_all;
                        var szer_all=(szer_all+szer);
                    }else{
                        szer=Math.floor($(".banner").width()/podz);
                        var szer_all=(szer_all+szer);
                    }
                    //alert(szer_all);
                    divz=divz+'<div id="dz'+i+'" style="position:absolute;left:'+(szer_all-szer)+'px;width:'+szer+'px;background:url('+bgimg+') -'+(szer_all-szer)+'px 0px no-repeat;height:'+($(".banner").height())+'px;"></div>';
                }

                setTimeout(function(){
                    $(".banner").append(divz);
                    $("#bani"+data).hide();
                    $("#bani"+data2).show();
                    ao_down(0,podz);
                    if(data==1){
                        var data3=max;
                    }else{
                        var data3=data-1;
                    }
                    
                    if($("#bani"+data2).attr("data-division")!== undefined){
                        kib2=parseInt($("#bani"+data2).attr("data-division"));
                    }else{
                        kib2=30;
                    }
                    if(kib2>$(".banner").width()){
                        kib2=$(".banner").width();
                    }
                    setTimeout(function(){
                        aoSlide(data3,max,kib2);
                    },2000);
                },4000);
            };


        var bi=0;
        $(".banner").find('img').each(function(){
            if(bi>0){
                $(this).hide();
            }else{
                if($(this).attr("data-division")!== undefined){
                    kib=parseInt($(this).attr("data-division"));
                }else{
                    kib=30;
                }
            }
            bi++;
            $(this).attr("id","bani"+bi);
        });
        if(kib>$(".banner").width()){
            kib=$(".banner").width();
        }
        aoSlide(1,bi,kib);
    }

    window.alert = function(text) {
        var arrPageSizes = get_Page_Size();
        // Style overlay and show it
        $('#blackout2').css({
                'display':'block',
                'width':arrPageSizes[0],
                'height':arrPageSizes[1]
        });
	$("body").append("<div class=\"form_info3\">&nbsp;<div class=\"close_form_info3\"></div><div class=\"form_info_mid\"><div class=\"mid\">"+text+"</div></div><div class=\"form_info_bot\"></div></div>");
	//$('html, body').animate({scrollTop:0}, 'fast');
    }

    //no border trick
    $('a').each(function(){
        $(this).focus(function(){
            if($(this).blur && 1){
                $(this).blur();
            }
        });
    });

    $('a').click(function(){
        if($(this).attr('rel')=='external'){
            window.open(this.href,'_blank');
            return false;
        }
    });

    $('#rollslide_img a').each(function(){
        $(this).lightBox();
    });

    $('.realizacja_lb').lightBox();

    $('.lightbox').lightBox();

    $('.lightbox,.yogurth,.ref_div').hover(function(){
        $(this).find('div').stop(true,false);
        $(this).find('div').animate({
            borderWidth: "10px",
            width: "155px",
            height: "153px"
        },150);

    }, function(){
        $(this).find('div').stop(true,false);
        $(this).find('div').animate({
            borderWidth: "1px",
            width: "175px",
            height: "173px"
        },150);

    });

    //górne menu
    var addr_ar = document.location.toString().split('/');
    var link_class=0;

    $('.inner ul li a').each(function(){
        var this_href2 = $(this).attr("href").split('/');
        var this_href = this_href2[this_href2.length-1];
        if($(this).attr("href")==addr_ar[addr_ar.length-1].replace("#",'') || $(this).attr("href")==addr_ar[addr_ar.length-1].replace("2",'1') || this_href==addr_ar[addr_ar.length-1].replace("2",'1') ||  this_href==addr_ar[addr_ar.length-1].replace("#",'')){
            if(addr_ar[addr_ar.length-1].replace("#",'')!='' || addr_ar[addr_ar.length-1].replace("2",'1')!=''){
                $(this).addClass("current");
                link_class++;
            }
        }
        if(($(this).attr("href")=="/wybrane-realizacje" && (addr_ar[addr_ar.length-2]=="realizacje" || addr_ar[addr_ar.length-1]=="realizacje"))
        || ($(this).attr("href")=="/cennik-zakupu-oprogramowania" && addr_ar[addr_ar.length-1]=="cennik-wynajmu-oprogramowania")
        || ($(this).attr("href")=="/demo-sklepu-wersja-indywidualna" && addr_ar[addr_ar.length-1]=="demo-sklepu")
        || ($(this).attr("href")=="/demo-sklepu" && addr_ar[addr_ar.length-1]=="demo-sklepu-wersja-indywidualna")
        || ($(this).attr("href")=="/blog/" && addr_ar[addr_ar.length-2]=="blog")
        || ($(this).attr("href")=="/blog/" && addr_ar[addr_ar.length-3]=="blog")
        || ($(this).attr("href")=="/blog/" && addr_ar[addr_ar.length-4]=="blog")
        ){
            $(this).addClass("current");
            link_class++;
        }
    });
    if(link_class==0) {$("#main_site_link").addClass("current");}

    $("*[data-hinter]").hover(function(e){
        if(window.innerWidth){var win_wid=window.innerWidth;}else{var win_wid=document.body.scrollWidth;}
        var xr=Math.round(win_wid-e.pageX)-20;
        $("#hint-middle").html($(this).attr("data-hinter"));
        $("#hinter").show();
        var xt=Math.round($(this).offset().top-$(window).scrollTop());
        if(xt>$("#hint-middle").height()+17){
            $("#hinter").css("top",($(this).offset().top-($("#hint-middle").height()+17)));
            $("#hint-top").addClass("top1");
            if(xr>198){
                $("#hint-bottom").addClass("bottom1");
                $("#hinter").css("left",(e.pageX-15));
            }else{
                $("#hint-bottom").addClass("bottom2");
                $("#hinter").css("left",(e.pageX-183));
                //$("#hinter").css("left",($(this).offset().left-Math.abs($(this).width()-198)));
            }
        }else{
            $("#hinter").css("top",($(this).offset().top+$(this).height()+5));
            $("#hint-bottom").addClass("bottom3");
            if(xr>198){
                $("#hint-top").addClass("top2");
                $("#hinter").css("left",(e.pageX-15));
            }else{
                $("#hint-top").addClass("top3");
                $("#hinter").css("left",(e.pageX-183));
                //$("#hinter").css("left",($(this).offset().left-Math.abs($(this).width()-198)));
            }
        }
    },function(){
        $("#hinter").hide();
        $("#hinter").css("left","-200px");
        $("#hint-bottom").removeClass();
        $("#hint-top").removeClass();
    });

    $("#demo .form ul:nth-child(2)").css("padding-right", "0px");
    th_var=0;
    th_left=$("#fb_main").css('left');
    $("#fb_button").click(function(){
            if(th_var==0){
                    $("#fb_main").animate({
                            left: '0'
                    }, 500,function(){
                            th_var=1;
                    });
            }else{
                    $("#fb_main").animate({
                            left: ''+th_left+''
                    }, 500,function(){
                            th_var=0;
                    });
            }
    });

    scrl_width=(178*(($("#rollslide_img .selected").length)))+33;
    $("#rollslide_img").css('width',scrl_width);
    left_scr=scrl_width-562; //-33+5-(3*178);
    slide_act='2';
    $("#slide"+slide_act).css('width','211px');
    $("#slide"+slide_act).css('margin-top','15px');
    var _click=0;
    $(".right_arr_slide").click(function(){
        window.getSelection().removeAllRanges();
        if(_click==0){
            if(slide_act==($("#rollslide_img .selected").length)-4)
			{
                $("#slide"+slide_act).css('width','178px');
                $("#slide"+slide_act).css('margin-top','0px');
                slide_act=-1*(($("#rollslide_img .selected").length)-4);
                $("#slide"+slide_act).css('width','211px');
                $("#slide"+slide_act).css('margin-top','15px');
                $("#rollslide_img").css('left','-5px');
            }
            $("#slide"+slide_act).animate({
                'width': '178px',
                'margin-top': '0px'
            },500)
            if(slide_act<0){
                slide_act--;
            }else{
                slide_act++;
            }
            if(slide_act==(-1*(($("#rollslide_img .selected").length)-2))){
                slide_act=1;
            }
            _click=1;
            $(".portfolio_opis").fadeTo(300,0, function(){
                $(this).css("display","none");
            });
            $("#slide"+slide_act.toString()).animate({
                'width': '211px',
                'margin-top': '15px'
            },500)
            $("#rollslide_img").animate({
                'left': '-=178'
            },500,function(){
                _click=0;
                $("#"+$("#slide"+slide_act.toString()).parent().attr('rel')).fadeTo(300,1);
            });
        }
    });


    $(".left_arr_slide").click(function(){
        window.getSelection().removeAllRanges();
        if(_click==0){
             if(slide_act==-1*($("#rollslide_img .selected").length-4)){
                $("#slide"+slide_act).css('width','178px');
                $("#slide"+slide_act).css('margin-top','0px');
                slide_act=($("#rollslide_img .selected").length)-4;
                $("#slide"+slide_act).css('width','211px');
                $("#slide"+slide_act).css('margin-top','15px');
                $("#rollslide_img").css('left','-'+left_scr+'px');
            }       
            $("#slide"+slide_act).animate({
                'width': '178px',
                'margin-top': '0px'
            },500)
            if(slide_act<0){
                slide_act++;
            }else{
                slide_act--;
            }
            if(slide_act==0){
                slide_act=(-1*($("#rollslide_img .selected").length-3));
            }
            _click=1;
            $(".portfolio_opis").fadeTo(300,0,function(){
                $(this).css("display","none");
            });
            $("#slide"+slide_act).animate({
                'width': '211px',
                'margin-top': '15px'
            },500)
            $("#rollslide_img").animate({
                'left': '+=178'
            },500,function(){
                _click=0;
                $("#"+$("#slide"+slide_act.toString()).parent().attr('rel')).fadeTo(300,1);
            });
        }
    });

    $(":input").each(function(){
        if($(this).attr('alt')=='req' || $(this).attr('title')=='req'){
            $(this).css({'background-image':'url(/images/uwaga.jpg)','background-position':'top right','background-repeat':'no-repeat'});
        }
    });



 
    if($("#form_info").css("display")=="block"){
         var arrPageSizes = get_Page_Size();
        // Style overlay and show it
        $('#blackout2').css({
                'display':'block',
                'width':arrPageSizes[0],
                'height':arrPageSizes[1]
        });
    }

    $("#form_info").appendTo("body");

    $("#close_form_info").click(function(){
        $("#form_info").fadeTo(200, 0, function(){
            $(this).css("display","none");
            $("#blackout2").hide();
            if($("#close_form_info").attr("class").length>0 && $("input[name$='"+$("#close_form_info").attr("class")+"']").length>0){
                $("input[name$='"+$("#close_form_info").attr("class")+"']").focus();
            }
            if($("#close_form_info").attr("data-refresh")!==undefined){
                window.location.href = "http://www.cstore.pl"+$("#close_form_info").attr("data-refresh");
            }
        });

    });

    $("#form_info2").appendTo("body");

    $("#close_form_info2").click(function(){
        $("#form_info2").fadeTo(200, 0, function(){
            $(this).css("display","none");
            $("#blackout2").hide();
        });
        if( typeof(currentFocusForm) != 'undefined' && currentFocusForm!=''){
            $("form[name$='"+currentFocusForm+"'] input[name$='"+currentFocus+"']").focus();
        }
    });

    $(".form_info3").appendTo("body");

    $(".close_form_info3").live('click',function(){
        $(".form_info3").fadeTo(200, 0, function(){
            $(this).css("display","none");
            $("#blackout2").hide();
        });
       if(currentFocusForm!='') {
           $("form[name$='"+currentFocusForm+"'] input[name$='"+currentFocus+"']").focus();
       }
    });


    $(".demo_color").click(function(){
        $(".new_blue_but").css("background-position","0px 0px");
        $(".new_green_but").css("background-position","-35px 0px");
        $(".new_yellow_but").css("background-position","-70px 0px");
        $(".new_red_but").css("background-position","-105px 0px");
        $(this).css("background-position",$(this).css("background-position").replace(" 0%"," bottom").replace(" 0px"," bottom"));
        $(".change_color").val($(this).attr("title"));
        $(".demo_submit").stop(true,false);
        var slide=$(this).attr("data-slide");
        $(".demo_submit").animate({
            backgroundPosition: '0px -'+slide+'px'
        },300)
    });


    $(".demo_submit").mouseup(function(){
        $(".demo_div").each(function(){
            if($(this).css("display")=="block"){
                $(this).find(".demo_color_form").submit();
            }
        });
        
    });



    $(".demo_pa_link").mouseup(function(){
        window.open($(this).attr("title"));
    });

//ZAMAWIANIE KOD RABATOWY
    var http_request = false;

    disc_code_ext=0;

    function makeRequest(url,show_info) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/plain');
                // Przeczytaj o tym wierszu poniżej
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Poddaję się :( Nie mogę stworzyć instancji obiektu XMLHTTP');
            return false;
        }
        http_request.onreadystatechange = function() {alertContents(http_request,show_info);};
        http_request.open('GET', url, true);
        http_request.send(null);

    }



    function alertContents(http_request,show_info) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				
                $("#code_alert").html(http_request.responseText);
                if(http_request.responseText==''){
                    show_info=0;
                }
				info = http_request.responseText;
				
				info = info.substr(info.length-11,11);

                //kod_rabat_int=parseInt(http_request.responseText.substr(-11));
                kod_rabat_int=parseInt(info);

                disc=(1-(kod_rabat_int/100));
                //alert(http_request.responseText);
                if(Number(disc)>0){
                    if(disc_code_ext==0){
                        if(show_info>0){
                            var arrPageSizes = get_Page_Size();
                            // Style overlay and show it
                            $('#blackout2').css({
                                    'display':'block',
                                    'width':arrPageSizes[0],
                                    'height':arrPageSizes[1]
                            });
                            $("#form_info2").fadeTo(200,1);
                            $("#form_info2").css("display","block");
                        }
                        var cena=parseInt($("#order_price1").html().replace(",00 zł netto",""));
                        cena *= disc;
                        cena=Math.ceil(cena);
                        $("#order_price1").html(cena+",00 zł netto");
                        if($("#zamow_szate").is(':checked')){
                            cena += 2500;
                        }
						 if($("#zamow_integrator").is(':checked')){
                            cena += 800;
                        }
						 if ( $("#kod_rabatowy").val().toLowerCase() == 'solex' && $("#zamow_integrator").is(':checked') ) {cena -=55;$("#order_price22").html("745,00 zł netto");}

                        $("#order_price3").html(cena+",00 zł netto");
                        disc_code_ext=1;
                    }
                        currentFocusForm='';
                        currentFocus='';
                }else{
                    if(show_info>0){
                        var arrPageSizes = get_Page_Size();
                        // Style overlay and show it
                        $('#blackout2').css({
                                'display':'block',
                                'width':arrPageSizes[0],
                                'height':arrPageSizes[1]
                        });
                        $("#form_info2").fadeTo(200,1);
                        $("#form_info2").css("display","block");
                    }
                    var cena=1950;
                    $("#order_price1").html(cena+",00 zł netto");
                    if($("#zamow_szate").is(':checked')){
                        cena += 2500;
                    }
					if($("#zamow_integrator").is(':checked')){
                        cena += 800;
                    }
					 if ( $("#kod_rabatowy").val().toLowerCase() == 'solex' && $("#zamow_integrator").is(':checked') ) {cena -=55;$("#order_price22").html("745,00 zł netto");}

                    $("#order_price3").html(cena+",00 zł netto");
                    disc_code_ext=0;
                    $(".input-text,.input-text-small,.input-textarea").focus(function(){
                        $(this).css("border","2px solid #EAA800");
                        $(this).css("margin","-1px");
                        $(this).css("-moz-border-radius","3px");
                        $(this).css("border-radius","3px");
                        $(this).css("-khtml-border-radius","3px");
                        $(this).css("-webkit-border-radius","3px");
                    });

                    $(".input-text,.input-text-small,.input-textarea").blur(function(){
                        $(this).css("border","1px solid #C5C5C5");
                        $(this).css("margin","0px");
                        $(this).css("-moz-border-radius","0px");
                        $(this).css("border-radius","0px");
                        $(this).css("-khtml-border-radius","0px");
                        $(this).css("-webkit-border-radius","0px");
                    });
                    if($.browser.msie==true){
                        $(".input-submit").live('click',function(){
                            if($("input[name$='order_summary']").length>0 && $("#order_price3").length>0){
                                $("input[name$='order_summary']").val(parseInt($("#order_price3").html().replace(",00 zł netto","")));
                            }

                            var p=0;
                            $(this).parents('form').find(":input").each(function(){
                                $(this).blur();
                                if($(this).attr('alt')=='req' || $(this).attr('alt')=='req2' || $(this).attr('title')=='req' || $(this).attr('title')=='req2'){
                                    if($(this).attr('name')=='email' || $(this).attr('name')=='e-mail'){
                                        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                                        if(reg.test($(this).val()) == false) {
                                            $(this).focus();
                                            currentFocus = $(this).attr('name');
                                            currentFocusForm = $(this).parents('form').attr('name');
                                            p++;
                                            return false;
                                        }
                                    }else{
                                        if($(this).val().length<3){
                                            var tid=$(this).attr("id");
                                            var nazwa=$(this).parents('li').find('label').text().replace(":","").replace("*","");
                                            $(this).focus();
                                            currentFocus = $(this).attr('name');
                                            currentFocusForm = $(this).parents('form').attr('name');
                                            p++;
                                            return false;
                                        }
                                    }
                                }
                            });
                            if(p>0) {
                                return false;
                            }
                        });
                    }else{
                        $(".input-submit").click(function(){
                            if($("input[name$='order_summary']").length>0 && $("#order_price3").length>0){
                                $("input[name$='order_summary']").val(parseInt($("#order_price3").html().replace(",00 zł netto","")));
                            }

                            var p=0;
                            $(this).parents('form').find(":input").each(function(){
                                $(this).blur();
                                if($(this).attr('alt')=='req' || $(this).attr('alt')=='req2' || $(this).attr('title')=='req' || $(this).attr('title')=='req2'){
                                    if($(this).attr('name')=='email' || $(this).attr('name')=='e-mail'){
                                        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                                        if(reg.test($(this).val()) == false) {
                                            $(this).focus();
                                            p++;
                                            currentFocus = $(this).attr('name');
                                            currentFocusForm = $(this).parents('form').attr('name');
                                            return false;
                                        }
                                    }else{
                                        if($(this).val().length<3){
                                            var tid=$(this).attr("id");
                                            var nazwa=$(this).parents('li').find('label').text().replace(":","").replace("*","");
                                            $(this).focus();
                                            currentFocus = $(this).attr('name');
                                            currentFocusForm = $(this).parents('form').attr('name');
                                            p++;
                                            return false;
                                        }
                                    }
                                }
                            });
                            if(p>0) {
                                return false;
                            }
                        });
                    }
                }
            }
        }

    }

//KONIEC KODU RABATOWEGO

    //var order_type=1;
    if($("input[name$='zamawiam']").length>0){
        var order_type=$("input[name$='zamawiam']").val();
        if(order_type==1){
            $("input[name$='zamawiam']").val("1");
            if($("#zamow_szate").is(':checked')){
                $("#order_design").show();
            }else{
                $("#order_design").hide();
            }
			
			if($("#zamow_integrator").is(':checked')){
                $("#order_integrator").show();
            }else{
                $("#order_integrator").hide();
            }

            $("#order_software").html($("#order_software").html().replace(" (w tym hosting)",""));

            $("#order_gratis").html($("#order_gratis").html().replace("comiesięczny","3-miesieczny hosting,"));
            $("#order_gratis").html($("#order_gratis").html().replace("pakiet","jednorazowy pakiet"));
            $(".left-side h3").html("FORMULARZ ZAMÓWIENIA - ZAKUP OPROGRAMOWANIA");
            if($.browser.msie!=true) {
                Cufon.replace(".left-side h3", {fontFamily: 'Myriad Pro Bold'});
            }
            $("#kod_rabat_li div").show();
            $("#order_instal").hide();
            $("#kod_rabatowy").val("");
            var cena=1950;
            $("#order_price1").html(cena+",00 zł netto");
            if($("#zamow_szate").is(':checked')){
                cena += 2500;
            }
			 if($("#zamow_integrator").is(':checked')){
                cena += 800;
            }
				 if ( $("#kod_rabatowy").val().toLowerCase() == 'solex' && $("#zamow_integrator").is(':checked') ) {cena -=55;$("#order_price22").html("745,00 zł netto");}

            $("#order_price3").html(cena+",00 zł netto");

        }

        if(order_type==2){
            $("input[name$='zamawiam']").val("2");
            if($("#zamow_szate").is(':checked')){
                $("#order_design").show();
            }else{
                $("#order_design").hide();
            }
			if($("#zamow_integrator").is(':checked')){
                $("#order_integrator").show();
            }else{
                $("#order_integrator").hide();
            }
            $("#order_software").html($("#order_software").html().replace(":"," (w tym hosting):"));
            $("#order_gratis").html($("#order_gratis").html().replace("3-miesieczny hosting,","comiesięczny"));
            $("#order_gratis").html($("#order_gratis").html().replace("jednorazowy pakiet","pakiet"));
            $(".left-side h3").html("FORMULARZ ZAMÓWIENIA - WYNAJEM OPROGRAMOWANIA");
            if($.browser.msie!=true) {
                Cufon.replace(".left-side h3", {fontFamily: 'Myriad Pro Bold'});
            }
            $("#kod_rabat_li div").hide();
            $("#kod_rabatowy").val("");
            var cena=150;
            $("#order_price1").html(cena+",00 zł netto/m-c");
            $("#order_instal").show();
            cena += 100;
            if($("#zamow_szate").is(':checked')){
                cena += 2500;
            }
			 if($("#zamow_integrator").is(':checked')){
                cena += 800;
            }
				 if ( $("#kod_rabatowy").val().toLowerCase() == 'solex' && $("#zamow_integrator").is(':checked') ) {cena -=55;$("#order_price22").html("745,00 zł netto");}

            $("#order_price3").html(cena+",00 zł netto");
        }
    }else var order_type=1;


	$("form#order_form").submit(function(){

		cena=parseInt($("#order_price1").html().replace(",00 zł netto",""));

		if(cena == 1950 && $("#kod_rabatowy").length>0 && $("#kod_rabatowy").val()!='')
		{
			$("#kod_rabatowy").trigger('blur');
			return false;
		}

	});

    if($("#kod_rabatowy").length>0 && $("#kod_rabatowy").val()!=''){
        currentFocusForm='order';
        currentFocus='kod_rabatowy';
        makeRequest('code_chck.php?code='+$("#kod_rabatowy").val(),0);
    };

    $("#kod_rabatowy").blur(function(){
        if($(this).val()!=''){
            currentFocusForm='order';
            currentFocus='kod_rabatowy';
            makeRequest('code_chck.php?code='+$("#kod_rabatowy").val(),1);
	 
        }else{
            makeRequest('code_chck.php?code='+$("#kod_rabatowy").val(),0);
            $(this).onreadystatechange = function() {}
            var cena=1950;
            $("#order_price1").html(cena+",00 zł netto");
            if($("#zamow_szate").is(':checked')){
                cena += 2500;
            }
			if($("#zamow_integrator").is(':checked')){
                cena += 800;
            }
			 if ($("#kod_rabatowy").val().toLowerCase() == 'solex') {
				 cena -=55;
				$("#order_price22").html("745,00 zł netto");
		 }

            $("#order_price3").html(cena+",00 zł netto");
        }
    });

    $("#ff2_domena").keyup(function(){
        $(this).val($(this).val().replace(/[^A-z0-9]/i,""));
    });

    $("#ff2_domena").blur(function(){
        if($(this).val()!=''){
            makeRequest('domain_chck.php?code='+$(this).val(),1);
            currentFocusForm='demo_14';
            currentFocus='domena';
        }
    });

    $("#dd123").keyup(function(){
        $(this).val($(this).val().replace(/[^A-z0-9]/i,""));
    });

    $("#dd123").blur(function(){
        if($(this).val()!='' && order_type==1){
            makeRequest('domain_chck2.php?code='+$(this).val(),1);
            currentFocusForm='order';
            currentFocus='domena_demo';
        }
    });

    $("#awaria").click(function(){
        makeRequest('malfunction_form.php',1);
        $("#form_info2").css({
            "margin-top":"-300px"
        });
    });
    $("#p_buy").click(function(){
        makeRequest('p_buy_form.php?pid='+$(this).attr("rel"),1);
        $("#form_info2").css({
            "margin-top":"-300px"
        });
    });
    $("#p_list").click(function(){
        makeRequest('p_buy_list.php?pid='+$(this).attr("rel"),1);
        $("#form_info2").css({
            "margin-top":"-300px"
        });
    });
    $("#wynajem_opr").css({
        "color" : "white",
        "background-position" : "0px -76px"
    });
    Cufon.replace("#wynajem_opr", {fontFamily: 'Myriad Pro Bold',color: 'white'});
    Cufon.refresh('#wynajem_opr');
    $("#zakup_opr").click(function(){
        $(this).css({
            "color" : "white",
            "background-position" : "0px -76px"
        });
        Cufon.replace("#zakup_opr", {fontFamily: 'Myriad Pro Bold',color: 'white'});
        Cufon.refresh('#zakup_opr');
        $("#wynajem_opr").css({
            'color' : '#636363',
            'background-position' : '0px 0px'
        });
        Cufon.replace("#wynajem_opr", {fontFamily: 'Myriad Pro Bold',color: '#636363'});
        Cufon.refresh('#wynajem_opr');
        $("#wynajem_opr").hover(function(){
            $(this).css({"background-position" : "0px -38px"});
        }, function(){
            $(this).css({"background-position" : "0px 0px"});
        });
        $(this).hover(function(){
            $(this).css({"background-position" : "0px -76px"});
        }, function(){
            $(this).css({"background-position" : "0px -76px"});
        });
        if(order_type!=1){
            $("input[name$='zamawiam']").val("1");
            if($("#zamow_szate").is(':checked')){
                $("#order_design").show();
            }else{
                $("#order_design").hide();
            }
		    if($("#zamow_integrator").is(':checked')){
                $("#order_integrator").show();
            }else{
                $("#order_integrator").hide();
            }
		 
            $("#order_software").html($("#order_software").html().replace(" (w tym hosting)",""));
            $("#order_gratis").html($("#order_gratis").html().replace("comiesięczny","3-miesieczny hosting,"));
            $("#order_gratis").html($("#order_gratis").html().replace("pakiet","jednorazowy pakiet"));
            $(".left-side h3").html("FORMULARZ ZAMÓWIENIA - ZAKUP OPROGRAMOWANIA");
            if($.browser.msie!=true) {
                Cufon.replace(".left-side h3", {fontFamily: 'Myriad Pro Bold'});
            }
            $("#kod_rabat_li div").show();
            $("#order_instal").hide();
            $("#kod_rabatowy").val("");
            var cena=1950;
            $("#order_price1").html(cena+",00 zł netto");
            if($("#zamow_szate").is(':checked')){
                cena += 2500;
            }
			 if($("#zamow_integrator").is(':checked')){
                cena += 800;
            }
            $("#order_price3").html(cena+",00 zł netto");
            order_type=1;
        }
    });

    $("#wynajem_opr").click(function(){
        $(this).css({
            "color" : "white",
            "background-position" : "0px -76px"
        });

        Cufon.replace("#wynajem_opr", {fontFamily: 'Myriad Pro Bold',color: 'white'});
        Cufon.refresh('#wynajem_opr');
        $("#zakup_opr").css({
            'color' : '#636363',
            'background-position' : '0px 0px'
        });
        Cufon.replace("#zakup_opr", {fontFamily: 'Myriad Pro Bold',color: '#636363'});
        Cufon.refresh('#zakup_opr');
        $("#zakup_opr").hover(function(){
            $(this).css({"background-position" : "0px -38px"});
        }, function(){
            $(this).css({"background-position" : "0px 0px"});
        });
        $(this).hover(function(){
            $(this).css({"background-position" : "0px -76px"});
        }, function(){
            $(this).css({"background-position" : "0px -76px"});
        });
        if(order_type!=2){
            $("input[name$='zamawiam']").val("2");
            if($("#zamow_szate").is(':checked')){
                $("#order_design").show();
            }else{
                $("#order_design").hide();
            }
			if($("#zamow_integrator").is(':checked')){
                $("#order_integrator").show();
            }else{
                $("#order_integrator").hide();
            }
            $("#order_software").html($("#order_software").html().replace(":"," (w tym hosting):"));
            $("#order_gratis").html($("#order_gratis").html().replace("3-miesieczny hosting,","comiesięczny"));
            $("#order_gratis").html($("#order_gratis").html().replace("jednorazowy pakiet","pakiet"));
            $(".left-side h3").html("FORMULARZ ZAMÓWIENIA - WYNAJEM OPROGRAMOWANIA");
            if($.browser.msie!=true) {
                Cufon.replace(".left-side h3", {fontFamily: 'Myriad Pro Bold'});
            }
            $("#kod_rabat_li div").hide();
            $("#kod_rabatowy").val("");
            var cena=150;
            $("#order_price1").html(cena+",00 zł netto/m-c");
            $("#order_instal").show();
            cena += 100;
            if($("#zamow_szate").is(':checked')){
                cena += 2500;
            }
			if($("#zamow_integrator").is(':checked')){
                cena += 800;
            }
            $("#order_price3").html(cena+",00 zł netto");
            order_type=2;
        }
    });

    if($("#order_price3").length>0){
        if($("#zamow_szate").is(':checked')){
            $("#order_design").show();
            var cena=parseInt($("#order_price1").html().replace(",00 zł netto",""));
            cena += 2500;
            if(order_type==2){
                cena += 100;
            }
            $("#order_price3").html(cena+",00 zł netto");
        }
	if($("#zamow_integrator").is(':checked')){
            $("#order_integrator").show();
            var cena=parseInt($("#order_price1").html().replace(",00 zł netto",""));
            cena += 800;
            if(order_type==2){
                cena += 100;
            }
				if ($("#kod_rabatowy").val().toLowerCase() == 'solex') {cena -=55;
				$("#order_price22").html("745,00 zł netto");}
		
            $("#order_price3").html(cena+",00 zł netto");
        }
    };



    $("#zamow_szate").click(function(){
        if($(this).is(':checked')){
            $("#order_design").show();
            var cena=parseInt($("#order_price1").html().replace(",00 zł netto",""));
            cena += 2500;
            if(order_type==2){
                cena += 100;
            }
            $("#order_price3").html(cena+",00 zł netto");
        }else{
            $("#order_design").hide();
            var cena=parseInt($("#order_price3").html().replace(",00 zł netto",""));
            if(cena>2000 || order_type==2) {
                cena -= 2500;
            }
//            if(order_type==2){
//                cena -= 100;
//            }
            $("#order_price3").html(cena+",00 zł netto");
        }
    });
    

    $("#zamow_integrator").click(function(){
        if($(this).is(':checked')){
            $("#order_integrator").show();
            var cena=parseInt($("#order_price1").html().replace(",00 zł netto",""));
            cena += 800;
            if(order_type==2){
                cena += 100;
            }
			if ($("#kod_rabatowy").val().toLowerCase() == 'solex') {cena -=55;$("#order_price22").html("745,00 zł netto");}
			
            $("#order_price3").html(cena+",00 zł netto");
        }else{
            $("#order_integrator").hide();
            var cena=parseInt($("#order_price3").html().replace(",00 zł netto",""));
            if(cena>2000 || order_type==2) {
                cena -= 800;
            }
//            if(order_type==2){
//                cena -= 100;
//            }
            $("#order_price3").html(cena+",00 zł netto");
        }
    });

    $(".input-text,.input-text-small,.input-textarea,#s,#comment").focus(function(){
        $(this).css("border","2px solid #EAA800");
        $(this).css("margin","-1px");
        $(this).css("-moz-border-radius","3px");
        $(this).css("border-radius","3px");
        $(this).css("-khtml-border-radius","3px");
        $(this).css("-webkit-border-radius","3px");
    });

    $(".input-text,.input-text-small,.input-textarea,#s,#comment").blur(function(){
        $(this).css("border","1px solid #C5C5C5");
        $(this).css("margin","0px");
        $(this).css("-moz-border-radius","0px");
        $(this).css("border-radius","0px");
        $(this).css("-khtml-border-radius","0px");
        $(this).css("-webkit-border-radius","0px");
    });

    if($.browser.msie==true){
        $(".input-submit").live('click',function(){
            if($("input[name$='order_summary']").length>0 && $("#order_price3").length>0){
                $("input[name$='order_summary']").val(parseInt($("#order_price3").html().replace(",00 zł netto","")));
            }

            if($("#form_info2").css("display")!="block"){
                var p=0;
                $(this).parents('form').find(":input").each(function(){
                    $(this).blur();
                    if($(this).attr('alt')=='req' || $(this).attr('alt')=='req2' || $(this).attr('title')=='req' || $(this).attr('title')=='req2'){
                        if($(this).attr('name')=='email' || $(this).attr('name')=='e-mail'){
                            var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                            if(reg.test($(this).val()) == false) {
                                alert("<div class=\"form_info_ico\"></div>Prosimy podać poprawny adres e-mail!");
                                $(this).focus();
                                currentFocus = $(this).attr('name');
                                currentFocusForm = $(this).parents('form').attr('name');
                                p++;
                                return false;
                            }
                        }else{
                            if($(this).val().length<3){
                                var tid=$(this).attr("id");
                                var nazwa=$(this).parents('li').find('label').text().replace(":","").replace("*","");
                                if(nazwa==''){
                                    var nazwa=$(this).parents('p').find('label').text().replace(":","").replace("*","");
                                }
                                alert("<div class=\"form_info_ico\"></div>Prosimy wypełnić wszystkie wymagane pola - "+nazwa+"!");
                                $(this).focus();
                                currentFocus = $(this).attr('name');
                                currentFocusForm = $(this).parents('form').attr('name');
                                p++;
                                return false;
                            }
                        }
                    }
                });
                if(p>0) {
                    return false;
                }
            }
        });
    }else{
        $(".input-submit").click(function(){
            if($("input[name$='order_summary']").length>0 && $("#order_price3").length>0){
                $("input[name$='order_summary']").val(parseInt($("#order_price3").html().replace(",00 zł netto","")));
            }

            var p=0;
            $(this).parents('form').find(":input").each(function(){
                $(this).blur();
                if($(this).attr('alt')=='req' || $(this).attr('alt')=='req2' || $(this).attr('title')=='req' || $(this).attr('title')=='req2'){
                    if($(this).attr('name')=='email' || $(this).attr('name')=='e-mail'){
                        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                        if(reg.test($(this).val()) == false) {
                            alert("<div class=\"form_info_ico\"></div>Prosimy podać poprawny adres e-mail!");
                            $(this).focus();
                            p++;
                            currentFocus = $(this).attr('name');
                            currentFocusForm = $(this).parents('form').attr('name');
                            return false;
                        }
                    }else{
                        if($(this).val().length<3){
                            var tid=$(this).attr("id");
                            var nazwa=$(this).parents('li').find('label').text().replace(":","").replace("*","");
                            if(nazwa==''){
                                var nazwa=$(this).parents('p').find('label').text().replace(":","").replace("*","");
                            }
                            alert("<div class=\"form_info_ico\"></div>Prosimy wypełnić wszystkie wymagane pola - "+nazwa+"!");
                            $(this).focus();
                            currentFocus = $(this).attr('name');
                            currentFocusForm = $(this).parents('form').attr('name');
                            p++;
                            return false;
                        }
                    }
                }
            });
            if(p>0) {
                return false;
            }
        });
    }



    
    $("#theme_name").change(function(){
        $(".demo_div").each(function(){
            $(this).hide();
        });
        $('#'+$(this).children(':selected').val()).show();
        $(".demo_div").each(function(){
            if($(this).attr("data-default-slide")!==undefined){
                var ds=$(this).attr("data-default-slide");
            }else{
                var ds=0;
            }
            $(this).find(".demo_submit").css({
                backgroundPosition: '0px -'+ds+'px'
            });
        })
    });

    $(".demo_div .left_arr_slide").click(function(){
        window.getSelection().removeAllRanges();
        var r=-1;
        $(".demo_div").each(function(){
            $(this).hide();
            r++;
        });
        var str=$(this).parent().attr("id");
        str=str.substr(4);
        if(parseInt(str)-1<0){
            var to=r;
        }else{
            var to=parseInt(str)-1;
        }
        $(".demo_div").each(function(){
            if($(this).attr("data-default-slide")!==undefined){
                var ds=$(this).attr("data-default-slide");
            }else{
                var ds=0;
            }
            $(this).find(".demo_submit").css({
                backgroundPosition: '0px -'+ds+'px'
            });
        })
        $('#demo'+to).show();
        $("#theme_name").val('demo'+to);
        $("#theme_name").parent().children('.text').text( $('#theme_name :selected').text() );
    });

    $(".demo_div .right_arr_slide").click(function(){
        window.getSelection().removeAllRanges();
        var rr=-1;
        var strr=$(this).parent().attr("id");
        $(".demo_div").each(function(){
            $(this).hide();
            rr++;
        });
        
        strr=strr.substr(4);
        if(parseInt(strr)+1>rr){
            //alert(parseInt(strr+1)+">"+rr);
            var to=0;
        }else{
            var to=parseInt(strr)+1;
        }
        $(".demo_div").each(function(){
            if($(this).attr("data-default-slide")!==undefined){
                var ds=$(this).attr("data-default-slide");
            }else{
                var ds=0;
            }
            $(this).find(".demo_submit").css({
                backgroundPosition: '0px -'+ds+'px'
            });
        })
        $('#demo'+to).show();
        $("#theme_name").val('demo'+to);
        $("#theme_name").parent().children('.text').text( $('#theme_name :selected').text() );
    });

	$('div.niceselect_warp select').change( function() {
		$(this).parent().children('.text').text( $(this).children(':selected').text() );
	} );

        $("#skads").change(function(){
            if($(this).val()=="inne"){$("#skad_tid").show();$("#skad_tid").focus();}else{$("#skad_tid").hide();}
        })

	preload_slider();
});
