function ajaxLoad(url,id,eval_str){
    if(document.getElementById){var x=(window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();}
    if(x){x.onreadystatechange=function() {
        el=document.getElementById(id);
        el.innerHTML='loading....';
        if(x.readyState==4&&x.status==200){
            el.innerHTML='';
            el=document.getElementById(id);
            el.innerHTML=x.responseText;
            eval(eval_str);
            }
        }
    x.open("GET",url,true);x.send(null);
    }
}
function pb_display(x,y)      
   {
   ajaxLoad('getrss.php?id_cate='+x+'&id_product='+y,'rssOutput');
   }

/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 */

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}



function open_me(url, vStatus, vResizeable, vScrollbars, vToolbar, vLocation, vFullscreen, vTitlebar, vCentered, vHeight, vWidth, vTop, vLeft)	 {
	winDef = '';
	winDef = winDef.concat('status=').concat((vStatus) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('resizable=').concat((vResizeable) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('scrollbars=').concat((vScrollbars) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('toolbar=').concat((vToolbar) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('location=').concat((vLocation) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('fullscreen=').concat((vFullscreen) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('titlebar=').concat((vTitlebar) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('height=').concat(vHeight).concat(',');
	winDef = winDef.concat('width=').concat(vWidth).concat(',');

	if (vCentered)	{
		winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
		winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	}
	else	{
		winDef = winDef.concat('top=').concat(vTop).concat(',');
		winDef = winDef.concat('left=').concat(vLeft);
	}
	open(url, '_blank', winDef);
	return false;
}
function popup(mylink, windowname)
{
 window.open (""+mylink,
"mywindow","menubar=0,resizable=1,width=780, height=600,toolbar=no,resizeable=yes,location=no,scrollbars=yes");

 
}
function olMouseMove(e) {
    var e = e ? e : event;
    if (e.pageX) {
        o3_x = e.pageX;
        o3_y = e.pageY;
    } else if (e.clientX) {
        o3_x = eval("e.clientX+o3_frame." + docRoot + ".scrollLeft");
        o3_y = eval("e.clientY+o3_frame." + docRoot + ".scrollTop");
    }
    if (o3_allowmove == 1)  {runHook("placeLayer",FREPLACE);if(olHideForm)hideSelectBox();   }
    if (hoveringSwitch && !olNs4 && runHook("cursorOff", FREPLACE)) {
        olHideDelay ? hideDelay(olHideDelay) : cClick();
        hoveringSwitch = !hoveringSwitch;
    }
}

function clearIn(control)
{
	control.value='';
}
function product_detail(){
	document.getElementById("add_help").style.display="block";
	document.getElementById("close_help").style.display="block";
}
function product_click(){
	document.getElementById("product_other").style.display="none";
	document.getElementById("product_detail").style.display="block";
}
function close_help_js(){
	document.getElementById("add_help").style.display="none";
	document.getElementById("close_help").style.display="none";
}
function addInput1() {
if (fields != 10) {
var vals;
if(fields){
	vals=document.getElementById(fields-1).value;
}
if(vals) {vals=vals;}else{vals='';}
document.getElementById('text_add').innerHTML += "<div id='"+fields+"' style=\"display:block\"><input name='catename_"+fields+"' type='text' size='30' value='"+vals+"' /> Thu tu : <input type='text' name='ordernum_"+fields+"' size='5' value='"+fields+"' /><span class='span_class_remove' onclick='remove_add_text("+fields+"); return true;'>Bo qua</span></div>";
fields += 1;
} else {
document.getElementById('text_add').innerHTML += "<br /><font color=\"#FF0000\">Khong duoc chon qua 10 danh muc can them.</font>";
document.form_name.add.disabled=true;
}
}
function remove_add_text(id){
	document.getElementById(id).style.display="none";
};


function change(t){
	document.getElementById('cp').className='button_go';
	document.getElementById('pd').className='button_go';
	document.getElementById('bl').className='button_go';
	document.getElementById('sl').className='button_go';
	document.getElementById(t).className='button_sellingleads_go';

		if (t=='sl'){
			document.getElementById('choice').value=1;
		}else{
			if (t=='bl'){
				document.getElementById('choice').value=2;
			}else{
				if (t=='cp'){
					document.getElementById('choice').value=3;
				}else{
					document.getElementById('choice').value=4;
				}

			}
		}
    }
function change_register(v){
		if(v==1){
				document.getElementById("choice_register").style.display="none";
			}else{
				document.getElementById("choice_register").style.display="block";
			}
			
	}