function scrollToTop(){$(".go_top").click(function(){$("html, body").animate({scrollTop:"0px"},300);return false})}function popupOpen(){$("#rules").click(function(){var a=480;var b=625;var d=window.screenY+($(window).height()-a)/2+$(window).scrollTop();var c=window.screenX+($(window).width()-b)/2+$(window).scrollLeft();window.open(this.href,"rules","location=0,status=0,scrollbars=1,width=625,height=480,screenX="+c+",screenY="+d+",left="+c+",top="+d);return false})}function listenRegistrationForm(a){$("#reg_email, #reg_password, #reg_password_repeat").bind("focusout",function(d){var c=d.target,b=$(c);validateRegistrationForm(c.id,a)});$("#reg_agreement").live("focusout click",function(d){var c=d.target,b=$(c);validateRegistrationForm(c.id,a)})}function validateRegistrationForm(a,c){var b={};b.id=$("#reg_id").val();b.type=a;b.reg_email=$("#reg_email").val();b.reg_password=$("#reg_password").val();b.reg_password_repeat=$("#reg_password_repeat").val();if($("#reg_agreement").is(":checked")){b.reg_agreement=$("#reg_agreement").val()}else{b.reg_agreement=""}$.ajax({url:c,type:"post",data:b,success:function(e){if(a=="reg_agreement"){var d=$("#"+a+"_label")}else{var d=$("#"+a)}if(e!=""){$("#"+a+"_error").show();d.removeClass("success");d.addClass("error");$("#message_block").css("display","block");$("#message_type").addClass("error_message")}else{if($("#"+a).val()!=""){$("#"+a+"_error").hide();d.addClass("success");d.removeClass("error")}else{$("#"+a+"_error").hide();d.removeClass("error")}}$("#"+a+"_error").html(e);if($("#reg_email_error").html()==""&&$("#reg_password_error").html()==""&&$("#reg_password_repeat_error").html()==""&&$("#reg_agreement_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function listenDetailsTypes(c,b){var a=$("#"+b);a.bind("click",function(){loadDetailsTypes(c);$("#private").removeClass("buttoned black_link");$("#company").removeClass("buttoned black_link");a.addClass("buttoned black_link");return false})}function loadDetailsTypes(a){$.ajax({url:a,type:"get",success:function(b){$("#details").html(b)}})}function setDetailsParams(a){var b={};b.title=$("#title").val();if(a=="company"){b.responsible=$("#responsible").val();b.vat_code=$("#vat_code").val()}b.code=$("#code").val();b.country=$("#country").val();b.city=$("#city").val();b.address=$("#address").val();b.post_code=$("#post_code").val();b.phone=$("#phone").val();b.bank=$("#bank").val();b.account=$("#account").val();return b}function postDetails(b,a){$("#"+a+"_update").bind("click",function(){if(a=="private"){var c=setDetailsParams(a);c.id=$("#id").val();if($("#bills").is(":checked")){c.bills=$("#bills").val()}else{c.bills=""}}if(a=="company"){var c={};c.title=$("#title_c").val();c.responsible=$("#responsible_c").val();c.vat_code=$("#vat_code_c").val();c.code=$("#code_c").val();c.country=$("#country_c").val();c.city=$("#city_c").val();c.address=$("#address_c").val();c.post_code=$("#post_code_c").val();c.phone=$("#phone_c").val();c.bank=$("#bank_c").val();c.account=$("#account_c").val();c.id=$("#id_c").val();if($("#bills_c").is(":checked")){c.bills=$("#bills_c").val()}else{c.bills=""}}$.ajax({url:b,type:"post",data:c,success:function(d){if(d.search("#-")!=-1){window.location=d.substr(2)}else{$("#details").html(d);if($("#message_block_success")!=undefined&&$("#first")!=undefined){$("#first").hide()}}}});return false})}function listenDetails(b,a){if(a=="private"){$("#title, #code, #country, #city, #address, #post_code, #phone, #bank, #account").live("focusout",function(f){var d=f.target,c=$(d);validateDetails(d.id,b,a)})}if(a=="company"){$("#title_c, #responsible_c, #code_c, #vat_code_c, #country_c, #city_c, #address_c, #post_code_c, #phone_c, #bank_c, #account_c").live("focusout",function(f){var d=f.target,c=$(d);validateDetails(d.id,b,a)})}}function setFormStyles(c,a,b){$("#"+b+"_error").hide();if(c!=""){$("#"+b+"_error").show();a.removeClass("success");a.addClass("error");$("#message_block_success").css("display","none");$("#message_block").css("display","block")}else{if($("#"+b).val()!=""){a.addClass("success");a.removeClass("error")}else{a.removeClass("error")}}$("#"+b+"_error").html(c)}function validateDetails(a,d,b){if(b=="private"){var c=setDetailsParams(b);c.id=$("#id").val();c.type=a}if(b=="company"){var c={};c.title=$("#title_c").val();c.responsible=$("#responsible_c").val();c.vat_code=$("#vat_code_c").val();c.code=$("#code_c").val();c.country=$("#country_c").val();c.city=$("#city_c").val();c.address=$("#address_c").val();c.post_code=$("#post_code_c").val();c.phone=$("#phone_c").val();c.bank=$("#bank_c").val();c.account=$("#account_c").val();c.id=$("#id_c").val();c.type=a.substr(0,a.length-2)}$.ajax({url:d,type:"post",data:c,success:function(f){var e=$("#"+a);if(b=="private"){setFormStyles(f,e,a)}if(b=="company"){$("#"+a+"_error").hide();if(f!=""){$("#"+a+"_error").show();e.removeClass("success");e.addClass("error");$("#message_block_success_c").css("display","none");$("#message_block_c").css("display","block")}else{if($("#"+a).val()!=""){e.addClass("success");e.removeClass("error")}else{e.removeClass("error")}}$("#"+a+"_error").html(f)}if(b=="private"){if($("#title_error").html()==""&&$("#code_error").html()==""&&$("#country_error").html()==""&&$("#city_error").html()==""&&$("#address_error").html()==""&&$("#post_code_error").html()==""&&$("#phone_error").html()==""&&$("#bank_error").html()==""&&$("#account_error").html()==""){$("#message_block").css("display","none")}}if(b=="company"){if($("#title_error_c").html()==""&&$("#responsible_error_c").html()==""&&$("#code_error_c").html()==""&&$("#vat_code_error_c").html()==""&&$("#country_error_c").html()==""&&$("#city_error_c").html()==""&&$("#address_error_c").html()==""&&$("#post_code_error_c").html()==""&&$("#phone_error_c").html()==""&&$("#bank_error_c").html()==""&&$("#account_error_c").html()==""){$("#message_block").css("display","none")}}}})}function listenPasswordForm(a){$("#password, #password_new, #password_new_repeat").bind("focusout",function(d){var c=d.target,b=$(c);validatePasswordForm(c.id,a)})}function validatePasswordForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.password=$("#password").val();b.password_new=$("#password_new").val();b.password_new_repeat=$("#password_new_repeat").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);setFormStyles(e,d,a);if($("#password_error").html()==""&&$("#password_new_error").html()==""&&$("#password_new_repeat_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function listenWebsiteNewForm(a){$("#url").bind("focusout",function(d){var c=d.target,b=$(c);validateWebsiteNewForm(c.id,a)})}function validateWebsiteNewForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.url=$("#url").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);setFormStyles(e,d,a);if($("#url_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function selectCode(){$("#code").click(function(c){var b=c.target,a=$(b);b.select();return false})}function slider(a){$("#slider").slider({value:a,min:1,max:700,slide:function(b,c){$("#price").val(c.value)}});$("#price").val($("#slider").slider("value"));$("#price").bind("keyup",function(){$("#slider").slider("value",$("#price").val())})}function listenWebsiteForm(a){$("#title, #url, #keywords, #description, #price").bind("focusout",function(d){var c=d.target,b=$(c);validateWebsiteForm(c.id,a)})}function validateWebsiteForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.title=$("#title").val();b.url=$("#url").val();b.keywords=$("#keywords").val();b.description=$("#description").val();b.price=$("#price").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);if(e!=""){$("#message_block_ga").css("display","none")}setFormStyles(e,d,a);if($("#title_error").html()==""&&$("#url_error").html()==""&&$("#keywords_error").html()==""&&$("#description_error").html()==""&&$("#price_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function listenWidgetForm(a){$("#widget_title, #widget_ads, #widget_background, #widget_border, #widget_language_id").bind("focusout",function(d){var c=d.target,b=$(c);validateWidgetForm(c.id,a)})}function validateWidgetForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.widget_title=$("#widget_title").val();b.widget_ads=$("#widget_ads").val();b.widget_background=$("#widget_background").val();b.widget_border=$("#widget_border").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);setFormStyles(e,d,a);if($("#widget_title_error").html()==""&&$("#widget_ads_error").html()==""&&$("#widget_background_error").html()==""&&$("#widget_border_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function loadColorPicker(a){var b=$("#"+a);b.css("backgroundColor",b.val());setColors(a,b.val());b.ColorPicker({onBeforeShow:function(){$(this).ColorPickerSetColor(this.value)},onChange:function(c,e,d){b.val("#"+e);b.css("backgroundColor","#"+e);setColors(a,"#"+e)}}).bind("keyup change",function(){$(this).ColorPickerSetColor(this.value);b.css("backgroundColor",this.value);setColors(a,this.value)})}function setColors(b,a){if(b=="widget_background"){$("#preview").css("backgroundColor",a)}if(b=="widget_border"){$("#preview").css("borderColor",a)}}function setTexts(){$("#widget_title").bind("keyup",function(){$("#widget_title_preview").html($("#widget_title").val())});$("#widget_ads").bind("keyup",function(){$("#widget_ads_preview").html($("#widget_ads").val())})}function remove(a,e,b,f){$(".ui_tabs").tabs();var d={};d.id=f;var c={};c[a]=function(){$.ajax({url:b,type:"post",data:d,success:function(g){if(g!=""){window.location=g}}})};c[e]=function(){$(this).dialog("close")};$(".remove").bind("click",function(){$("#remove").dialog({height:"auto",width:480,modal:true,buttons:c});return false})}function listenPageForm(a){$("#parent_id, #title, #content").bind("focusout",function(d){var c=d.target,b=$(c);validatePageForm(c.id,a)})}function validatePageForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.parent_id=$("#parent_id").val();b.title=$("#title").val();b.content=$("#content").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);setFormStyles(e,d,a);if($("#parent_id_error").html()==""&&$("#title_error").html()==""&&$("#content_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function listenCategoryForm(a){$("#title").bind("focusout",function(d){var c=d.target,b=$(c);validateCategoryForm(c.id,a)})}function validateCategoryForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.title=$("#title").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);setFormStyles(e,d,a);if($("#title_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function listenCart(c,b,a){$(".cart_"+b).bind("click keyup",function(h){var g=h.target,d=$(g);if(b!="change"){var f=g.href.split("#");var i=f[1]}else{var i=$(".cart_"+b).val()}sendCart(c,i,b,a);return false})}function sendCart(d,e,b,a){var c={};c.id=e;c.type=b;c.button=a;$.ajax({url:d,type:"post",data:c,success:function(f){if(b=="add"){$("#add-website-"+e).fadeOut();$("#added-website-"+e).fadeIn();$("#cart").html(f);$("html, body").animate({scrollTop:"0px"},300)}if(b=="remove"){if(!a){$("#add-website-"+e).fadeIn();$("#added-website-"+e).fadeOut()}if(f.search("#-")!=-1){window.location=f.substr(2)}else{$("#cart").html(f)}}}})}function listenOrderForm(a){$("#url, #title, #from, #duration").bind("focusout",function(d){var c=d.target,b=$(c);validateOrderForm(c.id,a)})}function validateOrderForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.url=$("#url").val();b.title=$("#title").val();b.from=$("#from").val();b.duration=$("#duration").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);setFormStyles(e,d,a);if($("#url_error").html()==""&&$("#title_error").html()==""&&$("#from_error").html()==""&&$("#duration_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function listenCampaignForm(a){$("#url, #title, #from").bind("focusout",function(d){var c=d.target,b=$(c);validateCampaignForm(c.id,a)})}function validateCampaignForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.url=$("#url").val();b.title=$("#title").val();b.from=$("#from").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);setFormStyles(e,d,a);if($("#url_error").html()==""&&$("#title_error").html()==""&&($("#from_error").html()==""||$("#from_error").html()==null)){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function postUsers(c,b,a){$("#"+b+"_update").bind("click",function(){if(b=="private"){var e=setDetailsParams(b);e.id=$("#id").val();e.key=$("#key").val();if($("#bills").is(":checked")){e.bills=$("#bills").val()}else{e.bills=""}if($("#vat_pay").is(":checked")){e.vat_pay=$("#vat_pay").val()}else{e.vat_pay=""}if($("#active").is(":checked")){e.active=$("#active").val()}else{e.active=""}for(var d=1;d<=a;d++){if($("#right-"+d).is(":checked")){e["right-"+d]=$("#right-"+d).val()}else{e["right-"+d]=""}}}if(b=="company"){var e={};e.title=$("#title_c").val();e.responsible=$("#responsible_c").val();e.vat_code=$("#vat_code_c").val();e.code=$("#code_c").val();e.country=$("#country_c").val();e.city=$("#city_c").val();e.address=$("#address_c").val();e.post_code=$("#post_code_c").val();e.phone=$("#phone_c").val();e.bank=$("#bank_c").val();e.account=$("#account_c").val();e.id=$("#id_c").val();if($("#bills_c").is(":checked")){e.bills=$("#bills_c").val()}else{e.bills=""}if($("#vat_pay_c").is(":checked")){e.vat_pay=$("#vat_pay_c").val()}else{e.vat_pay=""}if($("#active_c").is(":checked")){e.active=$("#active_c").val()}else{e.active=""}for(var d=1;d<=a;d++){if($("#right-"+d+"_c").is(":checked")){e["right-"+d]=$("#right-"+d+"_c").val()}else{e["right-"+d]=""}}}$.ajax({url:c,type:"post",data:e,success:function(f){$("#details").html(f)}});return false})}function listenPayoutForm(b,a){$("#amount").bind("focusout",function(f){var d=f.target,c=$(d);validatePayoutForm(d.id,b,a)})}function validatePayoutForm(b,d,a){var c={};c.id=$("#id").val();c.type=b;c.amount=$("#amount").val();c.org_amount=a;$.ajax({url:d,type:"post",data:c,success:function(f){var e=$("#"+b);setFormStyles(f,e,b);if($("#amount_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}}})}function listenTabs(a){$(".ui_tabs").tabs({selected:a,show:function(c,d){calcSpinner()}});var b=$("#tab_create");if(b!=undefined){b.click(function(){$(".ui_tabs").tabs("select",2);return false})}}function listenWidgetForm(a){$("#url, #title, #from, #duration").bind("focusout",function(d){var c=d.target,b=$(c);validateWidgetForm(c.id,a)})}function validateWidgetForm(a,c){var b={};b.id=$("#id").val();b.type=a;b.url=$("#url").val();b.title=$("#title").val();b.from=$("#from").val();b.duration=$("#duration").val();$.ajax({url:c,type:"post",data:b,success:function(e){var d=$("#"+a);setFormStyles(e,d,a);if($("#url_error").html()==""&&$("#title_error").html()==""&&$("#from_error").html()==""&&$("#duration_error").html()==""){$("#message_block").css("display","none");$("#message_type").removeClass("error_message")}calcSpinner()}})}function listenDuration(a,b){$("#duration").bind("keyup change",function(g){var f=g.target,c=$(f);var d={};d.id=b;if(f.value<1){d.duration=1;$("#duration").val(1)}else{d.duration=f.value}$.ajax({url:a,type:"post",data:d,success:function(j){var h=j.split("-");var i=parseFloat(h[0]);var e=parseFloat(h[1]);$("#price").html(i.toFixed(2));$("#price_with_vat").html(e.toFixed(2));calcSpinner()}})})}function listenToggle(){var a=$("#toggle");a.bind("click",function(c){var b=$("#is_upload");if(a.is(":checked")){b.show()}else{b.hide()}calcSpinner()})}function calcSpinner(){if($("#duration").offset()!=null){var a=$("#duration").offset().top-66;$(".ui-spinner").css("top",a+"px")}}function billView(){$(".bills").click(function(){var a=800;var b=720;var d=window.screenY+($(window).height()-a)/2+$(window).scrollTop();var c=window.screenX+($(window).width()-b)/2+$(window).scrollLeft();window.open(this.href,"rules","location=0,status=0,scrollbars=0,width=720,height=800,screenX="+c+",screenY="+d+",left="+c+",top="+d);return false})}function loadWidgetDetailsTypes(c,b,a){$.ajax({url:c,type:"get",data:{key:a},success:function(d){$("#tabs-"+b).html(d)}})}function postWidgetDetails(c,b,d,a){$("#"+b+"_update").bind("click",function(){if(b=="private"){var e=setDetailsParams(b);e.id=$("#id").val();e.key=$("#key").val()}if(b=="company"){var e={};e.title=$("#title_c").val();e.responsible=$("#responsible_c").val();e.vat_code=$("#vat_code_c").val();e.code=$("#code_c").val();e.country=$("#country_c").val();e.city=$("#city_c").val();e.address=$("#address_c").val();e.post_code=$("#post_code_c").val();e.phone=$("#phone_c").val();e.bank=$("#bank_c").val();e.account=$("#account_c").val();e.id=$("#id_c").val();e.key=$("#key_c").val()}$.ajax({url:c,type:"post",data:e,success:function(f){$("#tabs-"+d).html(f)}});return false})}function listenWidgetDetails(b,a){if(a=="private"){$("#title, #code, #country, #city, #address, #post_code, #phone, #bank, #account").live("focusout",function(f){var d=f.target,c=$(d);validateWidgetDetails(d.id,b,a)})}if(a=="company"){$("#title_c, #responsible_c, #code_c, #vat_code_c, #country_c, #city_c, #address_c, #post_code_c, #phone_c, #bank_c, #account_c").live("focusout",function(f){var d=f.target,c=$(d);validateWidgetDetails(d.id,b,a)})}}function validateWidgetDetails(a,d,b){if(b=="private"){var c=setDetailsParams(b);c.id=$("#id").val();c.type=a}if(b=="company"){var c={};c.title=$("#title_c").val();c.responsible=$("#responsible_c").val();c.vat_code=$("#vat_code_c").val();c.code=$("#code_c").val();c.country=$("#country_c").val();c.city=$("#city_c").val();c.address=$("#address_c").val();c.post_code=$("#post_code_c").val();c.phone=$("#phone_c").val();c.bank=$("#bank_c").val();c.account=$("#account_c").val();c.id=$("#id_c").val();c.type=a.substr(0,a.length-2)}$.ajax({url:d,type:"post",data:c,success:function(f){var e=$("#"+a);if(b=="private"){setFormStyles(f,e,a)}if(b=="company"){$("#"+a+"_error").hide();if(f!=""){$("#"+a+"_error").show();e.removeClass("success");e.addClass("error");$("#message_block_success_c").css("display","none");$("#message_block_c").css("display","block")}else{if($("#"+a).val()!=""){e.addClass("success");e.removeClass("error")}else{e.removeClass("error")}}$("#"+a+"_error").html(f)}if(b=="private"){if($("#title_error").html()==""&&$("#code_error").html()==""&&$("#country_error").html()==""&&$("#city_error").html()==""&&$("#address_error").html()==""&&$("#post_code_error").html()==""&&$("#phone_error").html()==""&&$("#bank_error").html()==""&&$("#account_error").html()==""){$("#message_block").css("display","none")}}if(b=="company"){if($("#title_error_c").html()==""&&$("#responsible_error_c").html()==""&&$("#code_error_c").html()==""&&$("#vat_code_error_c").html()==""&&$("#country_error_c").html()==""&&$("#city_error_c").html()==""&&$("#address_error_c").html()==""&&$("#post_code_error_c").html()==""&&$("#phone_error_c").html()==""&&$("#bank_error_c").html()==""&&$("#account_error_c").html()==""){$("#message_block").css("display","none")}}}})}function sliderRange(e,c,f,d,b,a){$("#slider-range").slider({range:true,min:c,max:f,values:[d,b],slide:function(g,h){$("#price").html(h.values[0]+" "+a+" - "+h.values[1]+" "+a)},change:function(g,h){window.location=e+"&price_min="+h.values[0]+"&price_max="+h.values[1]}});$("#price").html($("#slider-range").slider("values",0)+" "+a+" - "+$("#slider-range").slider("values",1)+" "+a)}function sliderRange2(d,b,e,c,a){$("#slider-range2").slider({range:true,min:b,max:e,values:[c,a],slide:function(f,g){$("#impressions").html(g.values[0]+" - "+g.values[1])},change:function(f,g){window.location=d+"&impressions_min="+g.values[0]+"&impressions_max="+g.values[1]}});$("#impressions").html($("#slider-range2").slider("values",0)+" - "+$("#slider-range2").slider("values",1))}function sliderRange3(d,b,e,c,a){$("#slider-range3").slider({range:true,min:b,max:e,values:[c,a],slide:function(f,g){$("#visits").html(g.values[0]+" - "+g.values[1])},change:function(f,g){window.location=d+"&visits_min="+g.values[0]+"&visits_max="+g.values[1]}});$("#visits").html($("#slider-range3").slider("values",0)+" - "+$("#slider-range3").slider("values",1))}function thumbs(b,a){$("#"+b).qtip({content:'<img src="'+a+'" alt="" />',show:"mouseover",hide:"mouseout",position:{corner:{target:"rightMiddle",tooltip:"leftMiddle"}},style:{width:320}})}function bonus(){var c=document.cookie.match("(^|;) ?bonus=([^;]*)(;|$)");if(c){}else{var b=new Date();b.setTime(b.getTime()+(90*24*60*60*1000));var a="; expires="+b.toGMTString();document.cookie="bonus=1"+a+"; path=/;";$("#bonus").wowwindow({draggable:true,rotate:true,rotations:3,width:450,height:200})}}function changeCode(){$("#widget_language_id").bind("change",function(){var a=$("#code");var b=a.val();b=b.substr(0,b.length-13)+$("#widget_language_id option:selected").text().toLowerCase()+'"><\/script>';a.val(b)})};
