var control_interval=-1;var interval=4;var hasFocus=false;var hasMouse=false;var stopMoving=false;function prev(){stopMoving=false;var d=$(".control .item").index($(".control .active"));var c=(d+control_items-1)%control_items;hide(d);show(c);return false}function next(){if(!stopMoving){var d=$(".control .item").index($(".control .active"));var c=(d+1)%control_items;hide(d);show(c)}return false}function itemClick(){var d=$(".control .item").index($(".control .active"));var c=$(".control .item").index(this);if(d==c){return false}hide(d);show(c);return false}function hide(b){$(".control .item").eq(b).removeClass("active");$(".visual-item").eq(b).hide()}function show(d){var c=$(".visual-item").eq(d).find(":input[type=hidden][name=openspace]");if(c.length>0){$(".visual-item").eq(d).find(".ajaxloader").show();timerStop();$.ajax({url:resources.base_url+"Templates/Planet3/Pages/OpenSpaceAjax.aspx?openspace="+c.val()+"&uiculture="+resources.uiculture,datatype:"html",timeout:5000,error:function(){if(control_items>1){timerStart()}},success:function(a){$(".visual-item").eq(d).html(a);if(control_items>1){timerStart()}if(a.indexOf("player.vimeo.com">0)){VimeoEmbed.init()}}})}$(".control .item").eq(d).addClass("active");$(".visual-item").eq(d).show()}function timerStart(){if(control_interval==-1){control_interval=setInterval("next()",interval*1000)}}function timerStop(){clearInterval(control_interval);control_interval=-1}function onFocus(){stopMoving=true}function onMouseEnter(){hasMouse=true;timerStop()}function onMouseLeave(){hasMouse=false;if(!hasFocus&&control_items>1){timerStart()}}var districtBox=null;function LoadDistrictAjax(){$(".actphProvinces").change(function(){var b=$(this).val();districtBox=$(this).parents(".top-form").find(".actphDistricts");$.getJSON(resources.base_url+"Templates/Planet3/Handlers/GetDistricts.ashx?uiculture="+resources.uiculture+"&province="+b,function(a){$("option:gt(0)",districtBox).remove();for(district in a){$(districtBox).append('<option value="'+a[district].DatabaseId+'">'+a[district].Translations[resources.uiculture]+"</option>")}})})}function onSubmit(){var D=$(this).parents(".visual-item");var v=$("input[id$=hidActionPageId]",D).val();var M=$("input[id$=phFirstAndLastName1]",D).val();var w=$("input[id$=phFirstAndLastName2]",D).val();var I=$("input[id$=phEmailAddress]",D).val();var K=$("select[id$=phProvinces]",D).val();var z=$("select[id$=phDistricts]",D).val();var u=$("select[id$=phCountry]",D).val();var H=$("input[id$=phPhone]",D).val();var F=$("input[id$=phCellPhone]",D).val();var L=$("input[id$=phCellPhoneParts1]",D).val();var G=$("input[id$=phCellPhoneParts2]",D).val();var E=$("select[id$=phCellPhoneProvider]",D).val();var C=$("input[id$=phAge]",D).val();var x=$("input[id$=id7]",D).is(":checked")?"true":"false";if(M==resources.openspace_action_firstname){M=""}if(w==resources.openspace_action_lastname){w=""}if(I==resources.openspace_action_email){I=""}if(H==resources.openspace_action_phone){H=""}if(F==resources.openspace_action_cellphone){F=""}if(L==resources.openspace_action_cellphonepart1){L=""}if(G!=resources.openspace_action_cellphonepart2){G=""}if(C==resources.openspace_action_age){C=""}var B="";if($("select[id$=ddlDays1]",D).length||$("select[id$=ddlDays2]",D).length){var A,J,y;if($("select[id$=ddlDays1]",D).length){A=$("select[id$=ddlDays1]",D).val();J=parseInt($("select[id$=ddlMonths1]",D).val())+1;y=$("input[id$=txtYear1]",D).val()}else{A=$("select[id$=ddlDays2]",D).val();J=parseInt($("select[id$=ddlMonths2]",D).val())+1;y=$("input[id$=txtYear2]",D).val()}if(!(isNaN(A)||isNaN(J)||isNaN(y))){B=A+"."+J+"."+y}}var N="action="+v+"&email="+(I!=undefined?I:"")+"&firstname="+(M!=undefined?M:"")+"&lastname="+(w!=undefined?w:"")+"&province="+(K!=undefined?K:"")+"&district="+(z!=undefined?z:"")+"&country="+(u!=undefined?u:"")+"&phone="+(H!=undefined?H:"")+"&cellphone="+(F!=undefined?F:"")+"&cellphonepart1="+(L!=undefined?L:"")+"&cellphonepart2="+(L!=undefined?G:"")+"&cellphoneprovider="+(E!=undefined?E:"")+"&age="+(C!=undefined?C:"")+"&birthdate="+(B!=undefined?B:"")+"&sendupdates="+(x!=undefined?x:"")+"&pageid="+(v);$(".update-form *[class*=param~]",D).each(function(){var c=jQuery.grep($(this).attr("class").split(" "),function(e,d){return(e.indexOf("param~")==0)})[0].split("~")[1];if(this.nodeName.toLowerCase()=="input"||this.nodeName.toLowerCase()=="textarea"){var b=$(this).val();if(b==$("span.seo",$(this).parent()).text()){b=""}N+="&"+c+"="+b}else{if(this.nodeName.toLowerCase()=="select"){N+="&"+c+"="+$(this).val()}else{if(this.nodeName.toLowerCase()=="table"){var b="";var a=$("input:checked",this);a.each(function(){if($(this).attr("type")=="checkbox"){b=b==""?$(this).parent().attr("class"):","+$(this).parent().attr("class")}else{b=b==""?$(this).val():","+$(this).val()}});N+="&"+c+"="+b}else{N+="&"+c+"="}}}});$.ajax({url:resources.base_url+"Templates/Planet3/Pages/ActionAjax.aspx",type:"POST",datatype:"html",data:N,timeout:10000,error:function(){var a=$("input[id$=hidActionPageURL]",D).val()+"?"+N;location.href=a},success:function(a){try{var d=$("input[id$=hidGoogleAnalyticsCode]").val();var b=$("input[id$=hidActionThankYouPageURL]").val();if(d!=""&&b!=""){_gaq.push(["_setAccount",d],["_trackPageview",b])}}catch(c){}D.html(a)}});return false}function onPlayerStart(b){stopMoving=true}function onPlayerComplete(b){stopMoving=false}function onPlayerPreAdInit(f,g,i,j,h){stopMoving=true}function onYouTubePlayerReady(b){ytplayer=$("#"+b)[0];ytplayer.addEventListener("onStateChange","onytplayerStateChange")}function onytplayerStateChange(b){if(b>0){stopMoving=true}if(b==0){stopMoving=false}}var VimeoEmbed={};VimeoEmbed.addEvents=function(){Froogaloop.init();$(".visual-wrapper iframe").each(function(d,c){c.addEvent("onLoad",VimeoEmbed.vimeo_player_loaded)})};VimeoEmbed.init=function(b){if(typeof Froogaloop!="object"){$.getScript(resources.base_url+"Templates/Planet3/Javascripts/generic/froogaloop.min.js",VimeoEmbed.addEvents)}else{VimeoEmbed.addEvents()}};VimeoEmbed.vimeo_player_loaded=function(b){VimeoEmbed.setupAPIEventListeners($("#"+b).get(0))};VimeoEmbed.setupAPIEventListeners=function(b){b.addEvent("onPlay",VimeoEmbed.vimeo_on_play)};VimeoEmbed.vimeo_on_play=function(b){stopMoving=true};$(function(){control_items=$(".control .item").length;$(".control .left").click(prev);$(".control .right").bind("click",function(){stopMoving=false;return next()});$(".control .item").click(itemClick);$("#visual").bind("mouseenter",onMouseEnter).bind("mouseleave",onMouseLeave);$("#visual input:text").focus(onFocus);$("#visual").bind("click",function(){stopMoving=true});if($("#visual").attr("class")){interval=$("#visual").attr("class").substr(16)}if(control_items>1){timerStart()}$(".bottom-form .btn-sign-up").click(onSubmit);$(".top-form input[type='text'], .top-form textarea").bind("focus",function(){if($(this).val()==$("span.seo",$(this).parent()).text()){$(this).val("")}}).bind("blur",function(){if($(this).val()==""){$(this).val($("span.seo",$(this).parent()).text())}});LoadDistrictAjax();if($("#content div p > a").length>0){$("#content div p > a:not(:has(img))").each(function(){Main.ApplyLinkIcons($(this))})}$(".embedinfo-video input").focus(function(){$(this).select()});if(typeof Froogaloop=="object"){VimeoEmbed.init()}});
