// JavaScript Document
function directlogon()
{
	
	var w = 800;
	var h = 600;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var page = "direct/index.aspx";
	//var page = "citadeldirect/index.aspx";
	windowprops = "height="+h+",width="+w+",top="+ wint +", left="+ winl +",location=0,"+"scrollbars=1 ,menubars=0, toolbars=0, resizable=1, status=1";
	window.open(page, "Popup", windowprops);
	
}

function directregister()
{
	
	window.location = "register.aspx";
	
}

function assumptionscontactus()
{
	window.opener.location.href='contactus.aspx';
	this.window.close();
}
	

function generateEmail(userName, domain, suffix, textToShow)
{
	document.write('<a href="' + 'mailto:' + userName + '@' + domain + '.' + suffix + '">' + textToShow + '</a>');
}	
	
function openpopup(id)
{
	newwindow = window.open('page_popup.aspx?id=' + id, 'Page', 'height=380,width=585,false,false,false,scrollbars,status,false');					
	if (window.focus) {newwindow.focus()}
	return false;
}

function openpopupSizeable(id, iWidth, iHeight)
{
	newwindow = window.open('page_popup.aspx?id=' + id , 'Page', 'height=' + iHeight + ',width=' + iWidth +', false, false, false, scrollbars, status,false');
	if (window.focus) {newwindow.focus()}	
	return false;
}

function openpopupCustom(pageName, iWidth, iHeight)
{
	newwindow = window.open(pageName, 'Page', 'height='+ iHeight + ',width=' + iWidth +', false,false,false,scrollbars,status,false');					
	if (window.focus) {newwindow.focus()}
	return false;
}

function openpopupCustomResizeable(pageName, iWidth, iHeight)
{
	newwindow = window.open(pageName, 'Page', 'height='+ iHeight + ',width=' + iWidth +', resizable=yes, false,false,false,scrollbars,status,false');					
	if (window.focus) {newwindow.focus()}
	return false;
}

function alternate(id){ 
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);   
   var rows = table.getElementsByTagName("tr");   
   for(i = 0; i < rows.length; i++){           
 //manipulate rows 
     if(i % 2 == 0){ 
       rows[i].className = "table_evenrow"; 
     }else{ 
       rows[i].className = "table_oddrow"; 
     }       
   } 
 } 
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function addboatvalue(form)
{
	var engine1 = document.getElementById('quote_ma_e1value').value;	
	engine1 = engine1.replace(",","");
	var engine2 = document.getElementById('quote_ma_e2value').value;
	engine2 = engine2.replace(",","");
	var hull = document.getElementById('quote_ma_hullvalue').value;
	hull = hull.replace(",","");
	var trailer = document.getElementById('quote_ma_trailervalue').value;
	trailer = trailer.replace(",","");
	var personal = document.getElementById('quote_ma_personalvalue').value;
	personal = personal.replace(",","");
	
	
	var insuredsum = document.getElementById('quote_ma_insuredsum');
	
	if (!IsNumeric(engine1))
	{
		engine1 = 0
	}
	if (!IsNumeric(engine2))
	{
		engine2 = 0
	}
	if (!IsNumeric(hull))
	{
		hull = 0
	}
	if (!IsNumeric(trailer))
	{
		trailer = 0
	}
	if (!IsNumeric(personal))
	{
		personal = 0
	}
	
	insuredsum.value = Number(engine1) + Number(engine2) + Number(hull) + Number(trailer) + Number(personal);
}

function boat_engine()
{
	if(document.getElementById('quote_ma_e1inboard').checked == true)
	{
		document.getElementById('quote_ma_e1value').disabled=true;				
	}	
	if(document.getElementById('quote_ma_e1outboard').checked == true)
	{
		document.getElementById('quote_ma_e1value').disabled=false;	
	}
	
	if(document.getElementById('quote_ma_e2inboard').checked == true)
	{
		document.getElementById('quote_ma_e2value').disabled=true;			
	}
	if(document.getElementById('quote_ma_e2outboard').checked == true)
	{
		document.getElementById('quote_ma_e2value').disabled=false;	
	}
}

function boat_mooring()
{
	if ((document.getElementById('quote_ma_mooring_marina').checked == true) || (document.getElementById('quote_ma_mooring_harbour').checked == true))
	{
		document.getElementById('ashore').style.display='none';	
		document.getElementById('marinaharbour').style.display='';
	}	
	
	if(document.getElementById('quote_ma_mooring_ashore').checked == true)
	{
		document.getElementById('ashore').style.display='';	
		document.getElementById('marinaharbour').style.display='none';	
		document.getElementById('quote_ma_sheltered').selectedIndex = 0
	}
}


function checkAge()
{
	var age; 
	if (isNaN(document.getElementById('quote_m_youngage').value))
	{
		age = 0;		
	}
	else
	{		
		age = parseInt(document.getElementById('quote_m_youngage').value); 
	}
	if (age < 25)
	{
		document.getElementById('quote_m_excess').style.display = 'none';
		document.getElementById('quote_m_excess2').style.display  = '';
	}
	else
	{
		document.getElementById('quote_m_excess').style.display = '';
		document.getElementById('quote_m_excess2').style.display  = 'none';
	}
}

function persons()
{
	document.getElementById('quote_t_persons_2_t').value = document.getElementById('quote_t_persons_2').value;
	document.getElementById('quote_t_persons_2to15_t').value = parseInt(document.getElementById('quote_t_persons_2to15').value) + parseInt(document.getElementById('quote_t_persons_2to15_w').value);
	document.getElementById('quote_t_persons_16to54_t').value = parseInt(document.getElementById('quote_t_persons_16to54').value) + parseInt(document.getElementById('quote_t_persons_16to54_w').value);
	document.getElementById('quote_t_persons_55to69_t').value = parseInt(document.getElementById('quote_t_persons_55to69').value) + parseInt(document.getElementById('quote_t_persons_55to69_w').value);
	document.getElementById('quote_t_persons_70to74_t').value = document.getElementById('quote_t_persons_70to74').value;
	document.getElementById('quote_t_persons_t').value = parseInt(document.getElementById('quote_t_persons_2_t').value) + parseInt(document.getElementById('quote_t_persons_2to15_t').value) +
		parseInt(document.getElementById('quote_t_persons_16to54_t').value) + parseInt(document.getElementById('quote_t_persons_55to69_t').value) +
		parseInt(document.getElementById('quote_t_persons_70to74_t').value)
}
