Portal.Details=$H({DropDowns:$H({}),initDetails:function(){$$("table.Quickfacts tr:even").addClass("EvenClass");$$("table.Quickfacts td:even").addClass("EvenClass");if(!$("DetailsHeader")){return false}var c=$("DetailsHeader").getElement("h1 span");if(c.getSize().x>"520"){c.getParent("h1").addClass("LargeTitle")}var b=$("DetailsHeader").getElement("h2 span");if(b){Portal.truncate(b,55)}var a=$("greyNoticeHide");if(a){$("maxNotice").setStyle("display","none");a.addEvent("click",this.toggleSize.pass(a))}var e=$$("ol.LinksList");if($defined(e)){this.setupShowLinks()}var d=$$("div.InquiryFormMini").length;if(d>0){this.initInquiryForm()}},validateEmail:function(a){a=a.clean();var c=/^([a-zA-Z0-9_\.\-\+%])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;var b=a.test(c);return b},getProgrammeId:function(){return $("GetProgrammeId").value.toInt()},initInquiryForm:function(){var a=this;$$("a.ExpandInquiry").each(function(b){b.addEvent("click",function(){var d=b.id.toString().substring(0,2);var c=$(d+"_email").value;if(a.validateEmail(c)){$(d+"_e_email").hide();inputs=new Array("first_name","last_name","email");inputs.each(function(e){if($(d+"_"+e).get("value")!==""){$(e).value=$(d+"_"+e).get("value").trim()}});a.fillInquiryForm(c)}else{$(d+"_e_email").show();return false}})})},fillInquiryForm:function(a){instance_id=$("GetInstanceId").value.toInt();var b=Cookie.read("StudyPortals_Inquiry");if(b){new Request({url:"Ajax.php",method:"get",data:"email="+a+"&hash="+b+"&instance_id="+instance_id,onSuccess:(function(d,c){this.instaFill(d)}.bind(this))}).send()}else{}this.expandInquiryForm()},showInquiryTab:function(){var a=$$("ul.Tabs li").getLast();if($(a.id)){Tabs.showTab(a.id)}},expandInquiryForm:function(){this.showInquiryTab();if($("InquiryBottom")){$("InquiryBottom").hide()}if($("AskAQuestion")){$("AskAQuestion").removeClass("SmallContent");$("AskAQuestion").hide()}if($("InquiryForm")){var a=$("InquiryForm").getSize().y;$("InquiryFormContainer").setStyle("height","100%")}if($("TestTaken")){this.setupProficiency()}return false},setupProficiency:function(){if($("TestTaken").getProperty("checked")==true){$("TestOverview").show()}else{$("TestOverview").hide()}$$("input[name=proficiency_type]").each(function(a){a.addEvent("click",function(){if(a.id=="TestTaken"){$("TestOverview").show()}else{$("TestOverview").hide()}})});$$("input[name=proficiency_test]").each(function(a){a.addEvent("click",function(){$$("table#TestOverview tr").each(function(b){if(!b.hasClass("NotSelected")){b.addClass("NotSelected")}});p=a.getParent("tr");p.removeClass("NotSelected")});p=a.getParent("tr");if(a.getProperty("checked")==false){if(!p.hasClass("NotSelected")){p.addClass("NotSelected")}}})},instaFill:function(b){var a=JSON.decode(b);$each(a,function(e,c){switch(c){case"first_name":case"last_name":case"email":case"telephone":case"address":case"questions":case"accomplishments":case"work_experience":if($(c)){$(c).value=e}break;case"birth_date":var f=e.split("-");setSelected("select.Year",f[0].toInt());setSelected("select.Month",f[1].toInt());setSelected("select.Day",f[2].toInt());break;case"title":case"gender":setRadio(c,e);break;case"start_period":setSelected("select#"+c,e);break;case"funding_type":setSelected("select#funding_type",e);break;case"study_country":setSelected("select#study_country",e);break;case"nationality":setSelected("select#nationality",e);break;case"study_level":setSelected("select#study_level",e);break;case"proficiency_type":if(e==1){el=$("NativeSpeaker")}if(e==2){el=$("TestTaken")}if(e==3){el=$("WillTakeTest")}if(el){el.setProperty("checked",true);el.fireEvent("click")}break;case"proficiency_test":setRadio(c,e);break;case"proficiency_score":$$("input[name=proficiency_test]").each(function(d){if(d.id==a.proficiency_test){d.getParent().getParent().getElements("input.ScoreBox").each(function(g){g.value=e})}});break;default:break}}.bind(this))},setupShowLinks:function(){if($("moreLinks")){var a=$("moreLinks");var b=$$("ol.LinksList li.hidden");b.setStyle("display","none");a.addEvent("click",function(){a.setStyle("display","none");b.setStyle("opacity","0.0");b.setStyle("display","list-item");b.set("tween",{property:"opacity",duration:400});b.tween([0,1])})}},toggleSize:function(c){var b=$("greyNotice");var a=$("greyNoticeContent");b.set("tween",{property:"max-height",duration:500,transition:Fx.Transitions.Quart.easeInOut,onComplete:function(){a.setStyle("visibility","visible");if(b.hasClass("IconMini")){b.removeClass("IconMini")}else{b.addClass("IconMini")}}});if(b.hasClass("IconMini")){a.setStyle("visibility","hidden");c.getElement("#minNotice").show();c.getElement("#maxNotice").hide();b.tween([15,115])}else{a.setStyle("visibility","hidden");c.getElement("#minNotice").hide();c.getElement("#maxNotice").show();b.tween([115,15])}}});window.addEvent("domready",function(){Portal.Details.initDetails();if($("InquiryResult")){lb=new Lightbox();lb.show($("InquiryResult"))}var b=new URI(window.location);var c=b.get("fragment");if(c=="inquiry"){Portal.Details.expandInquiryForm()}if($("InquiryForm")){var a=$("InquiryForm").getElement("abbr.Error");if(a){window.scrollTo(0,a.getPosition().y.toInt()-20)}}});var Lightbox=new Class({show:function(c){dsize=window.getScrollSize();wsize=window.getSize();this.content=c;this.lb=new Element("div",{id:"LightBox",styles:{position:"absolute",top:0,left:0,width:wsize.x,height:dsize.y,"background-color":"#000000",opacity:0,"z-index":100}});this.lb.addEvent("click",function(){this.close()}.bind(this));$(document.body).adopt(this.lb);this.lb.fade(0.8);var b=this.content.getSize();posx=(wsize.x/2)-(b.x/2);posy=(wsize.y/2)-(b.y/2);if(posy<100){posy=100}this.content.setStyles({position:"absolute",left:posx.toInt(),top:posy.toInt(),"z-index":120});this.content.addClass("Notification");this.content.addEvent("click",function(){return false});var a=this;$$("div#InquiryResult a").each(function(d){d.addEvent("click",function(){if(d.hasClass("ClosePopup")){a.close()}else{location.href=d.href}})})},close:function(){var a=this;this.content.set("tween",{onComplete:function(){a.content.destroy()}}).fade(0);this.lb.set("tween",{onComplete:function(){a.lb.destroy()}}).fade(0)}});function setSelected(a,b){$$(a+" option").each(function(c){if(c.value==b){c.setProperty("selected",true)}})}function setRadio(a,b){$$("input[name="+a+"]").each(function(c){if(c.value==b){c.setProperty("checked",true);c.fireEvent("click")}})};