// JavaScript Document
/* for product.tpl */
function autoshow_advertise(){
	var widthWnd = screen.width;
	if(widthWnd > 800){
		document.getElementById('advertise_left_block').style.display = "block";
		document.getElementById('advertise_right_block').style.display = "block";
	}
	else{
		document.getElementById('advertise_left_block').style.display = "none";
		document.getElementById('advertise_right_block').style.display = "none";
	}
}

function producttype(typeid,manid){
	var pathlink = '?view=product&tid='+typeid+'&mid='+manid;
	document.location.replace(pathlink);
}
function detail(id){
	var pathlink = '?view=detail&id='+id;
	document.location.replace(pathlink);
}
function samples(id,typeid){
	var pathlink = '?view=sample&id='+id+'&tid='+typeid;
	document.location.replace(pathlink);
}

function gotopage(page, typeid, manid){
	var pathlink = '?view=product&cpg='+page+'&tid='+typeid+'&mid='+manid;
	document.location.replace(pathlink);
}
function gotopage_m(page, typeid, manid){
	var pathlink = '?view=productsx&cpg='+page+'&tid='+typeid+'&mid='+manid;
	document.location.replace(pathlink);
}


/* for detail.tpl */
function show( targets ){
    target_list = targets.split(',');
    for( i = 0 ; i < target_list.length; i++ ){
        document.getElementById( target_list[i] ).style.display="";
    }
}
function hide( targets ){
    target_list = targets.split(',');
    for( i = 0 ; i < target_list.length; i++ ){
        document.getElementById( target_list[i] ).style.display="none";
    }
}
function displayimages(id, iss){
	var pathlink = 'includes/images.php?id='+id+'&iss='+iss;
	window_open(pathlink, 600,520,'yes','normal');
}

/* dinh nghia khac */
<!--
var last_click;             // zuletzt angeklickter Button
var windows = new Array();  // Array mit Win-Objekten
function button_mouse_overme(obj){
	obj.className='mybutton_over';
}
function button_mouse_outme(obj){
	obj.className='mybutton';
}
function set_over(obj) {
   document.getElementById(obj).style.borderTopColor = "white";
   document.getElementById(obj).style.borderLeftColor = "white";
   document.getElementById(obj).style.borderBottomColor = "black";
   document.getElementById(obj).style.borderRightColor = "black";
}

function set_out(obj) {
   document.getElementById(obj).style.borderColor = "black";
}
function set_outh(obj) {
   document.getElementById(obj).style.borderColor = "ButtonFace";
}

function set_click(obj)
{
   document.getElementById(obj).style.borderTopColor = "black";
   document.getElementById(obj).style.borderLeftColor = "black";
   document.getElementById(obj).style.borderBottomColor = "white";
   document.getElementById(obj).style.borderRightColor = "white";
   elem1 = document.getElementById(last_click);
   if (elem1) elem1.style.fontWeight = "normal";
   last_click = obj;
   document.getElementById(obj).style.fontWeight = "bold";
}

function Win(ref, posx, posy) {
   this.ref  = ref;
   this.posx = posx;
   this.posy = posy;
}

function check_windows() {
   windows_new = new Array();
   for (i=0; i<windows.length; i++)
   {
    var found = false;
    try{
        if(!windows[i].ref.closed)
            found = true;
    }
    catch(e){
        found = false;
    }
    if (found && windows[i] && windows[i].ref && !windows[i].ref.closed) {
         windows_new.push(windows[i]);
         windows[i].ref.focus();
      }
   }
   windows = windows_new;
}

function window_open(url, w_width, w_height, scroll, type) {
	var proper;
   check_windows();
   ind = windows.length - 1;
   if (windows[ind]) {
      posx = windows[ind].posx + 20;
      posy = windows[ind].posy + 20;
   }
   else {
      posx = (screen.width - w_width) / 2;
      posy = (screen.height - w_height) / 2 - 30;
   }
   if (type == 'resizeable')  proper = 'titlebar=no,toolbar=yes,menubar=no,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=yes,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'normal')      proper = 'titlebar=no,toolbar=no,menubar=no,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'menu')        proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'mresizeable') proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=yes,left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy;
   if (type == 'minimized')   proper = 'titlebar=no,toolbar=no,menubar=yes,scrollbars='+scroll+',width='+w_width+',height='+w_height+',resizable=no,left='+screen.width+',top='+screen.height+',screenX='+screen.width+',screenY='+screen.height;
   

   win_ref = window.open(url, '', proper);
   if (win_ref) {
      tmp = new Win(win_ref, posx, posy);
      windows.push(tmp);
      win_ref.focus();
   }
   return win_ref;
}

function modal_open(url, w_width, w_height, scroll, type) {
	var proper;	
   if (type == 'normal')     proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:no;scroll:'+scroll+';status:no;';
   if (type == 'resizeable') proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:yes;scroll:'+scroll+';status:no;';
   window.showModalDialog(url, window, proper);
}

