window.onload = setClient;
//window.onresize = setClient;

function setClient()
{	
	var windowHeight = getWindowHeight();
	var windowWidth = getWindowWidth();
	externalLinks(); 	
}

function externalLinks() 
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) 
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
} 


function hideshow_row(field)
{
	field = field+'_tr';
	if($(field))
	{
		if($(field).visible())
		{
			$(field).hide();
		}
		else
		{
			$(field).show();
		}
	}
}

function hideshow_rows(fields)
{
	for(var field in fields){
		hideshow_row(fields[field]);
	}
}

function hideshow_row_init_bool(bool,field,modelname)
{
	if($('casco_'+modelname+'_'+bool).checked)
	{
		$(field+'_tr').show();
	}
	else
	{
		$(field+'_tr').hide();	
	}
}

function hideshow_field(field,modelname)
{
	field = 'casco_'+modelname+'_'+field;
	if($(field))
	{
		if($(field).visible())
		{
			$(field).hide();
		}
		else
		{
			$(field).show();
		}
	}
}

function hideshow_field_init_bool(bool,field,modelname)
{
	if($('casco_'+modelname+'_'+bool).checked)
	{
		$('casco_'+modelname+'_'+field).show();
	}
	else
	{
		$('casco_'+modelname+'_'+field).hide();	
	}
}


function edit_record(url)
{
	window.location.replace(url);
}

function delete_record(url,message)
{
	if(confirm(message))
	{
		window.location.replace(url);
	}
}

