// JavaScript Document
//============================================================================================================
// Form Validation
//============================================================================================================
_root = "/"
_dataroot = "/"

function load_category(_oid, _cat, _page){
///try{
		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = _root + "ajax/actions.aspx?type=productcate&page=" + window.encodeURIComponent(_page) + "&cat=" + window.encodeURIComponent(_cat) + "&anticache=" + Math.random();		

		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}		
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					
					obj.innerHTML = HttpRequest.responseText;					
			   } else {
				   
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	//}catch(ex){}	
}

function viewCat(_oid, _cid, _page, _inum){
	try{
	
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		
		if((_oid==null)||(_oid=='')||(_cid==null)||(_cid=='')){return;}
		var obj = document.getElementById(_oid);
		
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=viewcat&cat=" + window.encodeURIComponent(_cid) + "&page=" + window.encodeURIComponent(_page) + "&inum=" + window.encodeURIComponent(_inum) + "&rd=" + Math.random();
		/*var actionURL = "Viettel_new/ajax/actions.aspx?type=viewcat&cat=" + window.encodeURIComponent(_cid) + "&page=" + window.encodeURIComponent(_page) + "&inum=" + window.encodeURIComponent(_inum) + "&rd=" + Math.random();*/
		//window.location = actionURL;
		
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;
					$('.pitem .img').Tooltip({
						track: true,
						opacity: 1,
						fixPNG: true,
						top: -15,
						showBody: "@",
						left: 5
					});
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}

function viewCats(_oid, _cid, _page, _inum){
	try{
	
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		
		if((_oid==null)||(_oid=='')||(_cid==null)||(_cid=='')){return;}
		var obj = document.getElementById(_oid);
		
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=viewcats&cat=" + window.encodeURIComponent(_cid) + "&page=" + window.encodeURIComponent(_page) + "&inum=" + window.encodeURIComponent(_inum) + "&rd=" + Math.random();
		/*var actionURL = "Viettel_new/ajax/actions.aspx?type=viewcat&cat=" + window.encodeURIComponent(_cid) + "&page=" + window.encodeURIComponent(_page) + "&inum=" + window.encodeURIComponent(_inum) + "&rd=" + Math.random();*/
		//window.location = actionURL;
		
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;
					$('.pitem .img').Tooltip({
						track: true,
						opacity: 1,
						fixPNG: true,
						top: -15,
						showBody: "@",
						left: 5
					});
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}



function PortfolioPaging(_oid, _page) {
	///try{
		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = _root + "ajax/actions.aspx?type=portfoliopaging&page=" + window.encodeURIComponent(_page) + "&anticache=" + Math.random();		
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}		
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;
					$(".lightbox").lightbox({
						fileLoadingImage : '../images/assets/lightbox/loading.gif',
						fileBottomNavCloseImage : '../images/assets/lightbox/closelabel.gif'
					});					
					//Slimbox.scanPage();
					//Lightbox.init();
			   } else {
				   
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	//}catch(ex){}	
}


function trim2(str) {     
	if(!str || typeof str != 'string')         
		return null;     
	return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' '); 
}

function trim( s )
{
	var i, sRetVal = "";
	i = s.length - 1;
	while ( i>=0 && s.charAt(i) == ' ' ) i--;
	s = s.substring( 0, i+1 ); // trim blanks on the right
	i = 0;
	while ( i< s.length && s.charAt(i) == ' ') i++;
	return s.substring( i );
}

function validEmail(str) {
	var strEmail = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	if(!strEmail.test(str)) {
		return false;
	}else{
		return true;
	}	
}

function validUsername(str) {
	var strUsername = /^[a-zA-Z]{3,20}$/;
	if(!strUsername.test(str)) {
		return false;
	}else{
		return true;
	}	
}

