var control_interval=-1;var interval=4;var hasFocus=false;var hasMouse=false;var stopMoving=false;function prev(){stopMoving=false;var c=$(".control .item").index($(".control .active"));var d=(c+control_items-1)%control_items;hide(c);show(d);return false}function next(){if(!stopMoving){var c=$(".control .item").index($(".control .active"));var d=(c+1)%control_items;hide(c);show(d)}return false}function itemClick(){var c=$(".control .item").index($(".control .active"));var d=$(".control .item").index(this);if(c==d){return false}hide(c);show(d);return false}function hide(b){$(".control .item").eq(b).removeClass("active");$(".visual-item").eq(b).hide()}function show(c){var d=$(".visual-item").eq(c).find(":input[type=hidden][name=openspace]");if(d.length>0){$(".visual-item").eq(c).find(".ajaxloader").show();timerStop();$.ajax({url:resources.base_url+"Templates/Planet3/Pages/OpenSpaceAjax.aspx?openspace="+d.val()+"&uiculture="+resources.uiculture,datatype:"html",timeout:5000,error:function(){if(control_items>1){timerStart()}},success:function(a){$(".visual-item").eq(c).html(a);if(control_items>1){timerStart()}if(a.indexOf("player.vimeo.com">0)){VimeoEmbed.init()}}})}$(".control .item").eq(c).addClass("active");$(".visual-item").eq(c).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 y=$(this).parents(".visual-item");var A=$("input[id$=hidActionPageId]",y).val();var G=$("input[id$=phFirstAndLastName1]",y).val();var x=$("input[id$=phFirstAndLastName2]",y).val();var z=$("input[id$=phEmailAddress]",y).val();var M=$("select[id$=phProvinces]",y).val();var H=$("select[id$=phDistricts]",y).val();var E=$("select[id$=phCountry]",y).val();var w=$("input[id$=phPhone]",y).val();var u=$("input[id$=phCellPhone]",y).val();var C=$("input[id$=phCellPhoneParts1]",y).val();var B=$("input[id$=phCellPhoneParts2]",y).val();var I=$("select[id$=phCellPhoneProvider]",y).val();var v=$("input[id$=phAge]",y).val();var N=$("input[id$=id7]",y).is(":checked")?"true":"false";if(G==resources.openspace_action_firstname){G=""}if(x==resources.openspace_action_lastname){x=""}if(z==resources.openspace_action_email){z=""}if(w==resources.openspace_action_phone){w=""}if(u==resources.openspace_action_cellphone){u=""}if(C==resources.openspace_action_cellphonepart1){C=""}if(B!=resources.openspace_action_cellphonepart2){B=""}if(v==resources.openspace_action_age){v=""}var L="";if($("select[id$=ddlDays1]",y).length||$("select[id$=ddlDays2]",y).length){var J,D,K;if($("select[id$=ddlDays1]",y).length){J=$("select[id$=ddlDays1]",y).val();D=parseInt($("select[id$=ddlMonths1]",y).val())+1;K=$("input[id$=txtYear1]",y).val()}else{J=$("select[id$=ddlDays2]",y).val();D=parseInt($("select[id$=ddlMonths2]",y).val())+1;K=$("input[id$=txtYear2]",y).val()}if(!(isNaN(J)||isNaN(D)||isNaN(K))){L=J+"."+D+"."+K}}var F="action="+A+"&email="+(z!=undefined?z:"")+"&firstname="+(G!=undefined?G:"")+"&lastname="+(x!=undefined?x:"")+"&province="+(M!=undefined?M:"")+"&district="+(H!=undefined?H:"")+"&country="+(E!=undefined?E:"")+"&phone="+(w!=undefined?w:"")+"&cellphone="+(u!=undefined?u:"")+"&cellphonepart1="+(C!=undefined?C:"")+"&cellphonepart2="+(C!=undefined?B:"")+"&cellphoneprovider="+(I!=undefined?I:"")+"&age="+(v!=undefined?v:"")+"&birthdate="+(L!=undefined?L:"")+"&sendupdates="+(N!=undefined?N:"")+"&pageid="+(A);$(".update-form *[class*=param~]",y).each(function(){var b=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 a=$(this).val();if(a==$("span.seo",$(this).parent()).text()){a=""}F+="&"+b+"="+a}else{if(this.nodeName.toLowerCase()=="select"){F+="&"+b+"="+$(this).val()}else{if(this.nodeName.toLowerCase()=="table"){var a="";var c=$("input:checked",this);c.each(function(){if($(this).attr("type")=="checkbox"){a=a==""?$(this).parent().attr("class"):","+$(this).parent().attr("class")}else{a=a==""?$(this).val():","+$(this).val()}});F+="&"+b+"="+a}else{F+="&"+b+"="}}}});$.ajax({url:resources.base_url+"Templates/Planet3/Pages/ActionAjax.aspx",type:"POST",datatype:"html",data:F,timeout:10000,error:function(){var a=$("input[id$=hidActionPageURL]",y).val()+"?"+F;location.href=a},success:function(a){try{var c=$("input[id$=hidGoogleAnalyticsCode]").val();var b=$("input[id$=hidActionThankYouPageURL]").val();if(c!=""&&b!=""){_gaq.push(["_setAccount",c],["_trackPageview",b])}}catch(d){}y.html(a)}});return false}function onPlayerStart(b){stopMoving=true}function onPlayerComplete(b){stopMoving=false}function onPlayerPreAdInit(j,f,h,i,g){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()}});
