﻿// validates that the entry is formatted as an email address
function isEMailAddr(elem) {
    var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        //alert("Verify the email address format.");
        return false;
    } else {
        return true;
    }
}
/*
===============================================
	Author	: Nguyen Thanh Tung
	Date Created : 2005
	Date Modified: None 	
	Name	: doCheckAll
	Para	:
			- formName		: The form name contain checkbox
			- chkAllName	: The checkboxAll name
			- chkOneName	: The checkboxOne name
			
	Purpose	: Select all elements in List by CheckBoxes	
===============================================
*/
function doCheckAll(formName,chkAllName,chkOneName)
	{
	if (formName==null || formName=='') formName="frmMain";
    if (chkAllName==null || chkAllName=='') chkAllName="chkAll";
    if (chkOneName==null || chkOneName=='') chkOneName="chkOne";
    
	elemAll=document.forms[formName].elements[chkAllName];
	elemOne=document.forms[formName].elements[chkOneName];
	
	if (elemOne.length>1)
	{
		for(var i=0;i<elemOne.length;i++)
		{
			elemOne[i].checked=elemAll.checked;
		}
	}else
	{
		elemOne.checked=elemAll.checked;
	}
	return true;
	}

	
function doCheckOne(formName,chkAllName,chkOneName)
	{
	if (formName==null || formName=='') formName="frmMain";
    if (chkAllName==null || chkAllName=='') chkAllName="chkAll";
    if (chkOneName==null || chkOneName=='') chkOneName="chkOne";
    
	elemAll=document.forms[formName].elements[chkAllName];
	elemOne=document.forms[formName].elements[chkOneName];
	
	if (elemOne.length>1)
	{
		for(var i=0;i<elemOne.length;i++)
		{
			if (elemOne[i].checked==false)
			{
				elemAll.checked=false;
				return true;
			}
		}
	}
	else
	{
		if (elemOne.checked==false)
			{
				elemAll.checked=false;
				return true;
			}
	}
	elemAll.checked=true;
	return true;
	}
/*
	Author	: Nguyen Thanh Tung
	Date Created : 2005
	Date Modified: None 	
	Name	: doSubmit
	Para	:
	        - th            : Cac truong hop su ly
	        - ID            : ID can su ly
			- formName		: The form name contain checkbox
			- chkAllName	: The checkboxAll name
			- chkOneName	: The checkboxOne name
			
	Purpose	: check before submit form
*/
function doSubmit(languages,th,ID,formName,chkAllName,chkOneName)
{   var msg="";
	var txtlanguages,txtTh,txtID,txtEdit;
	var strASP="";
		
    if (languages==null) languages="";
	if (th==null) th="";
    if (ID==null) ID="";
    if (formName==null || formName=='') formName="frmMain";
    if (chkAllName==null || chkAllName=='') chkAllName="chkAll";
    if (chkOneName==null || chkOneName=='') chkOneName="chkOne";
	
  	txtlanguages=document.forms[formName].all.languages;
	txtTh=document.forms[formName].all.th;
	txtID=document.forms[formName].all.ID;
	
	if (th=='checkDomain') {
	    elemAll=document.forms[formName].elements[chkAllName];
	    elemOne=document.forms[formName].elements[chkOneName];
		if (elemOne!=null){
			if (elemOne.length>1){	
				for(var i=0;i<elemOne.length;i++) {
					if (elemOne[i].checked) {
						ID+=elemOne[i].value + ","; 
					}
				}
			}
			else {
				if (elemOne.checked) { 
					ID=elemOne.value + ",";
				}
			}
		}
		if (ID!="") {
			ID=ID.substring(0,ID.length-1); }
		else {
			alert("Bạn phải chọn các phần tử trong danh sách!");
			return false;
		}
		window.location="?th="+th+"&domain="+document.all.txtDomain.value+"&suffix="+ID;
		return true;
	}   
	txtlanguages.value=languages;
	txtTh.value		=	th;
	txtID.value		=	ID;
	
	//alert("ID=" + ID + ";th=" + th);
	//return false;
	
	window.location="?languages="+languages+"&th="+th+"&ID="+ID;
	//document.forms[formName].action="?th="+th+";ID"+ID;
	//document.forms[formName].submit();
	return true;
}
/*************************************************************************
  Create viewport
*************************************************************************/  
  
