// Development By: Infinity Arts Interactive, LLC - www.InfinityArts.com, (c) Copyright 2011 - All rights reserved.

document.write('<script type="text/javascript" src="'+'https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'+'"></scr'+'ipt>');var cmpntPath='/components/';var curFormId=0;function valSMForm(oForm){var flds=oForm.frmFlds.value;curFormId=oForm.frmIdno.value;for(var i=1;i<=flds;i++){var typeId=(oForm['typ'+i])?parseInt(oForm['typ'+i].value):0;if(oForm['timeHH'+i]){oForm['fld'+i].value=oForm['timeHH'+i].value+':'+oForm['timeMM'+i].value+' '+oForm['timeAP'+i].options[oForm['timeAP'+i].selectedIndex].value;}
if(oForm['req'+i]){if(oForm['req'+i].value=='Y'){switch(typeId){case 1:if(!valSMForm_radio(oForm,i)){formError('Please check an option for "'+valSMForm_labelTxt(i)+'" to continue.',oForm['rd'+i][0]);return false;}
break;case 2:if(!oForm['cb'+i].checked){formError('Please check "'+valSMForm_labelTxt(i)+'" to continue.',oForm['cb'+i]);return false;}
break;case 3:case 4:if(oForm['fld'+i].value==''||oForm['fld'+i].value==oForm['hfld'+i].value){formError('Please enter a value for "'+valSMForm_labelTxt(i)+'" to continue.',oForm['fld'+i]);return false;}
break;case 5:case 7:case 8:case 9:case 10:if(oForm['fld'+i].options[oForm['fld'+i].selectedIndex].value==''){formError('Please select an option for "'+valSMForm_labelTxt(i)+'" to continue.',oForm['fld'+i]);return false;}
break;case 6:if(!valSMForm_option(oForm,i)){formError('Please select an option for "'+valSMForm_labelTxt(i)+'" to continue.',oForm['fld'+i][0]);return false;}
break;case 13:if(!isDate(oForm['fld'+i].value,'')){formError('Please enter a valid date (MM/DD/YYYY) for "'+valSMForm_labelTxt(i)+'" to continue.',oForm['fld'+i]);return false;}
break;case 19:if(oForm['fld'+i].value==''||oForm['timeHH'+i].value==''||oForm['timeMM'+i].value==''){formError('Please enter a value for "'+valSMForm_labelTxt(i)+'" to continue.',oForm['timeHH'+i]);return false;}
break;}}}
switch(typeId){case 1:valSMForm_specialFieldData(oForm,'rd',i);break;case 2:var cbval=(oForm['fld'+i].value!='')?oForm['fld'+i].value:oForm['cb'+i].checked;oForm['fld'+i].value=(oForm['cb'+i].checked)?cbval:'-';break;}}
if(oForm.frmCaptcha.value=='Y'){valRecaptcha(oForm);}
else{$('#btnSubmit'+curFormId).attr('disabled',true);valSMForm_send(oForm);}
return false;}
function valSMForm_labelTxt(oPos){return($('#fldlbl'+curFormId+oPos).val()=='')?'This Field':$('#fldlbl'+curFormId+oPos).val();};function valSMForm_option(oForm,oPos){for(var i=0;i<oForm['fld'+oPos].options.length;i++){if(oForm['fld'+oPos].options[i].selected)return true;}
return false;}
function valSMForm_radio(oForm,oPos){var i=0;while(oForm['rd'+oPos][i]){if(oForm['rd'+oPos][i].checked){return true;}
i++;}
return false;}
function valSMForm_specialFieldData(oForm,oFld,oPos){for(var j=0;j<oForm[oFld+oPos].length;j++){if(oForm[oFld+oPos][j].checked){oForm['fld'+oPos].value=oForm[oFld+oPos][j].value;break;}}}
function valSMForm_send(oForm){oForm.actiontype.value='submit';$.post(cmpntPath+'sm-forms.asp',getFormVars(oForm),function(data){if(data.substr(0,4)=='http'){location.href=data;}
else{$('#DIVsmForm'+curFormId).html(data);}});}
function formError(oMsg,oField){alert(oMsg);oField.focus();}
function isDate(dateStr,field){var datePat=/^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;var matchArray=dateStr.match(datePat);if(matchArray==null){return false;}
month=matchArray[1];day=matchArray[3];year=matchArray[5];if(month<1||month>12){return false;}
if(day<1||day>31){return false;}
if((month==4||month==6||month==9||month==11)&&day==31){return false;}
if(month==2){var isleap=(year%4==0&&(year%100!=0||year%400==0));if(day>29||(day==29&&!isleap)){return false;}}
return true;}
function dateAdd(intval,numb,oDate){switch(intval){case"M":base.setMonth(base.getMonth()+numb);break;case"YYYY":base.setFullYear(base.getFullYear()+numb);break;case"D":base.setDate(base.getDate()+numb);break;case"H":base.setHours(base.getHours()+numb);break;case"N":base.setMinutes(base.getMinutes()+numb);break;case"S":base.setSeconds(base.getSeconds()+numb);break;default:}
return base}
function getCalendar(oSrc,oFrmField){var pos=get_XYcoordinates(oSrc);var url=cmpntPath+"dlg-calendar.asp?the_field="+oFrmField.id+"&the_date="+oFrmField.value+"&start_date="+oFrmField.value;var html=''
+'<div id="DIVdialogCalendarBG" style="width:100%; height:'+$(document).height()+'px; display:none; position:absolute; left:0px; top:0px; z-index:20010;" onclick="getCalendarExit(\'\',\'\');"></div>'
+'<div id="DIVdialogCalendar" style="border:2px #333333 solid; position:absolute; left:'+pos.x+'px; top:'+pos.y+'px; z-index:20011;"></div>';if($('#DIVdialogCalendarBG').length==0){$('body').append(html);}
switch(oSrc){default:setCalendarPos(pos.x-198,pos.y+22);break;}
$('#DIVdialogCalendarBG').show();$('#DIVdialogCalendar').html('<iframe unselectable="on" id="IFRAMEdialogCalendar" name="IFRAMEdialogCalendar" src="'+url+'" width="210" height="195" marginheight="0" marginwidth="0" frameBorder="0" noresize scrolling="no"></iframe>').show();}
function getCalendarExit(oFrmField,oDate){$('#DIVdialogCalendarBG').hide();$('#DIVdialogCalendar').hide();if(document.getElementById(oFrmField))document.getElementById(oFrmField).value=oDate;}
function setCalendarPos(oX,oY){document.getElementById('DIVdialogCalendar').style.left=oX+'px';document.getElementById('DIVdialogCalendar').style.top=oY+'px';}
function get_XYcoordinates(element){var useWindow=false;var coordinates=new Object();var x=0;var y=0;var use_gebi=false;var use_css=false;var use_layers=false;if(document.getElementById)use_gebi=true;else if(document.all)use_css=true;else if(document.layers)use_layers=true;if(use_gebi&&document.all){x=get_Xposition(document.all[element]);y=get_Yposition(document.all[element]);}else if(use_gebi){x=get_Xposition(document.getElementById(element));y=get_Yposition(document.getElementById(element));}else if(use_css){x=get_Xposition(document.all[element]);y=get_Yposition(document.all[element]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==element){found=1;break;}}
if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}
x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}
coordinates.x=x;coordinates.y=y;return coordinates;}
function get_Xposition(element){var ol=element.offsetLeft;while((element=element.offsetParent)!=null){ol+=element.offsetLeft;}
return ol;}
function get_Yposition(element){var ot=element.offsetTop;while((element=element.offsetParent)!=null){ot+=element.offsetTop;}
return ot;}
function get_XYscrollPos(){var scrollX,scrollY;if(document.all){if(!document.documentElement.scrollLeft)scrollX=document.body.scrollLeft;else scrollX=document.documentElement.scrollLeft;if(!document.documentElement.scrollTop)scrollY=document.body.scrollTop;else scrollY=document.documentElement.scrollTop;}else{scrollX=window.pageXOffset;scrollY=window.pageYOffset;}
var scroll=new Object();scroll.x=scrollX;scroll.y=scrollY;return scroll;}
function getFormVars(oForm){var sendVars='';for(i=0;i<oForm.elements.length;i++)
sendVars+=oForm.elements[i].name+'='+escape(oForm.elements[i].value)+'&';return sendVars;}
function loadAJAX(oEl,oCom,oParams){if(document.getElementById(oEl))
document.getElementById(oEl).innerHTML='<img src="'+cmpntPath+'assets/images/icon_loader.gif" align="middle" style="margin-right:5px; width:24px; height:24px;" /> <strong>Processing...</strong>';var http=false;if(window.ActiveXObject)http=new ActiveXObject("Microsoft.XMLHTTP");else if(window.XMLHttpRequest)http=new XMLHttpRequest();if(!http){alert('Sorry, your Web Browser is not configured to work with this feature.');return;}
http.open("POST",oCom,true);http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");http.onreadystatechange=function(){if(http.readyState==4)document.getElementById(oEl).innerHTML=http.responseText;}
http.send(oParams);}
function valRecaptcha(oForm){if(oForm.recaptcha_response_field.value==''){formError('Please enter a ReCaptcha code continue.',oForm.recaptcha_response_field);return false;}
var params=''
+'actiontype=captcha'
+'&frmIdno='+oForm.frmIdno.value
+'&remoteip='+oForm.remoteip.value
+'&challenge='+oForm.recaptcha_challenge_field.value
+'&response='+oForm.recaptcha_response_field.value;var http=false;if(window.ActiveXObject)http=new ActiveXObject("Microsoft.XMLHTTP");else if(window.XMLHttpRequest)http=new XMLHttpRequest();if(!http){alert('Sorry, your Web Browser is not configured to work with this feature.');return;}
http.open("POST",cmpntPath+'/sm-forms.asp',true);http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");http.onreadystatechange=function(){if(http.readyState==4){if(http.responseText=='false'){formError('The ReCaptcha Code entered was incorrect!\nPlease verify the ReCaptcha code continue.',oForm.recaptcha_response_field);Recaptcha.reload();return false;}
else valSMForm_send(oForm);}}
http.send(params);}
