// JavaScript Document

/////Roll Over Images for navigations
  //preload over images for shared buttons
var onimg = new Array();
onimg[0] = new Image();onimg[0].src = "/recruit/navigations/corporate_ov.gif";
onimg[1] = new Image();onimg[1].src = "/recruit/navigations/product_ov.gif";


function chimg(n, current){
	if ( !document.images[n] ) { return; }
	var imgsrc  = document.images[n].src;
	if ( imgsrc.match(/_ov\.gif$/) ) {
		var pfx = ( current ) ? "_cr.gif" : ".gif";
		imgsrc = imgsrc.replace(/_ov\.gif$/, pfx);
	} else {
		if ( current ) {
			imgsrc = imgsrc.replace(/_cr\.gif$/, "_ov.gif");
		} else {
			imgsrc = imgsrc.replace(/\.gif$/, "_ov.gif");
		}
	}
	document.images[n].src = imgsrc;
}

// For Current Page Image
function chimgCR(n) { chimg(n,1); }


/////For popup windows
function popup(url, winname){
	if ( url == '' ) return;
 if ( ! winname ) winname = '_blank';
	popwin = window.open(url, winname, 'width=100,height=100,scrollbars=yes,resizable=yes');
	if ( popwin ) popwin.focus();
}


function pwGetInnerWidth() {
	if ( window.opera ) { // For Opera
		return window.innerWidth;
	} else if ( document.all && document.getElementById ) { // For IE 6
		if ( document.documentElement.clientWidth ) {
			return document.documentElement.clientWidth;
		} else {
			return document.body.clientWidth;
		}
	} else if ( document.all ) { // For IE 4,5
		return document.body.clientWidth;
	} else if ( document.layers ) { // NN4
		return window.innerWidth;
	} else if ( document.getElementById ) { // Moz
		return window.innerWidth;
	}
	return null;
}

function pwGetInnerHeight() {
	if ( window.opera ) { // For Opera
		return window.innerHeight;
	} else if ( document.all && document.getElementById ) { // For IE 6
		if ( document.documentElement.clientHeight ) {
			return document.documentElement.clientHeight;
		} else {
			return document.body.clientHeight;
		}
	} else if ( document.all ) { // For IE 4,5
		return document.body.clientHeight;
	} else if ( document.layers ) { // NN4
		return window.innerHeight;
	} else if ( document.getElementById ) { // Moz
		return window.innerHeight;
	}
	return null;
}

function pwResizeTo(width, height) {
	if ( !width || !height ) return;

	var obj = self;

	// get size
	var w = pwGetInnerWidth();
	var h = pwGetInnerHeight();

//	if ( w > width  ) width  = w;
//	if ( h > height ) height = h;

	// resize
	obj.resizeTo(width,height);
	
	// get size
	w = pwGetInnerWidth();
	h = pwGetInnerHeight();

	// adjust
	if ( (w && width != w) || (h && height != h) ) {
		obj.resizeBy((width - w), (height - h));
		if ( document.layers ) {
			obj.location.reload(0) // For NN4
		}
		obj.focus();
	}
}

function popupInit(width, height) {
	pwResizeTo(width,height);
}

//link function for Opener
function openerLink(url) {
	if ( !url ) return;

	if ( window.opener ) {
		window.opener.location.href = url;
		window.opener.focus();
	}
	else {
		var newwin = window.open(url, '_blank', '');
		if ( newwin ) newwin.focus();
	}
}



/////for MacOS stylesheets 
function styleWrite() {
	 if(navigator.userAgent.indexOf("Mac")!=-1){
	  if(navigator.userAgent.indexOf("Safari")!=-1) {
				document.write ("<link href=../../old/common//"/common/safari.css/" rel=\"stylesheet\" type=\"text/css\">");
			}else if(navigator.userAgent.indexOf("Gecko")!=-1){
			 //document.write ("<link href=../../old/common//"/common/macmoz.css/" rel=\"stylesheet\" type=\"text/css\">");
		 } 
		}
}


// add 2008.3.18
function bg_select(){
	var key_id = 'bgs';

	if( !!document.key ){
		if( !!document.key.bg ){
			if( document.key.bg.value == 'standard' ){	// 'normal' page
				changeClass( key_id , 'base' );
			}
			else if( document.key.bg.value == 'press' ){	// 'press' page
				changeClass( key_id , 'prebase' );
			}
			else if( document.key.bg.value == 'info' ){	// 'info' page
				changeClass( key_id , 'popup2' );

				var mywidth  = '580';		// 'popup' window width
				var myheight = '530';		// 'popup' window height
				popupInit( mywidth, myheight );	// resize 'popup' window
			}
			else {
				changeClass( key_id , 'base' );
			}
		}
		else {
			changeClass( key_id , 'base' );
		}
	}
	else {
		changeClass( key_id , 'base' );
	}
}


function changeClass( id, class_name ){
	if( !!document.all ){
		document.all( id ).className = class_name;
	}
	else if( !!document.getElementById ){
		document.getElementById( id ).className = class_name;
	}
}


function open_ebook( link_obj ){
	window.open( link_obj.href, '_blank', 'width=1010,height=730,resizable=yes,scrollbars=no,status=no,titlebar=no,toolbar=no' );
}

