window.addEvent('domready', function() {
	$E('html').addClass('js');
	var cleardefaulttext = function(el) {
		if($(el)) {
			var termValue = $(el).value;
			$(el).onfocus = function() {if ($(el).value == termValue) $(el).value = ''};
			$(el).onblur = function() {if ($(el).value == '') $(el).value = termValue};
		}
	}
	cleardefaulttext('term');
	cleardefaulttext('search-term');
	cleardefaulttext('place');
	cleardefaulttext('profileid');

	var roundTheBoxes = {
		init: function() {
			var imgPath = '/export/system/modules/org.opencms.frontend.templatetwo/resources/images/';
			var imgPathToolsuite = '/system/modules/com.candg.mortgages.toolsuite/resources/images/';
			$$('*.box').each(function(box) {
				if(box.getProperty('id') == 'tasks') {
					tl = new Element('img').addClass('tl').setProperties({'src':imgPathToolsuite+'home_tasks_tl.gif','alt':''}).injectInside(box);
					tr = new Element('img').addClass('tr').setProperties({'src':imgPathToolsuite+'home_tasks_tr.gif','alt':''}).injectInside(box);
					bl = new Element('img').addClass('bl').setProperties({'src':imgPathToolsuite+'home_tasks_bl.gif','alt':''}).injectInside(box);
					br = new Element('img').addClass('br').setProperties({'src':imgPathToolsuite+'home_tasks_br.gif','alt':''}).injectInside(box);
				} else if(box.hasClass('box-home-links')) {
					tl = new Element('img').addClass('tl').setProperties({'src':imgPath+'box_corner_tl.gif','alt':''}).injectInside(box);
					tr = new Element('img').addClass('tr').setProperties({'src':imgPath+'box_corner_tr.gif','alt':''}).injectInside(box);
					if(window.ie6) {
						bl = new Element('img').addClass('ie-bl').setProperties({'src':imgPath+'home_corner_bl.gif','alt':''}).injectInside(box);
						br = new Element('img').addClass('ie-br').setProperties({'src':imgPath+'home_corner_br.gif','alt':''}).injectInside(box);
					} else {
						bl = new Element('img').addClass('bl').setProperties({'src':imgPath+'home_corner_bl.gif','alt':''}).injectInside(box);
						br = new Element('img').addClass('br').setProperties({'src':imgPath+'home_corner_br.gif','alt':''}).injectInside(box);
					}
				} else if(box.hasClass('box-center') || box.hasClass('box-right-promo') || box.hasClass('box_schema2')) {
					tl = new Element('img').addClass('tl').setProperties({'src':imgPath+'box_corner_tl.gif'}).injectInside(box);
					tr = new Element('img').addClass('tr').setProperties({'src':imgPath+'box_corner_tr.gif'}).injectInside(box);
					bl = new Element('img').addClass('bl').setProperties({'src':imgPath+'box_corner_bl.gif'}).injectInside(box);
					br = new Element('img').addClass('br').setProperties({'src':imgPath+'box_corner_br.gif'}).injectInside(box);
				} else if(box.hasClass('statement')) {
						tl = new Element('img').addClass('nav-tl').setProperties({'src':imgPath+'box_gray_corner_tl.gif'}).injectInside(box);
						tr = new Element('img').addClass('nav-tr').setProperties({'src':imgPath+'box_gray_corner_tr.gif'}).injectInside(box);
						bl = new Element('img').addClass('nav-bl').setProperties({'src':imgPath+'box_gray_corner_bl.gif'}).injectInside(box);
						br = new Element('img').addClass('nav-br').setProperties({'src':imgPath+'box_gray_corner_br.gif'}).injectInside(box);
				} else if (box.hasClass('box-right') || box.hasClass('box-right-tabbed') || box.hasClass('box-center-promo') || box.hasClass('box_schema1') || box.hasClass('box_schema3')) {
					bl = new Element('img').addClass('bl').setProperties({'src':imgPath+'box_corner_bl.gif'}).injectInside(box);
					br = new Element('img').addClass('br').setProperties({'src':imgPath+'box_corner_br.gif'}).injectInside(box);
				} 
			});
			$$('#calculator-panel-priority p, #calculator-panel p').each(function(box) {
				bl = new Element('img').addClass('bl').setProperties({'src':imgPathToolsuite+'calc_panel_bl.gif','alt':''}).injectInside(box);
				br = new Element('img').addClass('br').setProperties({'src':imgPathToolsuite+'calc_panel_br.gif','alt':''}).injectInside(box);
			});
			$$('#calculator-panel-priority h2').each(function(box) {
				tl = new Element('img').addClass('tl').setProperties({'src':imgPathToolsuite+'calc_header_tl.gif','alt':''}).injectInside(box);
				tr = new Element('img').addClass('tr').setProperties({'src':imgPathToolsuite+'calc_header_tr.gif','alt':''}).injectInside(box);
			});
			$$('#calculator-panel h2').each(function(box) {
				tl = new Element('img').addClass('tl').setProperties({'src':imgPathToolsuite+'calc_panel_tl.gif','alt':''}).injectInside(box);
				tr = new Element('img').addClass('tr').setProperties({'src':imgPathToolsuite+'calc_panel_tr.gif','alt':''}).injectInside(box);
			});
			$$('#calculator-panel-priority h3').each(function(box) {
				tl = new Element('img').addClass('h3-tl').setProperties({'src':imgPathToolsuite+'calc_h3_off_tl.gif','alt':''}).injectInside(box);
				tr = new Element('img').addClass('h3-tr').setProperties({'src':imgPathToolsuite+'calc_h3_off_tr.gif','alt':''}).injectInside(box);
				bl = new Element('img').addClass('h3-bl').setProperties({'src':imgPathToolsuite+'calc_h3_off_bl.gif','alt':''}).injectInside(box);
				br = new Element('img').addClass('h3-br').setProperties({'src':imgPathToolsuite+'calc_h3_off_br.gif','alt':''}).injectInside(box);
			});
			$$('#calculator-panel-priority h3.on').each(function(box) {
				tl = new Element('img').addClass('h3-tl').setProperties({'src':imgPathToolsuite+'calc_h3_tl.gif','alt':''}).injectInside(box);
				tr = new Element('img').addClass('h3-tr').setProperties({'src':imgPathToolsuite+'calc_h3_tr.gif','alt':''}).injectInside(box);
				bl = new Element('img').addClass('h3-bl').setProperties({'src':imgPathToolsuite+'calc_h3_bl.gif','alt':''}).injectInside(box);
				br = new Element('img').addClass('h3-br').setProperties({'src':imgPathToolsuite+'calc_h3_br.gif','alt':''}).injectInside(box);
			});
		}
	}
	roundTheBoxes.init();
	if(window.ie6){
		var explorerNav = {
			init: function() {
				if($('mortgages')) {
					$('mortgages').addEvent('mouseover',function() {
						this.setProperties({'id':'mortgages-over'});
						this.setStyles({'zIndex':50});
					}).addEvent('mouseout',function() {
						this.setProperties({'id':'mortgages'});
						this.setStyles({'zIndex':0});
					});
				}
				if($('savings')) {
					$('savings').addEvent('mouseover',function() {
						this.setProperties({'id':'savings-over'});
						this.setStyles({'zIndex':50});
					}).addEvent('mouseout',function() {
						this.setProperties({'id':'savings'});
						this.setStyles({'zIndex':0});
					});	
				}
				if($('calculators')) {
					$('calculators').addEvent('mouseover',function() {
						this.setProperties({'id':'calculators-over'});
						this.setStyles({'zIndex':50});
					}).addEvent('mouseout',function() {
						this.setProperties({'id':'calculators'});
						this.setStyles({'zIndex':0});
					});
				}
				
				if($('mortgages-on')) {
					$('mortgages-on').setStyles({'zIndex':30});
					$('savings').setStyles({'zIndex':0});
					$('calculators').setStyles({'zIndex':0});
				}
				if($('savings-on')) {
					$('mortgages').setStyles({'zIndex':0});
					$('savings-on').setStyles({'zIndex':30});
					$('calculators').setStyles({'zIndex':0});
				}
				if($('calculators-on')) {
					$('mortgages').setStyles({'zIndex':0});
					$('savings').setStyles({'zIndex':0});
					$('calculators-on').setStyles({'zIndex':30});
				}
				
			}
		}
		explorerNav.init();
	}
	if($('all-count') != null && $('all-count') != '') { 
		var totMort = $('all-count').innerHTML;
		$$('*.total-mortgages').each(function(statement) {
			statement.innerHTML = "  of "+totMort;
		});
	}

});
function openVA(URL,sc) 
{
    var popW = '580';   //width of popup
    var popH = '492';   //height of popup
    var uid = new Date().getTime() + Math.floor(Math.random()*100);
    URL += '?uid='+uid;
    if(sc != '') URL += '&startcontext='+sc;
    window.open(URL,'VA','resizable=yes, toolbar=no, location=no, status=no, scrollbars=yes, menubar=no, titlebar=no, width=' + popW + ',height=' + popH);
}