function initFCKEditor(ele){var sBasePath=document.location.href.substring(0,document.location.href.lastIndexOf("_samples"));var oFCKeditor=new FCKeditor(ele);oFCKeditor.BasePath="/codemis_cms/js/fckeditor/";if(customFckconfigJsPath){oFCKeditor.Config.CustomConfigurationsPath=customFckconfigJsPath}oFCKeditor.Height=600;oFCKeditor.ReplaceTextarea();return true}function checkAvailability(loading_id,input_id,result_id,url){$("#"+input_id).blur(function(){$("#"+loading_id).show();$.post(url,{inputValue:$("#"+input_id).val()},function(response){$("#"+loading_id).fadeOut();setTimeout("finishAjax('"+result_id+"', '"+escape(response)+"')",400,loading_id)});return false})}function finishAjax(id,response,loading_id){$("#"+loading_id).hide();$("#"+id).html(unescape(response));$("#"+id).fadeIn()}function createMessage(msg,ele,type){if(use_gritter){if(type=="error"){$.gritter.add({title:"Error",text:msg,time:5000,image:"/codemis_cms/img/gritter/error.png"})}else{$.gritter.add({title:"Message",text:msg,time:5000,image:"/codemis_cms/img/gritter/info.png"})}}else{if($("#flashMessage").length!=0){$("#flashMessage").remove()}var _insert=$(document.createElement("div")).css("display","none");_insert.attr("id","flashMessage").addClass("message").text(msg);_insert.insertBefore($(ele)).fadeIn()}return true}function stripTable(tableRef){$(tableRef+" tr").removeClass("altrow");$(tableRef+" tr").each(function(index){if(index%2==0){$(this).addClass("altrow")}})}function getUrlVars(){var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(var i=0;i<hashes.length;i++){hash=hashes[i].split("=");vars.push(hash[0]);vars[hash[0]]=hash[1]}return vars}$.extend({URLEncode:function(c){var o="";var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;while(x<c.length){var m=r.exec(c.substr(x));if(m!=null&&m.length>1&&m[1]!=""){o+=m[1];x+=m[1].length}else{if(c[x]==" "){o+="+"}else{var d=c.charCodeAt(x);var h=d.toString(16);o+="%"+(h.length<2?"0":"")+h.toUpperCase()}x++}}return o},URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;while((m=r.exec(o))!=null&&m.length>1&&m[1]!=""){b=parseInt(m[1].substr(1),16);t=String.fromCharCode(b);o=o.replace(m[1],t)}return o}});function initLoginScript(){var open_div="#user_login";$("#forgot_password").hide();$("#send_activation").hide();$("a.forgot_pass_link").click(function(){$(open_div).fadeOut("slow",function(){$("#forgot_password").fadeIn();open_div="#forgot_password"});return false});$("a.login_link").click(function(){$(open_div).fadeOut("slow",function(){$("#user_login").fadeIn();open_div="#user_login"});return false});$("a.activation_link").click(function(){$(open_div).fadeOut("slow",function(){$("#send_activation").fadeIn();open_div="#send_activation"});return false})}var sectionId=0;function initEventDisplay(){if($("#segments_data").children().length==0){getAllEventsForView()}else{}}function getAllEventsForView(){var eventsArray=[];$.getJSON("/segments/index.json?section_id="+sectionId,function(data){var counter=0;$.each(data,function(i,Segment){$.each(Segment.SegmentDate,function(segCount,SegmentDate){eventsArray[counter]={id:SegmentDate.id,segmentId:SegmentDate.segment_id,title:Segment.Segment.seg_title,subtitle:Segment.Segment.seg_subtitle,description:Segment.Segment.seg_content,truncated:Segment.Segment.seg_content.replace(/<.*?>/g,"").substring(0,400),start:$.fullCalendar.parseDate(SegmentDate.date_of_event+" "+SegmentDate.time_of_event),allDay:false};counter++})});displayEventCalendarOnView(eventsArray)});return true}function displayEventCalendarOnView(eventsArray){$("#segments_data").fullCalendar({editable:false,header:{left:"prev,next today",center:"title",right:"month,agendaWeek,agendaDay"},slotMinutes:15,events:eventsArray,eventClick:goToEventViewPage,eventMouseover:function(calEvent,jsEvent,view){ie=document.all?true:false;$("#segments_data").append("<div class='event_tooltip' id='event_desc_"+calEvent.id+"'><h1>"+calEvent.title+"</h1><h2>"+calEvent.subtitle+"</h2>"+calEvent.truncated+"</div>");tooltip=$("#event_desc_"+calEvent.id);xOffset=-(tooltip.width()/2);yOffset=-(tooltip.height()+30);$("#event_desc_"+calEvent.id).hide().css("top",(jsEvent.pageY+yOffset)+"px").css("left",(jsEvent.pageX+xOffset)+"px").fadeIn("slow")},eventMouseout:function(calEvent,jsEvent,view){$("#event_desc_"+calEvent.id).fadeOut("slow").remove()}});return true}function displaySingleEventOnView(data){$("#events_wrapper").css("height",$("#events_wrapper").height());$("#segments_data").fadeOut("slow",function(){$("#events_wrapper").css("height","auto");$("#segments_data").html(data).fadeIn("slow")});return true}function goToEventViewPage(event,jsEvent,view){window.location=location.href+"/event/"+event.id+"/"};
