﻿var zz, zv, d, fTSR;
d = new Date();
fTSR=0;
zv = d.getTime();
zz = "&zz="+zv;

var gBF=false;
function GoTo(u){window.top.location = u + zz;}
function Go(u){window.top.location = u;} 

function BF(){gBF=true;}

function Foci(o){if(!gBF && IsVis(o)){o.focus();}}

function IsVis(o)
{
	if(!o || o.type=="hidden")
	return false;
	
	while(o && o.style && o.style.display!='none')
	{
	o = o.parentNode;	
	}
	return !o || !o.style;
}

function TEK(a){if(13==event.keyCode){event.cancelBubble=true;event.returnValue=false;eval(a);}}

function getObj(objID)
	{
	if (document.getElementById) {return document.getElementById(objID);}
	else if (document.all) {return document.all[objID];}
	else if (document.layers) {return document.layers[objID];}
	}
	
function objNext(f,d)
{
	var fFnd=false,el=f.elements,i=0;
	for(;i < el.length;i++)
	{
	if('hidden'!=el[i].type && false==el[i].disabled && IsVis(el[i]) && fFnd)return el[i];
	if(d.id==el[i].id)fFnd=true;
	}
	return null;
}
function objPrev(f,d)
{
	var fFnd=false,el=f.elements,i=el.length - 1;
	for(;i >= 0;i--)
	{
	if('hidden'!=el[i].type && false==el[i].disabled && IsVis(el[i]) && fFnd)return el[i];
	if(d.id==el[i].id)fFnd=true;
	}
	return null;
}

var rgOnLoad=new Array();
function AddLoadFn(szfn){window.onload=RunLoadFn;rgOnLoad[rgOnLoad.length]=szfn;}
function RunLoadFn(){for(var i=0;i<rgOnLoad.length;i++)eval(rgOnLoad[i]);}

function RegisterClick(r)
{

	var zv = (new Date()).getTime();
	getObj("rfrrImg").src="agent.dll?qscr=live&rfrr="+r+"&zz="+zv;

}
function WriteCookie(c)
{
	document.cookie=c
}

//Create by MR TOAN
function addDate(dateString,num){
    var dateOnMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    var dateArray = new Array();
    var reStr = "";
    
    var date, month, year;
    
    dateArray = dateString.split("/");
    
    date = parseInt(dateArray[0]);
    month = parseInt(dateArray[1]);
    year = parseInt(dateArray[2]);
        
    if(year % 4 == 0){
        dateOnMonth[1]++;
    }
    
    date += num;
    while(date > dateOnMonth[month-1]){
        date -= dateOnMonth[month-1];
        if(month == 12){
            month = 1;
            year ++;
        }
        else{
            month++;
        }
    }
    
    reStr = date + "/" + month + "/" + year;
    return reStr;
}

function GetToDateStart(txtFromDate){
    var toDate = addDate(document.getElementById(txtFromDate).value,1);
    var dateArray = new Array();
    dateArray = toDate.split("/");
    
    toDate = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2];
    
    return toDate;
}
//End of Mr Toan's functions

function OpenMeSize(url, inNew, winDef,h,w)
{
	bsh = 96;
	rsw = 10;
	h = h - bsh;
	w = w - rsw;
	if (url == '')
		return;

	if (typeof(inNew)=='undefined!')
		inNew = 0;

	if (winDef=='default')
		winDef = 'Height='+h+',Width='+w+',Top='.concat((screen.height - h)/2-20).concat(',Left=').concat((screen.width - w)/2); //.concat(',scrollbars,resizable');
		
	if (winDef=='resizable')
		winDef = 'Height='+h+',Width='+w+',Top='.concat((screen.height - h)/2).concat(',Left=').concat((screen.width - w)/2).concat(',resizable');

	if (winDef=='havescroll')
	{
		winDef = 'Height='+h+',Width='+w+',Top='.concat(((screen.height - h)/2) - (bsh/2)).concat(',Left=').concat(((screen.width - w)/2) - (rsw/2)).concat(',scrollbars,resizable,status');
		//winDef = 'Height='+h+',Width='+w+',Top=0,Left=0,scrollbars,resizable,status';
		//alert(winDef);
	}

	if (inNew)
	{
		newWindow = window.open(url, inNew, winDef);
		newWindow.focus();
	}
	else
	{
		location.href = url;
	}
}