
function getbyid(id_name) {
	if (document.getElementById)
	{
		return document.getElementById(id_name);
	}
	else if (document.all)
	{
		return document.all[id_name];
	}
	else if (document.layers)
	{
		return document.layers[id_name];
	}
	else
	{
		return null;
	}
}
function is_valid_email(email) {

 return /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(email);
}
function openAWindow( pageToLoad, winName, width, height, center, scroll) {
	xposition=0;
	yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
  	xposition = (screen.width - width) / 2;
  	yposition = (screen.height - height) / 2;
  }

  args = "width=" + width + "," + "height=" + height + "," + "location=0," + "scrollbars=" + scroll + "," + "screenx=" + xposition + "," + "screeny=" + yposition + "," + "left=" + xposition + "," + "top=" + yposition;

  return window.open( pageToLoad, winName, args );
}

function zoom_image(img_fn, width, height) {
	if(width > 0 && height > 0) {
		var hnd = openAWindow('create_image.php?dir=products&thumb_size=fullsize&file_name=' + img_fn, 'zoom_larger', width, height, 1, 0);
	}	
}

function open_weblink() {
	frm = document.forms['frmLink'];
	
	lnk = frm.weblink.value;
	
	if(lnk != '') {
		frm.action = lnk;
		frm.submit();		
	}
	
}

function select_list( the_list, the_value ) {
 var the_list = getbyid(the_list);
 var option_count = the_list.options.length;

 for ( i = 0; i < option_count; i++ )
 {
  if ( the_value == the_list.options[i].value )
  {
   the_list.options[i].selected = true;
   break;
  }
 }
}

function dr(text) {
	document.write(text);
}

function show_gioithieu() {
	if(getbyid('gioithieu_p').style.display == 'none') {
		getbyid('gioithieu_p').style.display = '';
	}
	else {
		getbyid('gioithieu_p').style.display = 'none';
	}
}
function show_daynghe() {
	if(getbyid('daynghe_p').style.display == 'none') {
		getbyid('daynghe_p').style.display = '';
	}
	else {
		getbyid('daynghe_p').style.display = 'none';
	}
}

function show_cate(cateid) {
	if(getbyid('ic_plus_' + cateid).style.display == 'none') {
		getbyid('ic_plus_' + cateid).style.display = '';
		getbyid('ic_minus_' + cateid).style.display = 'none';
		getbyid('cate_' + cateid).style.display = 'none';		
	}
	else {
		getbyid('ic_plus_' + cateid).style.display = 'none';
		getbyid('ic_minus_' + cateid).style.display = '';
		getbyid('cate_' + cateid).style.display = '';
	}
}

function answer_faq(ques_id) {
	if(getbyid('faq' + ques_id).style.display == 'none') {
		getbyid('faq' + ques_id).style.display = '';
	}
	else {
		getbyid('faq' + ques_id).style.display = 'none';
	}
}