function validate_ex(theForm, _ErrMsg, arrNotRequired) {
	validForm = true;
	firstError = null;
	errorstring = '';
	var x = document.forms[theForm].elements;
	var arr = ','+arrNotRequired.toString()+ ',';
	for (var i=0;i<x.length;i++) {
		if (arr.indexOf(','+x[i].name+',')==-1) {
			if (!x[i].value)
			{
				var str="";
				str = "".concat(x[i].type);
				if ((str.toString() != "undefined") && (str.toString() != "button") && (str.toString() != "hidden"))
				{
					writeError(x[i], _ErrMsg);
					if (firstError ==null)
					firstError = x[i];
				}
			}
			if (x[i].name == 'txtEmail')
			{			
				var strEmail = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
				if(!strEmail.test(x['txtEmail'].value))
					writeError(x['txtEmail'],'e-mail is not valid !');
			}
			if (x[i].name == 'txtConfirm')
			{
				if(x['txtConfirm'].value != x['txtPassword'].value)
					writeError(x['txtConfirm'],'confirm password is not valid !');
			}
			if(x[i].name == 'txtPassword')
			{
				if(x['txtPassword'].value.length < 6)
					writeError(x['txtPassword'],'password must be longer than 6 characters !')
			}
			if(x[i].name == 'txtoldpass')
			{
				if(x['txtoldpass'].value.length < 6)
					writeError(x['txtoldpass'],'password must be longer than 6 characters !')
			}
			if(x[i].name == 'txtpassword')
			{
				if(x['txtpassword'].value.length < 6)
					writeError(x['txtpassword'],'password must be longer than 6 characters !')
			}
			if (x[i].name == 'txtconfirm')
			{
				if(x['txtconfirm'].value != x['txtpassword'].value)
					writeError(x['txtconfirm'],'**'); //confirm password is not valid !
			}
			if (x[i].name == 'txtnewpass')
			{
				if(x['txtnewpass'].value.length < 6)
					writeError(x['txtnewpass'],'password must be longer than 6 characters !')
			}
			if (x[i].name == 'txtemail')
			{			
				var strEmail = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
				if(!strEmail.test(x['txtemail'].value))
					writeError(x['txtemail'],'e-mail is not valid !');
			}			
			if (x[i].name == 'year'){
				if (x['year'].value == 0){
					writeError(x['year'],'(*)');
					writeError(x['month'],'');
					writeError(x['day'],'');
				}
				else{
					if (x['month'].value == 0){
						writeError(x['year'],'(*)');
						writeError(x['month'],'');
						writeError(x['day'],'');
					}
					else{
						if (x['day'].value == 0){
							writeError(x['year'],'(*)');
							writeError(x['month'],'');
							writeError(x['day'],'');
						}
						else{
							removeNodeError('bd_year');
							removeNodeError('bd_month');
							removeNodeError('bd_day');
						}
						
					}
				}
			}
			if (x[i].name == 'year'){
				var strDate = x['day'].value + '/' + x['month'].value + '/' + x['year'].value;				
				if(!isDate(strDate)) {
					writeError(x['year'], 'Invalid date');
				}
			}
			if (x[i].name == 'sltcountry'){
				if (x['sltcountry'].value == 0){
					writeError(x['sltcountry'],'(*)');
					
				}
			}
		}
	}
	if (!W3CDOM)
		alert(errorstring);
	if (firstError)
		firstError.focus();
	if (validForm)
		return true;
		
	return false; // I return false anyway to prevent actual form submission. Don't do this at home!
}
function validate(theForm, _ErrMsg ) {
	try {
		validForm = true;
		firstError = null;
		errorstring = '';
		var _frm = document.getElementById(theForm);
		if(_frm==null){return false;}
		var x = document.forms[theForm].elements;
		for (var i=0;i<x.length;i++) {
			
			if (!x[i].value)
			{
				var str="";
				str = "".concat(x[i].type);
				if ((str.toString() != "undefined") || (str.toString() != "button") || (str.toString() != "hidden"))
				{
					writeError(x[i], _ErrMsg);
					if (firstError ==null)
					firstError = x[i];				
				}
			}
			if (x[i].name == 'txtemail')
			{			
				var strEmail = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
				if(!strEmail.test(x['txtemail'].value))
					writeError(x['txtemail'],'  *');
			}
		}
		
		if (!W3CDOM)
			alert(errorstring);
		if (firstError)
			firstError.focus();
		if (validForm)
			return true;
			
		return false; // I return false anyway to prevent actual form submission. Don't do this at home!
		
	}catch(ex){return(false);}
}

