function setupEditor(textareaID,wd,hg,toolbarSet){var oFCKeditor=new FCKeditor(textareaID,wd,hg,toolbarSet);oFCKeditor.BasePath=templatesRoot+'/js/fckeditor/';oFCKeditor.ReplaceTextarea();FCKeditor.BaseHref=window.location.pathname;}
function isDefined(variable){return(typeof(window[variable])=='undefined')?false:true;};function ArrayInsert(arr,index,v){if(index>=0){len=arr.length;for(i=len-1;i>index;i--){if(arr[i+1]==undefined){arr[i+1]=new Array;}
arr[i+1]=arr[i];}
arr.splice(parseInt(index)+1,1,v);return arr;}
return-1;};function startWait(){}
function endWait(){}
function ArrayIndexOf(arr,v){for(i in arr){if(arr[i]==v){return parseInt(i);}}
return-1;};function ajax(url,method,params,before,success,error){options={url:url,method:method};if(params!=undefined&&params!='')options['data']=params;if(success!=undefined&&success!='')options['success']=success;if(error!=undefined&&error!='')options['error']=error;$.ajax(options);};function setupCalendar(input_id,btn_id){Zapatec.Calendar.setup({inputField:input_id,ifFormat:"%m/%d/%Y",showsTime:false,button:btn_id,align:"B2"});};function win_popup(url,width,height){if(!width)width=450;if(!height)height=550;if(!window.popupNum)window.popupNum=0;window.popupNum++;mywindow=window.open(url,window.name+"_popup"+window.popupNum,"menubar=1,resizable=1,location=1,status=1,scrollbars=1,width="+width+",height="+height+"");mywindow.moveTo(100,100);};var popupOpened=false;var response;function ajaxpopup(url,width,height,before,success){if(!isDefined('before')){before=function(){startWait()};}
if(success==undefined){success=function(msg){endWait()};}
ajax(url,'GET','',before,function(msg){success(msg);popup(msg,width,height);});};function popup(text,width,height){if(width==undefined){width=600;}
if($("div.popup").length>0){popupclean();}
else{hideUnderPopup();}
$("body").append("<script type='text/javascript'>$(function(){$(document).pngFix();})</script><div style='width:"+width+"px' id='popup'  class=\"popup popup_block\">"+"<div class=\"popup_close\" onclick='popupclose();'><img alt=\"Close Window\" src='"+templatesRoot+"img/spacer.gif' width='30' height='30' /></div>"+"<div id='popupcontent'>"+text+"</div></div>");center("div#popup");applyCurtain();popupOpened=true;if($("div#popup").offset().top<0){$("div#popup").css('top',10);};};function popupclose(){popupclean();removeCurtain();popupOpened=false;showUnderPopup();};function hideUnderPopup(body){if(!$.browser.msie||!($.browser.version<7.0)){return;}
if(!body)body=$("body");$("object:visible",body).css("visibility","hidden");$("select:visible",body).css("visibility","hidden");}
function showUnderPopup(body){if(!$.browser.msie||!($.browser.version<7.0)){return;}
if(!body)body=$("body");$("object:hidden",body).css("visibility","visible");$("select:hidden",body).css("visibility","visible");}
function getScrollXY(){var scrOfX=0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}
return[scrOfX,scrOfY];};function getWindowSize(){var myWidth=0,myHeight=0;if(window.innerWidth||window.innerHeight){myWidth=window.innerWidth;myHeight=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myWidth=document.documentElement.clientWidth+16;myHeight=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myWidth=document.body.clientWidth;myHeight=document.body.clientHeight;}
return[myWidth,myHeight];};function getCenteredArea(el){w=$(el).width();h=$(el).height();wsize=getWindowSize();wscroll=getScrollXY();if($("#page-all").width()!=null){x=(parseInt($("body").width())-(w+parseInt($(el).css('border-left-width').replace('px',''))+parseInt($(el).css('border-right-width').replace('px',''))))/2;}else{x=(wsize[0]-w)/2+wscroll[0];}
y=(wsize[1]-h)/2+wscroll[1];return[x,y,x+w,y+h];};function center(el){area=getCenteredArea(el);$(el).css("left",area[0]);$(el).css("top",area[1]);};function removeCurtain(){$("#popupcurtain1").remove();};function ShowBlock(data,width,height){popup(data,width,height);};function applyCurtain(){var wsize=getWindowSize();$('body').append('<iframe src="'+templatesRoot+'black.html" style="width:'+wsize[0]+'px;height:'+wsize[1]+'px;  filter:alpha(opacity=0.0);-moz-opacity:.0;opacity:.0;background-color:#000000;" id="popupcurtain1" frameborder="none" scrolling="No" marginheight="0" marginwidth="0"></iframe>');$('#popupcurtain1').css("position:absolute")
if($.browser.msie&&$.browser.version==6){var dh=$(document).height();$('#popupcurtain1').css("position","absolute").height(dh);$('#popupcurtain1 >body').css("background","black");}
$('#popupcurtain1').fadeTo(0.0,0.5,function(){$("div.popup").show()});$("div.popup").show();};function popupclean(){$('object',$("div.popup")).remove();$('embed',$("div.popup")).remove();$("div.popup").remove();};function popup_preview(url,ratio){var width=640;var height=480;if(ratio==null){ratio=4/3;};if(ratio>1){height=Math.round(width/ratio);}
else{width=Math.round(height*ratio);};var top=Math.round((screen.height-height)/2);var left=Math.round((screen.width-width)/2);window.open(url,'','location=0,status=0,resizable=0,menubar=0,scrollbars=0,width='+width+',height='+height+',top='+top+',left='+left);}
function escapeURI(value){return escape(encodeURI(value));};function getFormFields(formName,popup,url,callback,method){if(method='undefined'){method='POST';}
str='';for(i=0;i<document.getElementById(formName).elements.length;i++){str+='&'+document.getElementById(formName).elements[i].name+'='+escapeURI(document.getElementById(formName).elements[i].value);}
GetAjaxContent(popup,url,str,callback,method);return false;};function rolloverEnhancedCopy(container_class,clipped_class,enhanced_class,clip_width,clip_height){$("."+clipped_class).css({position:'absolute',width:clip_width,height:(clip_height+2),clip:'rect(0px '+clip_width+'px '+clip_height+'px 0px)'});$("."+container_class).hover(function(){$(this).children("."+enhanced_class).show();$(this).children("."+clipped_class).hide();},function(){$(this).children("."+enhanced_class).hide();$(this).children("."+clipped_class).show();});};function setup_fc_form(id_container,success_callback){var errorsContainer=$("#errors","#"+id_container);$("#container-submit-button").each(function(){if(!$("#container-loading-image",$(this).parent()).length){var html='<div id="container-loading-image" style="display:none"><img src="'+templatesRoot+'img/ajax-loader.gif" border="0" align="absmiddle" /> Please wait...</div>';$(this).parent().append(html);}});var options={type:"POST",dataType:"xml",url:'?controller=firstcontactadaptor&action=fcsubmit',async:"true",beforeSubmit:function(){startWait();$("#container-submit-button").hide();$("#container-loading-image").show();errorsContainer.html('').hide();$("label").removeClass('label_error');},success:function(xml){endWait();$("#container-submit-button").show();$("#container-loading-image").hide();if($(xml).find("returnedData > errors > error").length){var errCommonMessage='The form cannot be submitted due to the error(s).<br /> Please, verify that all marked fields are filled correctly and try again.';if($(xml).find("returnedData > errors > message").length){errCommonMessage=$(xml).find("returnedData > errors > message").text();}
errorsContainer.show().html('<span class="error bold">'+errCommonMessage+'</span>');$(xml).find("returnedData > errors > error").each(function(){var elName=$(this).attr("element_name");if(elName=='')elName=$(this).attr("block_name");$("label[for='"+elName+"']").addClass('label_error');})}else{$(xml).find("returnedData > message").each(function(){$("#"+id_container).append("<span class='fc_thank_you'>"+$(this).text()+"</span>");})
$("form","#"+id_container).hide();if(typeof(success_callback)=="function")success_callback();}
return;var blankFieldsPresent=emailInvalid=error=false;var responseTxt="";$(xml).find("returnedData > errors > error").each(function(){if($(this).attr("type")=="blank"){blankFieldsPresent=true;error=true;}
if($(this).attr("type")=="validate"){emailInvalid=true;error=true;}
if($(this).attr("type")=="already_registered"){responseTxt+="You have already registered with us.\n\n";error=true;}});if(blankFieldsPresent){responseTxt+="Please fill all required fields.\n\n";};if(emailInvalid){responseTxt+="E-mail Address is invalid.\n\n";};if(!error){$(xml).find("returnedData > message").each(function(){if($(this).attr("type")=="thank"){responseTxt+="<br/><div align='center' class='green bold mt10'>Thank you for your interest.<br/>You will be hearing from us soon.</div>";document.getElementById(divId).innerHTML=responseTxt;}else{error=true;}});if(error){responseTxt+="Unknown error, please try again later.\n\n";};};if(error){alert(form_title+":\n\n"+responseTxt);};},error:function(XMLHttpRequest,textStatus,errorThrown){endWait();$("#container-submit-button").show();$("#container-loading-image").hide();alert("An error occured while connecting to the server, please try again later.\n\n");}};$("form","#"+id_container).ajaxForm(options);};function showFCformPopup(url,width){if(width==null)width=960;startWait();$.get(url,function(data){endWait();obj=popup(data,width);$("select, input:checkbox, input:radio, input:file","#popupcontent").uniform();$("div.disabled").removeClass("disabled");})}
function getEditorValue(id_element){var text=null;var oEditor=FCKeditorAPI.GetInstance(id_element);if(oEditor){text=jQuery.trim(oEditor.GetXHTML(true));}else{text=jQuery.trim($(id_element).val());}
return text;}
function updateEditorValue(id_field){$('textarea[id="'+id_field+'"]').val(getEditorValue(id_field));}
function setupAjaxForm(id_form,id_error,success_handler){$('#'+id_form).ajaxForm({dataType:'json',timeout:35000,error:function(){$('#'+id_error).html('An error occured while processing the request');},beforeSubmit:function(){$("#container-submit-button").hide();$("#container-loading-image").show();$('#'+id_form+' label').css('color','');$('#'+id_error).html('');},success:function(respond){$("#container-submit-button").show();$("#container-loading-image").hide();if(respond.success==1){if(success_handler.length!=0){var func=success_handler+'(respond);'
eval(func);}}else{processErrors(id_form,id_error,respond);}}});}
function processErrors(id_form,id_error,respond){var isRequired=false;jQuery.each(respond.errors,function(key,error){if(error.indexOf("Please, fill all required fields")!=-1){if(isRequired==false){$('#'+id_error).append("Please, fill all required fields <br />");}
isRequired=true;}else{$('#'+id_error).append(error+"<br />");}});jQuery.each(respond.eFields,function(key,field){$('#'+id_form+' label[for='+field+']').css('color','red');})}
function jGrowl_successHandler(){$.jGrowl("Your request was processed successfully");}