var viewport = {
  getWinWidth: function () {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
  	else if (document.documentElement && document.documentElement.clientHeight) 
  		this.height = document.documentElement.clientHeight;
  	else if (document.body && document.body.clientHeight) 
  		this.height = document.body.clientHeight;
  },
  
  getScrollX: function () {
    this.scrollX = 0;
  	if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		this.scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		this.scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) this.scrollX = window.scrollX;
  },
  
  getScrollY: function () {
    this.scrollY = 0;    
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
  		this.scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		this.scrollY = document.body.scrollTop; 
  	else if (window.scrollY) this.scrollY = window.scrollY;
  },
  
  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }
  
}
/*************************************************************************
  CREATE ROLLTIP
*************************************************************************/

var RollTip = {
  offX: 12,
  offY: 12,
  ID: "rolltipDiv",
  aniLen: 300,  // duration of clipping animation
  ready: false,
  t1: null,
  t2: null,
  tip: null,
  
  init: function() {
    if ( document.createElement && document.body && 
        typeof document.body.appendChild != "undefined" && !window.opera ) {
      var el = document.createElement("DIV");
      el.className = "rolltip"; el.id = this.ID;
      document.body.appendChild(el);
      this.mult = el.offsetWidth/this.aniLen/this.aniLen;	
      el.style.clip = "rect(0, 0, 0, 0)";
      el.style.visibility = "visible";
      this.ready = true;
    }
  },

  reveal: function(msg, e) {
    if (this.t1) clearTimeout(this.t1);	if (this.t2) clearTimeout(this.t2); 
    this.tip = document.getElementById( this.ID );
    this.writeTip(msg);
    viewport.getAll();
    this.w = this.tip.offsetWidth; this.h = this.tip.offsetHeight;
    this.startTime = (new Date()).getTime();
    this.positionTip(e);
    this.t1 = setInterval("RollTip.rollOut()", 10);
  },
  
  rollOut: function() {
    var elapsed = (new Date()).getTime() - this.startTime;
  	if (elapsed < this.aniLen) {
  		var cv = this.w - Math.round( Math.pow(this.aniLen - elapsed, 2) * this.mult );
  		this.clipTo(0, cv, this.h, 0);
  	} else {
      this.clipTo(0, this.w, this.h,0);
      clearInterval(this.t1);
    }
  },
  
  conceal: function() {
  	if (this.t1) clearInterval(this.t1);	if (this.t2) clearInterval(this.t2);
  	this.startTime = (new Date()).getTime();
  	this.t2 = setInterval("RollTip.rollUp()", 10);
  },
  
  rollUp: function() {
  	var elapsed = (new Date()).getTime() - this.startTime;
  	if ( elapsed < this.aniLen ) {
  		var cv = Math.round( Math.pow(this.aniLen - elapsed, 2) * this.mult );
  		this.clipTo(0, cv, this.h, 0);
  	} else {
      this.clipTo(0, 0, this.h, 0);
      clearInterval(this.t2);
      this.tip = null;
    }  
  },
  
  writeTip: function(msg) {
    if ( this.tip && typeof this.tip.innerHTML != "undefined" ) this.tip.innerHTML = msg;
  },
  
  clipTo: function(top, rt, btm, lft) {
    this.tip.style.clip = "rect("+top+"px, "+rt+"px, "+btm+"px, "+lft+"px)";
  },
  
  positionTip: function(e) {
    var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
    var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
    if ( x + this.tip.offsetWidth + this.offX > viewport.width + viewport.scrollX )
      x = x - this.tip.offsetWidth - this.offX;
    else x = x + this.offX;
  
    if ( y + this.tip.offsetHeight + this.offY > viewport.height + viewport.scrollY )
      y = ( y - this.tip.offsetHeight - this.offY > viewport.scrollY )? y - this.tip.offsetHeight - this.offY : viewport.height + viewport.scrollY - this.tip.offsetHeight;
    else y = y + this.offY;

    this.tip.style.left = x + "px"; this.tip.style.top = y + "px";
  }

}

var imageHandler = { 
  imgs:[], path:"", preload:function() { for(var i=0;arguments[i];i++) {
    var img=new Image(); img.src=this.path+arguments[i]; this.imgs[this.imgs.length]=img;}}
}

/*************************************************************************
  CREATE ROLLTIP
*************************************************************************/