function writeError(obj,message) {
	validForm = false;
	if (obj.hasError) return;
	if (W3CDOM) {
		obj.className += ' error';
		obj.onchange = removeError;
		var sp = document.createElement('span');
		sp.className = 'error';
		sp.appendChild(document.createTextNode(message));
		obj.parentNode.appendChild(sp);
		obj.hasError = sp;
	}
	else {
		errorstring += obj.name + ': ' + message + '\n';
		obj.hasError = true;
	}
	if (!firstError)
		firstError = obj;
}

function removeError() {
	this.className = this.className.substring(0,this.className.lastIndexOf(' '));
	this.parentNode.removeChild(this.hasError);
	this.hasError = null;
	this.onchange = null;
}
function removeNodeError(_nodeId){
	var obj = document.getElementById(_nodeId);
	try{
		obj.className = obj.className.substring(0,obj.className.lastIndexOf(' '));
		obj.parentNode.removeChild(obj.hasError);
		obj.hasError = null;
		obj.onchange = null;
	}
	catch(ex){
		
	}
}
//============================================================================================================
// END Form Validation
//============================================================================================================

// JavaScript Document
function generalSearch(){
	try{
		var _frm = document.getElementById('frmsearch');
		_frm.action = 'Search';
		_frm.submit();
	}catch(ex){}
}
//function trimtext(_text) { return _text.replace(/^\s+|\s+$/, '').substr(0, _text.replace(/^\s+|\s+$/, '').length); };
function trimtext(_text) {
	var tmp=_text;
	while((tmp.substr(0,1)==' ')&&(tmp.length>0)){
		tmp = tmp.substr(1, tmp.length);
	}
	while((tmp.substr(tmp.length-1,1)==' ')&&(tmp.length>0)){
		tmp = tmp.substr(0,tmp.length-1);
	}
	return(tmp)
}
function changeImg(_dest, _destLink, _destTitle, _arr, _arrLink, _arrTitle, _index, _interval) {
	try {
		var i, obj, objLink, objTitle;
		obj = document.getElementById(_dest);
		objLink = document.getElementById(_destLink);
		objTitle = document.getElementById(_destTitle);
		if((obj==null)||(objLink==null)||(objTitle==null)){return;}
		i = _index + 1;
		if((i>=_arr.length)||(i<0)){i=0;}
		obj.src = _arr[i];
		obj.alt = arrTitle[i];
		objLink.href = _arrLink[i];
		objTitle.innerHTML = arrTitle[i];
		setTimeout("changeImg('" + _dest + "','" + _destLink + "','" + _destTitle + "',arr,arrLink,arrTitle," + i + "," + _interval + ")", _interval)
	}catch(ex){}
}
function changeAdv(_dest, _arr, _index, _interval) {
	try{
		var i, obj;
		obj = document.getElementById(_dest);
		if(obj==null){return;}
		i = _index + 1;
		if((i>=_arr.length)||(i<0)){i=0;}
		obj.innerHTML = _arr[i];
		setTimeout("changeAdv('" + _dest + "',arrAdv," + i + "," + _interval + ")", _interval)
	}catch(ex){}
}
//============================================================================================================
// Ajax function
//============================================================================================================

function changelang(_lang) {
	try {
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_lang==null)||(_lang=='')){return;}
		var actionURL = "ajax/actions.aspx?type=language&lang=" + window.encodeURIComponent(_lang) + "&anticache=" + Math.random();
		//window.location = actionURL;
//		return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
				   
					//window.location.reload(true);
					window.location = "default.aspx";
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}

