/*
image change function
*/

$(document).ready(function (){
$.each( $( '#sgmtSubnav' ).find('a'), function(i, node)
{

	$(this).click( function()
	{
	$name = $(this).attr('href');
	$("#photo").fadeOut("normal", fade_in);
	return false;
	});

});
});

/*
rollover
*/

rollovers = function(off,on){
    //target path
	nav = document.getElementById("globalnavi");
	//target tag
	img=nav.getElementsByTagName("img");
	p=[];
	var off_reg=new RegExp(off+"(\.[a-z]+$)","i");
	var on_reg=new RegExp(on+"(\.[a-z]+$)","i");
		for(var x=0,i;i=img[x];x++){
			if(i.src.match(off_reg)){
			p[x]=new Image();
			p[x].src=i.src.replace(off_reg,on+"$1");
			i.active = false;
			i.onmouseover=function(){
				if( this.src.match(off_reg) ){this.src=this.src.replace(off_reg,on+"$1");};
			};
			i.onmouseout=function(){
				if(!this.active && this.src.match(on_reg) ){this.src=this.src.replace(on_reg,off+"$1");};
			};
		};
	};
};

/*
img fadeIn function
*/

fade_in = function(){
		$('#photo').attr('src',$name);
		$("#photo").fadeIn();
};

/*
img preloader function
*/

preloader = function(){
	nav = document.getElementById("other_photo");
	if(nav){
	img=nav.getElementsByTagName("a");
	p=[];
		for(var x=0,i;i=img[x];x++){
		p[x]=new Image();
		p[x].src=i.href;
		}
	};
};

window.onload = function(){
  rollovers( "_o" , "_h" );
  preloader();
};

/*
popup window function
*/

//	For example:
//	<a href="./index.html" onclick="popUpWindow(800,600,this.href);return false;">

function popUpWindow(w,h,href){
win=window.open(href,"","scrollbars=yes,resizable=yes,Width="+ w +",Height="+ h);
win.focus();
}