
function calendarClose(id){calendarResult=id;if(id)
{date=id.split('-');day=document.theForm.selDay;day.selectedIndex=date[2]-1;month=document.theForm.selMonth;month.selectedIndex=date[1]-1;year=document.theForm.selYear;for(i=0;i<year.options.length;i++){if(year.options[i].value==date[0]){year.options[i].selected=true;}}}
calendarRemove();calcDay('theForm','selDay','selMonth','selYear','StartDay');document.documentElement.onclick=null;}
function calendarRemove(){var div=document.getElementById('calendarPopup');if(div)
{div.style.display='none';}
targetId='';}
var calendarResult='';var Classes=new Array();var targetId='';function calendar(){if(document.getElementById('advanced')){if(optShown){showHideAdditonal();}}
date=document.theForm.selYear.options[document.theForm.selYear.selectedIndex].value+'-'+(document.theForm.selMonth.selectedIndex+1)+'-'+(document.theForm.selDay.selectedIndex+1);inputBoxId='CalendarDate';var quickRunAway=(targetId==inputBoxId);calendarRemove();if(quickRunAway){return;}
targetId=inputBoxId;var div=document.getElementById('calendarPopup');if(!div){div=document.createElement('div');div.setAttribute('id',"calendarPopup");var CalImg=document.getElementById('CalendarImage');CalImg.parentNode.appendChild(div);}
var textBox=document.getElementById(targetId);if(navigator.userAgent.indexOf("Firefox")!=-1){div.style.position='absolute';}else{div.style.position='absolute';}
div.style.zIndex=2100;document.documentElement.onclick=function(e){if(clickedOutsideElement('CalendarImage',e)&&clickedOutsideElement('calendarPopup',e)){calendarClose(0);}}
calendarPopulate(date);}
function calendarPopulate(date){var dayNames=new Array('Mo','Tu','We','Th','Fr','Sa','Su');var monthNames=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var id;var styleClass='';var table='';var events='onClick="calendarClose(this.id);" onMouseOver="this.className=\'calendarHighlight\';" onMouseOut="this.className=Classes[this.id];"';var dateArray=date.split('-');today=new Date();blah=new Date();blah.setYear(dateArray[0]);blah.setDate(1);blah.setMonth(dateArray[1]-1);zarg=new Date();zarg.setYear(blah.getFullYear());zarg.setDate(1);zarg.setMonth(blah.getMonth()-1);if(zarg.getMonth()+1==today.getMonth()){zarg.setYear(today.getFullYear()+1);}
prevMonth="&laquo;&nbsp;<a href='javascript:calendarPopulate(\""+zarg.getFullYear()+"-"+(zarg.getMonth()+1)+"-"+zarg.getDate()+"\")'>"+monthNames[zarg.getMonth()]+"</a>";zarg.setYear(blah.getFullYear());zarg.setDate(1);zarg.setMonth(blah.getMonth()+1);if(zarg.getMonth()==today.getMonth()){zarg.setYear(today.getFullYear());}
nextMonth="<a href='javascript:calendarPopulate(\""+zarg.getFullYear()+"-"+(zarg.getMonth()+1)+"-"+zarg.getDate()+"\")'>"+monthNames[zarg.getMonth()]+"</a>&nbsp;&raquo;";nextYear="<a href='javascript:calendarPopulate(\""+(blah.getFullYear()+1)+"-"+(blah.getMonth()+1)+"-01\")'>&laquo;"+(blah.getFullYear()+1)+"</a>";prevYear="<a href='javascript:calendarPopulate(\""+(blah.getFullYear()-1)+"-"+(blah.getMonth()+1)+"-01\")'>"+(blah.getFullYear()-1)+"&raquo;</a>";table+='<table class=calendar>\n';table+='<tr><td colspan=7 class=calendarMonthTitle align=center>'
table+=prevMonth+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';table+=monthNames[blah.getMonth()]+'&nbsp;'+blah.getFullYear()+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';table+=nextMonth+'</td>';table+='</tr>\n';table+='<tr>';for(i=0;i<5;i++)table+='<td class=calendarWeekdayHeading align=center>'+dayNames[i]+'</td>';for(;i<7;i++)table+='<td class=calendarWeekendHeading align=center>'+dayNames[i]+'</td>';table+='</tr>\n';table+='<tr>';if(blah.getDay()!=1)
{var i=-(blah.getDay()+5)%7;for(;i<1;i++)
{workingDate=new Date(blah);workingDate.setDate(i);if((month=(workingDate.getMonth()+1))<10)
{month='0'+month;}
if((day=(workingDate.getDate()))<10)
{day='0'+day;}
id=workingDate.getFullYear()+'-'+month+'-'+day;if(today.getDate()==workingDate.getDate()&&today.getMonth()==workingDate.getMonth()&&today.getFullYear()==workingDate.getFullYear())
{styleClass='calendarWrongToday';}
else if((workingDate.getDay==0)||(workingDate.getDay()==6))
{styleClass='calendarWrongMonthWeekend';}
else
{styleClass='calendarWrongMonthWeekday';}
table+='<td id="'+id+'" '+events+' class='+styleClass+' align=center>';Classes[id]=styleClass;table+=workingDate.getDate();table+='</td>\n';}}
else
{var i=1;}
for(;;i++)
{workingDate=new Date(blah);workingDate.setDate(i);if((month=(workingDate.getMonth()+1))<10)month='0'+month;if((day=(workingDate.getDate()))<10)day='0'+day;id=workingDate.getFullYear()+'-'+month+'-'+day;if(workingDate.getMonth()!=blah.getMonth())
{break;}
if(workingDate.getDay()==1){table+='</tr>\n<tr>';}
if(today.getDate()==workingDate.getDate()&&today.getMonth()==workingDate.getMonth()&&today.getFullYear()==workingDate.getFullYear())
{styleClass='calendarToday';}
else if((workingDate.getDay()==0)||(workingDate.getDay()==6))
{styleClass='calendarWeekend';}
else
{styleClass='calendarWeekday';}
table+='<td id="'+id+'" '+events+' class='+styleClass+' align=center>';Classes[id]=styleClass;table+=workingDate.getDate();table+='</td>\n';}
if(workingDate.getDay()!=1)
{for(;;i++){workingDate=new Date(blah);workingDate.setDate(i);if((month=(workingDate.getMonth()+1))<10)month='0'+month;if((day=(workingDate.getDate()))<10)day='0'+day;id=workingDate.getFullYear()+'-'+month+'-'+day;if(today.getDate()==workingDate.getDate()&&today.getMonth()==workingDate.getMonth()&&today.getFullYear()==workingDate.getFullYear())
{styleClass='calendarWrongToday';}
else if((workingDate.getDay()==0)||(workingDate.getDay()==6))
{styleClass='calendarWrongMonthWeekend';}
else
{styleClass='calendarWrongMonthWeekday';}
table+='<td id="'+id+'" '+events+' class='+styleClass+' align=center>';Classes[id]=styleClass;table+=workingDate.getDate();table+='</td>\n';if(workingDate.getDay()==0)break;}}
table+='</tr>\n'
table+='<tr><td colspan=7 align=center><a href="javascript:calendarClose(0)">Close</a></td></tr>';table+='</table>';var div=document.getElementById('calendarPopup');div.innerHTML=table;div.style.display='block';}
function calcDay(frm,nm,nm2,nm3,day){curr_year=document.forms[frm].elements[nm3].options[document.forms[frm].elements[nm3].selectedIndex].value;var cl,cForm,cMonthYearField,cDayField,cDateField;var mDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31)
var days=["Sun","Mon","Tue","Wed","Thu","Fri","Sat",];var days2=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var d=new Date();dateVal=document.forms[frm].elements[nm].options[document.forms[frm].elements[nm].selectedIndex].value;monthVal=curr_year+document.forms[frm].elements[nm2].options[document.forms[frm].elements[nm2].selectedIndex].value;var isLeapYear=(((monthVal.substr(0,4)%4==0)&&(monthVal.substr(0,4)%100!=0))||(monthVal.substr(0,4)%400==0));mDays[1]=(isLeapYear)?29:28;if(dateVal>mDays[monthVal.substr(4,2)-1]){setDDValue(document.forms[frm].elements[nm],mDays[monthVal.substr(4,2)-1]);dateVal=document.forms[frm].elements[nm].options[document.forms[frm].elements[nm].selectedIndex].value;}
newDate=new Date(monthVal.substr(0,4)+"/"+monthVal.substr(4,2)+"/"+dateVal);}
function setDDValue(elem,val){num=elem.options.length;for(i=0;i<num;i++){if(elem.options[i].value==val){elem.options.selectedIndex=i;}}}
function clickedOutsideElement(elemId,evt){var theElem='';if(window.event){theElem=getEventTarget(window.event);}else{theElem=getEventTarget(evt);}
while(theElem!=null){if(theElem.id==elemId){return false;}
theElem=theElem.offsetParent;}
return true;}
function getEventTarget(evt){var targ=(evt.target)?evt.target:evt.srcElement;if(targ!=null){if(targ.nodeType==3){targ=targ.parentNode;}}
return targ;}
function checkString(Input){if(null==Input)
{return 0;}
if("string"==typeof(Input)&&""==Input)
{return 1;}
return 2;}
function checkNumber(Input){if(null==Input)
{return 0;}
if(isNaN(parseFloat(Input)))
{return 1;}
return 2;}
function FiebaGeneralPopUp(popupURL,AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode,ServiceCode,SmallVersion)
{var isFirst=true;var PopupWindow=null;if(FiebaGeneralPopUp.arguments.length!=0){popupURL+='?';if(checkNumber(AmountToConvert)>1){popupURL+='inputAmount='+parseFloat(AmountToConvert);isFirst=false;}
if(checkString(SourceCurrencyCode)==2){popupURL+=(isFirst?'':'&')+'fromCurrency='+SourceCurrencyCode;isFirst=false;}
if(checkString(DestinationCurrencyCode)==2){popupURL+=(isFirst?'':'&')+'toCurrency='+DestinationCurrencyCode;isFirst=false;}
if(checkString(ServiceCode)>1){popupURL+=(isFirst?'':'&')+'serviceCode='+ServiceCode;}}
if(SmallVersion==true)
PopupWindow=window.open(popupURL,'PopupWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=228,width=146')
else
PopupWindow=window.open(popupURL,'PopupWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=273,width=468')
if(PopupWindow!=null)PopupWindow.focus();return PopupWindow;}
function FiebaPopUp(AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode)
{return FiebaCompactPopUp(AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode);}
function FiebaB2BPopUp(AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode)
{return FiebaGeneralPopUp('http://www.fieba.net/converter',AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode,'PCCB2B');}
function FiebaRetailPopUp(AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode)
{return FiebaGeneralPopUp('http://www.fieba.net/converter',AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode,'PCCPRETAIL');}
function FiebaNonRetailPopUp(AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode)
{return FiebaGeneralPopUp('http://www.fieba.net/converter',AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode,'PCCPNONRETAIL');}
function FiebaCompactPopUp(AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode)
{return FiebaGeneralPopUp('http://www.fieba.net/converter',AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode,'IFPCCRETAIL',true);}
function FiebaCustomPopUp(cnvId,AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode)
{var popupURL='http://www.fieba.net/converter';var isFirst=true;if(FiebaCustomPopUp.arguments.length!=0){popupURL+='?serviceCode=CPCC';isFirst=false;if(checkNumber(cnvId)>1){popupURL+=(isFirst?'':'&')+'cnvId='+new Number(cnvId).toString();}else
{FiebaPopUp(AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode);}
if(checkNumber(AmountToConvert)>1){popupURL+=(isFirst?'':'&')+'inputAmount='+parseFloat(AmountToConvert);}
if(checkString(SourceCurrencyCode)==2){popupURL+=(isFirst?'':'&')+'fromCurrency='+SourceCurrencyCode;}
if(checkString(DestinationCurrencyCode)==2){popupURL+=(isFirst?'':'&')+'toCurrency='+DestinationCurrencyCode;}}
CustomPopupWindow=window.open(popupURL,'PopupWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=220,width=350')
if(CustomPopupWindow!=null)CustomPopupWindow.focus();return CustomPopupWindow;}
function FiebaControlIFrame(AmountToConvert,SourceCurrencyCode,DestinationCurrencyCode,PerformConversion){var inputAmount=1.0;var sourceCurrencyCode="";var destinationCurrencyCode="";if(checkNumber(AmountToConvert)>1){inputAmount=parseFloat(AmountToConvert);}
if(checkString(SourceCurrencyCode)==2){sourceCurrencyCode=SourceCurrencyCode;}
if(checkString(DestinationCurrencyCode)==2){destinationCurrencyCode=DestinationCurrencyCode;}
iFrame=document.getElementById('FiebaIFrameConverter');if(iFrame!=null){if(sourceCurrencyCode==""||destinationCurrencyCode==""){iFrame.src="http://www.fieba.net/converter"+"?serviceCode=IFRETAIL"+"&inputAmount="+inputAmount+
((sourceCurrencyCode=="")?"":"&fromCurrency="+sourceCurrencyCode)+
((destinationCurrencyCode=="")?"":"&toCurrency="+
destinationCurrencyCode);}
else{iFrame.src="http://www.fieba.net/converter"+"?serviceCode=IFRETAIL&action=calculate"+"&inputAmount="+inputAmount+"&fromCurrency="+
sourceCurrencyCode+"&toCurrency="+destinationCurrencyCode;}}}