function submitLetter(_mail){
	try{
		return (false);
	}catch(ex){}
}
function viewCat(_oid, _cid, _page){
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')||(_cid==null)||(_cid=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=viewcat&cat=" + window.encodeURIComponent(_cid) + "&page=" + window.encodeURIComponent(_page) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}
function setOrderBy(_oid, _cid, _order) {
	try {
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')||(_cid==null)||(_cid=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=orderby&cat=" + window.encodeURIComponent(_cid) + "&order=" + window.encodeURIComponent(_order) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}
function changeSearchType(_oid, _type, _selectedValue, _root){
	try {
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')||(_type=='')||(_type==null)){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		//obj.innerHTML = '<img src="/images/data/indicator.gif />"';
		var actionURL = _root + "ajax/actions.aspx?type=getcat&cattype=" + window.encodeURIComponent(_type) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					var xml = HttpRequest.responseXML;
					while (obj.length > 1){
						obj.remove(1);
					}
					//var root = xml.documentElement;
					var root = xml.getElementsByTagName("option")
					if (root.length > 0){
						for(var i=0;i<root.length;i++){
							var oOption = document.createElement("OPTION");
							oOption.value = root[i].getAttribute("id");
							oOption.text = root[i].getAttribute("name");
							if(_selectedValue==oOption.value){
								oOption.selected = true;
							}
							obj.options[i+1] = oOption;
						}
					}
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}
function searchPaging(_oid, _keywords, _searchtype, _searchcat, _page, _root, _dataroot) {
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="' & _dataroot & '/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=searchpaging&keywords=" + window.encodeURIComponent(_keywords) + "&stype=" + window.encodeURIComponent(_searchtype) + "&scat=" + window.encodeURIComponent(_searchcat) + "&page=" + window.encodeURIComponent(_page) + "&rd=" + Math.random();
		//var actionURL = _root + "ajax/searchpaging/" + window.encodeURIComponent(_keywords) + "/" + window.encodeURIComponent(_searchtype) + "/" + window.encodeURIComponent(_searchcat) + "/" + window.encodeURIComponent(_page) + "/" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}

function faqPaging(_oid, _page, _root) {
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		obj.innerHTML = '<img src="' & _root &  '/images/data/indicator.gif" />';
		var actionURL = _root + "ajax/actions.aspx?type=faqpaging&page=" + window.encodeURIComponent(_page) + "&rd=" + Math.random();
		//var actionURL = _root + "ajax/faqpaging/" + window.encodeURIComponent(_page) + "/" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;
			   } else {
				   
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}

function Login(_form, _outObj) {
	try{
		var getStr = "type=login&antiCache=" + Math.random();
		var inputList = _form.getElementsByTagName("input");
		var outObj = document.getElementById(_outObj);
		var indicatorObj = document.getElementById('processing')
		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		
		if (!HttpRequest) return;		
		if((_form==null)||(_form=='')){return;}
		if((_outObj==null)||(_outObj=='')){return;}		
			
		if(!outObj){return;}
		
		for (i=0; i<inputList.length; i++) {
			 if (inputList[i].type == "text" || inputList[i].type == "password" || inputList[i].type == "hidden") {
				   getStr += "&" + inputList[i].id + "=" + encodeURI(inputList[i].value);
			 }   
		  }
		
		indicatorObj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx";		
		
		//window.location = actionURL;
		//return;
		//var indicator = document.getElementById('processDiv');
//		if(indicator!=null){
//			indicator.style.display = 'block';
//		}
		//HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			    if(HttpRequest.responseText.indexOf('err=')!=1){
					outObj.innerHTML = HttpRequest.responseText;	
			   }
			   //if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		//HttpRequest.send(null);
		HttpRequest.open('POST', actionURL, true);
		HttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		HttpRequest.setRequestHeader("Content-length", getStr.length);
		HttpRequest.setRequestHeader("Connection", "close");
		HttpRequest.send(getStr);
		return;
	}catch(ex){}
}

function LoadLoginBlock(_oid) {
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=loadloginblock&rd=" + Math.random();		
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}

function Logout(_oid) {
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=logout&rd=" + Math.random();		
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}

function CheckUsername(_strUser, _inObj, _outObj) {
	//try{		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_strUser==null)||(trim(' ' + _strUser)=='')){return;}
		if(validUsername(_strUser)==false){return;}
		if((_inObj==null)||(_inObj=='')){return;}
		if((_outObj==null)||(_outObj=='')){return;}
		
		var obj = document.getElementById(_outObj);		
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=checkusername&username=" + encodeURI(_strUser) + "&anticache=" + Math.random();		
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	//}catch(ex){}
}

function CheckEmail(_strEmail, _inObj, _outObj) {
	try{		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_strEmail==null)||(trim(' ' + _strEmail)=='')){return;}
		if(validEmail(_strEmail)==false){return;}
		if((_inObj==null)||(_inObj=='')){return;}
		if((_outObj==null)||(_outObj=='')){return;}
		
		var obj = document.getElementById(_outObj);		
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=checkemail&email=" + encodeURI(_strEmail) + "&anticache=" + Math.random();		
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}

function InsertNewRegister(_form, _outObj, _outObj2) {
	try{
		var getStr = "type=register&antiCache=" + Math.random();
		var inputList = _form.getElementsByTagName("input");
		var outObj = document.getElementById(_outObj);
		var outObj2 = document.getElementById(_outObj2);
		var indicatorObj = document.getElementById('processing')
		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		
		if (!HttpRequest) return;		
		if((_form==null)||(trim(' ' + _form)=='')){return;}
		if((_outObj2==null)||(trim(' ' + _outObj)=='')){return;}
		if((_outObj2==null)||(trim(' ' + _outObj2)=='')){return;}
			
		if(!outObj){return;}
		if(!outObj2){return;}
		
		for (i=0; i<inputList.length; i++) {
			 if (inputList[i].type == "text" || inputList[i].type == "password" || inputList[i].type == "hidden") {
				   getStr += "&" + inputList[i].id + "=" + encodeURI(inputList[i].value);
			 }   
		  }
		
		//indicatorObj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "/ajax/actions.aspx";		
		
		//window.location = actionURL;
		//return;
		//var indicator = document.getElementById('processDiv');
//		if(indicator!=null){
//			indicator.style.display = 'block';
//		}
		//HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			    if(HttpRequest.responseText.indexOf('err=')!=1){
					outObj.innerHTML = HttpRequest.responseText;
					outObj.className = "msg warning";
					outObj2.innerHTML = HttpRequest.responseText;
					outObj2.className = "msg warning";
			   }
			   //if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		//HttpRequest.send(null);
		HttpRequest.open('POST', actionURL, true);
		HttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		HttpRequest.setRequestHeader("Content-length", getStr.length);
		HttpRequest.setRequestHeader("Connection", "close");
		HttpRequest.send(getStr);
		return;
	}catch(ex){}
}

//============================================================================================================
// END Ajax function
//============================================================================================================

function get_porfolio(_oid) {
	try{
		var getStr = "type=porfolio"
		getStr += get_value(_oid);
		getStr += "&rd=" + Math.random(); 
		var actionURL =  "/ajax/actions.aspx";		
		
		$.ajax({
			type: "POST",
			url: actionURL,
			data: getStr,
			success: function(msg){
				if(msg.indexOf('err=')!=0){
					alert('Ban da gui lien he thanh cong!');
				}
			}
		});
		return;
	}catch(ex){}
}


function do_search(_oid, _keywords, _searchtype, _searchcat, _page ) {
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="' + _dataroot + 'images/data/indicator.gif" />';
		var actionURL = _root +  "ajax/actions.aspx?type=searchpaging&txtSearch=" + window.encodeURIComponent(_keywords) + "&stype=" + window.encodeURIComponent(_searchtype) + "&cat=" + window.encodeURIComponent(_searchcat) + "&page=" + window.encodeURIComponent(_page) + "&rd=" + Math.random();
		//var actionURL = _root + "ajax/searchpaging/" + window.encodeURIComponent(_keywords) + "/" + window.encodeURIComponent(_searchtype) + "/" + window.encodeURIComponent(_searchcat) + "/" + window.encodeURIComponent(_page) + "/" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex.message);}
}


function albumPaging(_oid, _page) {
	///try{
		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = _root + "ajax/actions.aspx?type=albumPaging&page=" + window.encodeURIComponent(_page) + "&anticache=" + Math.random();		
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}		
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;
/*
					$(".blightbox").lightbox({
						fileLoadingImage : '../images/assets/lightbox/loading.gif',
						fileBottomNavCloseImage : '../images/assets/lightbox/closelabel.gif'
					});
					//Slimbox.scanPage();
					//Lightbox.init();*/
			   } else {
				   
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	//}catch(ex){}	
}
function NewsPaging(_oid, _page, catID) {
	///try{
		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = _root + "ajax/actions.aspx?type=newspaging&page=" + window.encodeURIComponent(_page) + "&cat=" + window.encodeURIComponent(catID) + "&anticache=" + Math.random();		
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}		
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					
					obj.innerHTML = HttpRequest.responseText;					
			   } else {
				   
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	//}catch(ex){}	
}