function modless_open(url, w_width, w_height, scroll, type) {
	var proper;
   if (type == 'normal')     proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:no;scroll:'+scroll+';status:no;';
   if (type == 'resizeable') proper = 'dialogHeight:'+w_height+'px;dialogWidth:'+w_width+'px;center:yes;edge:raised;help:no;resizable:yes;scroll:'+scroll+';status:no;';
   window.showModalDialog(url, window, proper);
}


function vntext(st)
{
var Rex = ["&#224;","&#7843;","&#227;","&#225;","&#7841;","&#259;","&#7857;","&#7859;","&#7861;","&#7855;","&#7863;","&#226;","&#7847;","&#7849;","&#7851;","&#7845;","&#7853;","&#273;","&#232;","&#7867;","&#7869;","&#233;","&#7865;","&#234;","&#7873;","&#7875;","&#7877;","&#7871;","&#7879;","&#236;","&#7881;","&#297;","&#237;","&#7883;","&#242;","&#7887;","&#245;","&#243;","&#7885;","&#244;","&#7891;","&#7893;","&#7895;","&#7889;","&#7897;","&#417;","&#7901;","&#7903;","&#7905;","&#7899;","&#7907;","&#249;","&#7911;","&#361;","&#250;","&#7909;","&#432;","&#7915;","&#7917;","&#7919;","&#7913;","&#7921;","&#7923;","&#7927;","&#7929;","&#253;","&#7925;","&#192;","&#7842;","&#195;","&#193;","&#7840;","&#258;","&#7856;","&#7858;","&#7860;","&#7854;","&#7862;","&#194;","&#7846;","&#7848;","&#7850;","&#7844;","&#7852;","&#272;","&#200;","&#7866;","&#7868;","&#201;","&#7864;","&#202;","&#7872;","&#7874;","&#7876;","&#7870;","&#7878;","&#204;","&#7880;","&#296;","&#205;","&#7882;","&#210;","&#7886;","&#213;","&#211;","&#7884;","&#212;","&#7890;","&#7892;","&#7894;","&#7888;","&#7896;","&#416;","&#7900;","&#7902;","&#7904;","&#7898;","&#7906;","&#217;","&#7910;","&#360;","&#218;","&#7908;","&#431;","&#7914;","&#7916;","&#431&#7918;","&#7920;","&#7922;","&#7926;","&#7928;","&#221;","&#7924;"]
var Req = ["224","7843","227","225","7841","259","7857","7859","7861","7855","7863","226","7847","7849","7851","7845","7853","273","232","7867","7869","233","7865","234","7873","7875","7877","7871","7879","236","7881","297","237","7883","242","7887","245","243","7885","244","7891","7893","7895","7889","7897","417","7901","7903","7905","7899","7907","249","7911","361","250","7909","432","7915","7917","7919","7913","7921","7923","7927","7929","253","7925","192","7842","195","193","7840","258","7856","7858","7860","7854","7862","194","7846","7848","7850","7844","7852","272","200","7866","7868","201","7864","202","7872","7874","7876","7870","7878","204","7880","296","205","7882","210","7886","213","211","7884","212","7890","7892","7894","7888","7896","416","7900","7902","7904","7898","7906","217","7910","360","218","7908","431","7914","7916","4317918","7920","7922","7926","7928","221","7924"]

     function replaceString(szString,szFind,szReplace){
    var iMatched, fSubstring, sSubstring;
    iMatched=0;
        while(iMatched>=0){
        iMatched=szString.indexOf(szFind);
        if(iMatched<0)
        return szString;
        fSubstring=szString.substring(0,iMatched);
        sSubstring=szString.substring(iMatched+szFind.length,szString.length);
        szString=fSubstring + szReplace + sSubstring;
    }
    // Next line for Netscape compatibility 
    //     only - no effects
    return(0);
}

var s = st
for (i=0;i<133;i++)
{

	s = replaceString(s,Rex[i],String.fromCharCode(Req[i]))
}
return s
}	
// Ham kiem tra chuoi nhap so dau cho cac Mang 

function ValidString(sText,sodau,socuoi)
{
	var ValidChars = "0123456789,";
	var IsNumber=true;
	var Char;
	// Kiem tra tinh hop le cua cac Ky tu trong chuoi
	for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
			Char = sText.charAt(i); 
			if (i == 0 && Char=="," ) // Kiem tra dau o dau chuoi
				{
					return false;
				}
					//continue;
			if (ValidChars.indexOf(Char) == -1) 
				{
					return false;
				}
       }		
// kiem tra tinh hop le cua vi tri dau cham (,) trong chuoi so, khong the co <> 3-4  chu so giua 2 dau ,
//var mang=new Array();
    var luu=sText;
	var mang=luu.split(",");
	if (mang.length>0)	
		for(i=0;i<mang.length;i++)
			{
			    if(mang[i].length>socuoi || mang[i].length <sodau)
				    return false;				
			}			

	return true;

}
//--> 
function isNumeric(str)
{	var iLen;
	iLen=str.length;
	var c ;
	for(var i=0; i<iLen; i++)
	{	c = str.charAt(i);
		if ((c<'0') || (c>'9'))
			return false;
	}
	return true;
}