// JavaScript Document
function thong_ke(value)
{
	LoadXmlDoc('xml/thong_ke.php','');
}

function doidmtp(value)
{
	LoadXmlDoc('xml/doitp.php?id='+value,'div_quanhuyen');
}
function get_video(value)
{
	LoadXmlDoc('xml/get_video.php?id='+value,'get_video');
}

function get_video_duan(value)
{
	LoadXmlDoc('xml/get_video_duan.php?id='+value,'get_video');
}


function doidmqh(value)
{
	LoadXmlDoc('xml/doiqh.php?id='+value,'div_dm_kv');
}

function doidmkv(value)
{
	LoadXmlDoc('xml/doikv.php?id='+value,'');
}

function doidd(value,id)
{
	LoadXmlDoc('xml/doidd.php?id='+value,'div_dm_gia_ban');
}
function doi_khuvuc(value,id,loai)
{
	window.location='news_list.php?id='+id+'&khuvuc='+value+'&loai='+loai;
}

function doi_loai(value,id,khuvuc)
{
	window.location='news_list.php?id='+id+'&loai='+value+'&khuvuc='+khuvuc;
}

function view_pic(id,pic_multi)
{
	url='view_pic.php?id='+id+'&pic_multi='+pic_multi;
	var LeftPosition;
	var TopPosition;
	LeftPosition = (screen.width)/2-200;
	TopPosition = (screen.height)/2-200;
	newwindow=window.open(url,'name','height=10,width=10,top='+TopPosition+',left='+LeftPosition);
	if (window.focus) {newwindow.focus()}
	//return false;
}

// JavaScript Document
function over_menu(id,ele)
{
	set_all('menu_phu_span');	
	document.getElementById('menu_phu_'+id).style.display="block";

	/*padding_left=(document.body.clientWidth-998)/2;
	relative_left=tempX-padding_left;
	relative_right=document.body.clientWidth-2*padding_left-relative_left;
	
	if(relative_left<500)
	{
		document.getElementById('menu_phu_'+id).style.textAlign='left';
		document.getElementById('menu_phu_'+id).style.paddingRight='0px';
		document.getElementById('menu_phu_'+id).style.paddingLeft=relative_left/2+'px';
	}else
	{
		document.getElementById('menu_phu_'+id).style.textAlign='right';
		document.getElementById('menu_phu_'+id).style.paddingLeft='0px';
		document.getElementById('menu_phu_'+id).style.paddingRight=relative_right/2+'px';
	}*/
}

function set_all(className) 
  { 
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  if (navigator.userAgent.indexOf("MSIE")>=0)
		{ var cls = elem.getAttribute("className");}
		else
		{ var cls = elem.getAttribute("class");	}
	  if(cls == className)
	  {
		arr[arr.length] = id;
		 elem.style.display="none";
	  }
	}
  }
  
  
function overthis(ele)
{
	ele.style.cursor = 'pointer';
	if(	ele.className == 'tab')
	{
		ele.className = 'hover_tab'
	}
} 

function outthis(ele)
{
	if(	ele.className == 'hover_tab')
	{
		ele.className = 'tab'
	}
} 

function change_tab(ele,tabele)
{
	setCookie('c_tab',ele,2);
	document.getElementById('divtab').innerHTML=document.getElementById(ele).innerHTML;
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  if (navigator.userAgent.indexOf("MSIE")>=0)
		{ var cls = elem.getAttribute("className");}
		else
		{ var cls = elem.getAttribute("class");	}
	  if(cls == 'current_tab')
	  {
		arr[arr.length] = id;
		 elem.className="tab";
	  }
	}
	tabele.className = 'current_tab'

} 

function sosanh(id)
{
	submit_form('','button'+id,'xml/sosanh.php?id='+id,'')
} 

function setOpacity(object,value) {

	object.style.opacity = value/10;
	object.style.filter = 'alpha(opacity=' + value*10 + ')';
}


function change_detail_pic(id,picnum,ext,ele)
{
	document.getElementById('detail_pic').src="userfiles/estore/"+id+"/"+picnum+"."+ext;

	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  if (navigator.userAgent.indexOf("MSIE")>=0)
		{ var cls = elem.getAttribute("className");}
		else
		{ var cls = elem.getAttribute("class");	}
	  if(cls == 'thumb_pic')
	  {
		setOpacity(elem,5);
	  }
	}



	setOpacity(ele,10);


}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}


function check_product(id,checked)
{
	submit_form('test','','xml/check.php?id='+id+'&checked='+checked,'')
} 
function change_modem(id)
{
	submit_form('products_modem','','xml/change_modem.php?id='+id,'')
} 


function doidmtpdangtin(value)
{
	LoadXmlDoc('xml/doitpdangtin.php?id='+value,'div_dangtinquanhuyen');
}

function doidmqhdangtin(value)
{
LoadXmlDoc('xml/doiqhdangtin.php?id='+value,'div_dangtinkhuvuc');
}


function doidmgddangtin(value)
{
	LoadXmlDoc('xml/doigddangtin.php?id='+value,'div_unit');
}




function doiduan_khuvuc1(value)
{
	LoadXmlDoc('xml/doiduan_khuvuc1.php?id='+value,'div_duan_khuvuc2');
}


function doiduan_khuvuc2(value)
{
	LoadXmlDoc('xml/doiduan_khuvuc2.php?id='+value,'div_duan_khuvuc3');
}



function del_record(id,confim)
{
	var answer = confirm('Bạn đã chắc chắn xóa tin này?')
	if (answer){
		submit_form('xoaecho','','xml/xoatin.php?id='+id,'');
	}
}

function del_email(id,send_type)
{
	var answer = confirm('Bạn đã chắc chắn xóa email này ?')
	if (answer){
		submit_form('xoaemailecho','','xml/xoaemail.php?id='+id+'&send_type='+send_type,'');
	}
}

function del_record_now()
{
}


function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}


var iii=0
var du=1
function slide_now()
{
	iii++;
	if((iii%2)==1)
	{
	du='1';
	}else
	{
	du='0';
	}
	document.getElementById('vipcontent').innerHTML=document.getElementById('vipcontent'+du).innerHTML;
}

