window.onload 	= initialize_page;


function show_site()
{
	document.getElementById('page').style.display='block';
	document.getElementById('flash_splash_container').style.display='none';
}


/**********************************************************************/
function initialize_page()
{
	update_external_links();
}

function update_external_links()
{
	if(!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");

	for(var i=0; i<anchors.length; i++)
	{	
		var link = anchors[i].getAttribute("href");
		var href = link.replace('http://'+location.hostname+'/', '/'); // IE
		
		if(href.substr(0, 7)=='http://')
			anchors[i].target = "_blank";
	}
}

function get_email(name, domain)
{
	var email=name+'@'+domain;
	return "<a href='mailto:"+email+"'>"+email+"</a>";
}


//<img style='visibility: hidden' width='WWW' height='HHH' alt='' onload='scale_image(this, WWW, HHH)' src='' />
function scale_image(obj, bound_width, bound_height, stretch)
{
	var x_ratio = 1;
	var y_ratio = 1;
	var stretch = (stretch==null)?false:true;
	
	// IE does not have naturalWidth and naturalHeight
	obj.removeAttribute('width');
	obj.removeAttribute('height');

	var width 	= obj.naturalWidth || obj.width;
	var height 	= obj.naturalHeight || obj.height;

	if(bound_width>0 && (width>bound_width || (stretch && width>=height)))
		x_ratio=bound_width/width;
	
	width  = Math.round(width*x_ratio*10)/10;
	height = Math.round(height*x_ratio*10)/10;

	if(bound_height>0 && (height>bound_height || (stretch && height>=width)))
		y_ratio=bound_height/height;
	
	width  = Math.round(width*y_ratio*10)/10;
	height = Math.round(height*y_ratio*10)/10;

	obj.style.width		 = Math.round(width)+'px';
	obj.style.height	 = Math.round(height)+'px';
	obj.style.visibility = 'visible';
}



/**********************************************************************/
// usage <div onMouseOut="fixOnMouseOut(this, event, 'JavaScript Code');">So many childs</div>

function is_child_of(parent, child)
{
	if(child!=null)
	{
		while(child.parentNode)
		{
			if(child.parentNode==parent)
				return true;
			else
				child = child.parentNode;
		}
	}
	return false;
}

function fixOnMouseOut(element, event, JavaScript_code)
{
	var current_mouse_target = null;

	if(event.toElement)
		current_mouse_target = event.toElement;
	else if(event.relatedTarget)
		current_mouse_target = event.relatedTarget;

	if(!is_child_of(element, current_mouse_target) && element != current_mouse_target )
		eval(JavaScript_code);
}
/**********************************************************************/