// JavaScript Document

function pop_home_gift(url)
{
	window.open(url,"_blank","toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, copyhistory=0, width=355, height=605, top=0, left=0")
}

function pop_product_detail(url) {
	var win_width	  = 500;
	var win_height	  = 550;
	
	var screen_width  = screen.width;
	var screen_height = screen.height;
	
	var margin_left = screen_width - win_width;
	var margin_left_to_set = Math.floor(margin_left / 2) + "px";
	
	var margin_top = screen_height - win_height;
	var margin_top_to_set = Math.floor(margin_top / 2) + "px";

	window.open(url,"_blank","toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, copyhistory=0, width="+win_width+", height="+win_height+", top="+margin_top_to_set+", left="+margin_left_to_set)
}
function set_element_middle(obj_id, element_height) {
	var screen_height = document.body.clientHeight
	var margin = screen_height - element_height;
	var margin_to_set = Math.floor(margin / 2) + "px";

	$(obj_id).style.marginTop = margin_to_set;
}

function change_object_class(obj, style_class) {
	
	obj.className = style_class;
	
} // end function change_object_class

function change_image_src(id, event_type) {
	
	var img_obj = document.getElementById(id);
	
	if (event_type == 'over') {
		img_obj.src = 'image/side_bar_over.jpg';
	} 
	if (event_type == 'out') {
		img_obj.src = 'image/side_bar_off.jpg';
	}
} // end function change_image_src

function chanage_menu_image_src(name, image_path, event_type) {
	
	var over = image_path +"/"+ name +"_over.gif";
	var out  = image_path +"/"+ name +".gif";
		
	if (event_type == 'over') {
		document.images[name].src = over;
	} 
	if (event_type == 'out') {
		document.images[name].src = out;
	}
} // end function chanage_menu_image_src


function include_css_by_browser(css_path_prefix) {
 
	var browser     = '';
	var version     = '';
	var entrance    = '';
	var cond        = '';

	if (browser == ''){
		if (navigator.appName.indexOf('Microsoft') != -1)
			browser = 'IE';
		else if (navigator.appName.indexOf('Safari') != -1)
			browser = 'Safari';
		else if(navigator.userAgent.indexOf("Firefox")!=-1)
			browser = 'Firefox';
		else if(navigator.userAgent.indexOf("Opera")!=-1)
			browser = 'Opera';
		else if (navigator.appName.indexOf("Netscape") != -1)
			browser = 'Netscape';
		else 
			browser = 'Others';

	} // end if

	
	if (version == ''){
		version       = navigator.appVersion;
		paren         = version.indexOf('(');
		whole_version = navigator.appVersion.substring(0,paren-1);
		version       = parseInt(whole_version);
	} // end if
	
	if (browser == 'IE' && version >= 4) {
		document.write('<'+'link rel="stylesheet" href="'+ css_path_prefix +'_ie.css" />');
	}
	else if (browser == 'Netscape' || browser == 'Firefox' || browser == 'Safari' || browser == 'Opera' || browser == 'Netscape' ) {
		document.write('<'+'link rel="stylesheet" href="'+ css_path_prefix +'_std.css" />');
	}
	
} // end get_client_browser 

// please include prototype before use the function
// please form an sub-menu array (e.g. using php to form)
/*function hide_all_sub_menu() {

	for (i=0 ; i<menu_arr.length ; i++) {
			$(menu_arr[i]).hide();
	} // end for

} // end hide_element_by_array*/