function load_list_news(_oid, _cat, _page){
try{
		
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}		
		var obj = document.getElementById(_oid);		
		if(!obj){return;}				
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = _root + "ajax/actions.aspx?type=list_news&page=" + window.encodeURIComponent(_page) + "&cat=" + window.encodeURIComponent(_cat) + "&anticache=" + Math.random();		
        
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}		
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					
					obj.innerHTML = HttpRequest.responseText;					
			   } else {
				   
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}	
}

function print_page(_type,_cid,_id){
	try{
		$('#print').after("<form action='print.aspx' id='print_form' method='post'></form>");
		$('#print_form').append("<input type='hidden' name='type' value='"+ _type+"' />");
		$('#print_form').append("<input type='hidden' name='cat' value='"+ _cid+"' />");
		$('#print_form').append("<input type='hidden' name='nid' value='"+ _id+"' />");
		$('#print_form').submit();
	}catch(ex){}	
}
function email_page(_title,_body){
	try{
		if(!_body){_body=window.location.toString();}
		if(!_title){_title=document.title;}
		window.location = "mailto:your-friend@email.com?subject=" + encodeURIComponent(_title) + '&body=' + window.encodeURIComponent(_body);
	}catch(ex){}
}
function bookmark_page(_title){
	try{
		if(!_title){_title=document.title;}
		if (window.external)
			window.external.AddFavorite(window.location.toString(),_title);
	}catch(ex){}
}
function FilePaging(_oid, _page, _type) {
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=" + window.encodeURIComponent(_type) + "&page=" + window.encodeURIComponent(_page) + "&rd=" + Math.random();		
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}		
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=1){
					obj.innerHTML = HttpRequest.responseText;
			   } else {
				   
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}
// Specific functions
function viewTab(_oid, _pid, _fid){
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')||(_pid==null)||(_pid=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=viewTab&pid=" + window.encodeURIComponent(_pid) + "&fid=" + window.encodeURIComponent(_fid) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex.tostring);}
}
function Show(_oid, _cat, _page){
///try{
		alert("aaaaa");
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;		
		if((_oid==null)||(_oid=='')){return;}
		
		var obj = document.getElementById(_oid);		
		if(!obj){return;}
		
		obj.innerHTML = '<img src="/images/data/indicator.gif" />';
		/*var actionURL = _root + "ajax/actions.aspx?type=productpage&page=" + window.encodeURIComponent(_page) + "&cat=" + window.encodeURIComponent(_cat) + "&anticache=" + Math.random();*/	
		var actionURL = "/Viettel_New/ajax/actions.aspx?type=productpage&page=" + window.encodeURIComponent(_page) + "&cat=" + window.encodeURIComponent(_cat) + "&anticache=" + Math.random();

		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}		
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					
					obj.innerHTML = HttpRequest.responseText;					
			   } else {
				   
			   }
			   if(indicator!=null){indicator.style.display = 'none';indicator.innerHTML = "";}
		   }
		}
		HttpRequest.send(null);
		return;
	//}catch(ex){}	
}