var RollTip = {
  offX: 12,
  offY: 12,
  ID: "rolltipDiv",
  aniLen: 300,  // duration of clipping animation
  ready: false,
  t1: null,
  t2: null,
  tip: null,
  
  init: function() {
    if ( document.createElement && document.body && 
        typeof document.body.appendChild != "undefined" && !window.opera ) {
      var el = document.createElement("DIV");
      el.className = "rolltip"; el.id = this.ID;
      document.body.appendChild(el);
      this.mult = el.offsetWidth/this.aniLen/this.aniLen;	
      el.style.clip = "rect(0, 0, 0, 0)";
      el.style.visibility = "visible";
      this.ready = true;
    }
  },

  reveal: function(msg, e) {
    if (this.t1) clearTimeout(this.t1);	if (this.t2) clearTimeout(this.t2); 
    this.tip = document.getElementById( this.ID );
    this.writeTip(msg);
    viewport.getAll();
    this.w = this.tip.offsetWidth; this.h = this.tip.offsetHeight;
    this.startTime = (new Date()).getTime();
    this.positionTip(e);
    this.t1 = setInterval("RollTip.rollOut()", 10);
  },
  
  rollOut: function() {
    var elapsed = (new Date()).getTime() - this.startTime;
  	if (elapsed < this.aniLen) {
  		var cv = this.w - Math.round( Math.pow(this.aniLen - elapsed, 2) * this.mult );
  		this.clipTo(0, cv, this.h, 0);
  	} else {
      this.clipTo(0, this.w, this.h,0);
      clearInterval(this.t1);
    }
  },
  
  conceal: function() {
  	if (this.t1) clearInterval(this.t1);	if (this.t2) clearInterval(this.t2);
  	this.startTime = (new Date()).getTime();
  	this.t2 = setInterval("RollTip.rollUp()", 10);
  },
  
  rollUp: function() {
  	var elapsed = (new Date()).getTime() - this.startTime;
  	if ( elapsed < this.aniLen ) {
  		var cv = Math.round( Math.pow(this.aniLen - elapsed, 2) * this.mult );
  		this.clipTo(0, cv, this.h, 0);
  	} else {
      this.clipTo(0, 0, this.h, 0);
      clearInterval(this.t2);
      this.tip = null;
    }  
  },
  
  writeTip: function(msg) {
    if ( this.tip && typeof this.tip.innerHTML != "undefined" ) this.tip.innerHTML = msg;
  },
  
  clipTo: function(top, rt, btm, lft) {
    this.tip.style.clip = "rect("+top+"px, "+rt+"px, "+btm+"px, "+lft+"px)";
  },
  
  positionTip: function(e) {
    var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
    var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
    if ( x + this.tip.offsetWidth + this.offX > viewport.width + viewport.scrollX )
      x = x - this.tip.offsetWidth - this.offX;
    else x = x + this.offX;
  
    if ( y + this.tip.offsetHeight + this.offY > viewport.height + viewport.scrollY )
      y = ( y - this.tip.offsetHeight - this.offY > viewport.scrollY )? y - this.tip.offsetHeight - this.offY : viewport.height + viewport.scrollY - this.tip.offsetHeight;
    else y = y + this.offY;

    this.tip.style.left = x + "px"; this.tip.style.top = y + "px";
  }

}

var imageHandler = { 
  imgs:[], path:"", preload:function() { for(var i=0;arguments[i];i++) {
    var img=new Image(); img.src=this.path+arguments[i]; this.imgs[this.imgs.length]=img;}}
}
//-----------
function showRollTip(msg, e) {
  if ( typeof RollTip == "undefined" || !RollTip.ready ) return;
  RollTip.reveal(msg, e);
}

function hideRollTip() {
  if ( typeof RollTip == "undefined" || !RollTip.ready ) return;
  RollTip.conceal();
}
Pay1 = "Công ty cổ phần đầu tư phát triển công nghệ ADC<br>Tầng 4, Số 139B đường Nguyễn Thái Học, Ba Đình, Hà Nội<br>ĐT: +84.47343726 hoặc 7343727";
Pay2 = "Chủ TK: Công ty cổ phần đầu tư phát triển công nghệ ADC<br>Số TK: 102010000045425<br>Ngân hàng Công Thương Ba Đình Hà Nội";
Pay3 = "<b>Đến máy ATM VietComBank, chuyển tiền:</b><br>Chủ TK: Nguyễn Văn Quý<br>Số TK: 0021000142578<br>Ngân hàng Ngoại thương Hà Nội (VietComBank HN)";
