
var ratewindow;
var userwindow;

if(parent.ratewindow != null) {
	parent.ratewindow.close();
	parent.ratewindow = null;
}
if(parent.userwindow != null) {
	parent.userwindow.close();
	parent.userwindow = null;
}
function closeChildWindows()
{
	if(parent.ratewindow != null) {
		parent.ratewindow.close();
		parent.ratewindow = null;
	}
}

function progress(frm, msg)
{
	frm.style.visibility='hidden';
//	var width = document.body.offsetWidth - 20;
//	var height = document.body.offsetHeight - 20;
//	// var win=dhtmlwindow.open("googlebox", "iframe", "/include/progress.php", "Google Web site", "width=300px,height=200px,resize=1,scrolling=1,center=1", "recal");
//	var win=dhtmlwindow.open("prgbox", "iframe", "/include/progress.php?msg="+msg, "", "width="+width+"px,height="+height+"px,resize=0,scrolling=0,center=1,border=0");


	document.getElementById("submitdiv").style.display = "none";	
	if (navigator.appName == "Microsoft Internet Explorer") {
		document.getElementById("progressdiv").innerHTML = "";
		document.getElementById("progressdiv").style.display = "block";
		document.getElementById("progressdiv").innerHTML = "<img src='/include/progress.gif' width=300 height=15 alt='Please wait ...'><br>Please wait ...";
	} else {
		document.getElementById("progressdiv").style.display = "block";		
	}

	return 1;
}


function changeColor(id, checkbox)
{
	if(checkbox.checked)
		document.getElementById(id).style.backgroundColor = "#D6D7E7";
	else
		document.getElementById(id).style.backgroundColor = "#FFFFFF";
}

function resetdate()
{
	var dt = new Date();
	var s = dt.getFullYear() + "-" + (dt.getMonth() < 9 ? '0' : '') + (dt.getMonth() + 1) + "-"
		+ (dt.getDate() < 10 ? '0' : '') + dt.getDate();

	document.getElementById('datefrom').value = s + ' 00:00';
	document.getElementById('dateto').value = s + ' 23:59';
}
function popprefix(dest_id, lookup, cust_id, did, rategroup)
{
	//parent.ratewindow = window.open('/customer/destpick.php?cust_id='+cust_id+'&buy=1', '', 'width=520,status=yes,resizable=no,scrollbars=yes,top=200,left=200');
	if(parent.ratewindow != null) parent.ratewindow.close();
	parent.ratewindow = window.open('/customer/prefixes.php?dest_id='+escape(dest_id)+'&lookup='+lookup+'&cust_id='+cust_id+'&did='+did+'&rategroup='+rategroup, '', 'width=520,height=400,status=yes,scrollbars=yes,top=200,left=200');
	parent.ratewindow.opener = window;
	parent.ratewindow.focus();
}


function popstat(destgroup, dfrom, dto, trunk, trunkout, timezone, outbound)
{
	if(parent.ratewindow != null) parent.ratewindow.close();
	parent.ratewindow = window.open('showcdr.php?destgroup='+destgroup+'&dfrom='+dfrom+'&dto='+dto+'&trunkgroup='+trunk+'&trunkgroup_out='+trunkout+'&timezone='+timezone+'&outbound='+outbound, '', 'height=400,width=1280,status=yes,resizable=yes,scrollbars=yes,top=200,left=200');
	parent.ratewindow.opener = window;
	parent.ratewindow.focus();
}
function popinfo(info, number, product)
{
	if(parent.ratewindow != null) parent.ratewindow.close();
	if(info == 0)
		parent.ratewindow = window.open('/stats/lookup.php', '', 'height=500,width=740,status=yes,resizable=yes,scrollbars=yes,top=200,left=200');
	else if(info == 2)
		parent.ratewindow = window.open('/prepaid/lookup.php?dialin='+number+'&product_id='+product, '', 'height=500,width=740,status=yes,resizable=yes,scrollbars=yes,top=200,left=200');
	else
		parent.ratewindow = window.open('/stats/performance.php', '', 'height=600,width=860,status=yes,resizable=yes,scrollbars=yes,top=200,left=200');
	parent.ratewindow.opener = window;
	parent.ratewindow.focus();
}

function popcredit(cust_id, mode)
{
	if(parent.ratewindow != null) parent.ratewindow.close();
	parent.ratewindow = window.open('credit.php?cust_id='+cust_id, '', 'height=600,width=740,status=yes,resizable=yes,scrollbars=yes,top=200,left=200');
	parent.ratewindow.opener = window;
	parent.ratewindow.focus();
}
//function popdest(cust_id, gk)
//{
//	parent.ratewindow = window.open('destpick.php?cust_id='+cust_id+'&gk='+gk, '', 'width=560,status=yes,resizable=yes,scrollbars=yes,top=200,left=200');
//	parent.ratewindow.opener = window;
//	parent.ratewindow.focus();
//}
function poppattern(cust_id, gk)
{
	parent.ratewindow = window.open('pattern.php?cust_id='+cust_id+'&gk='+gk, '', 'width=740,status=yes,height=400,resizable=no,scrollbars=yes,top=200,left=200');
	parent.ratewindow.opener = window;
	parent.ratewindow.focus();
}
function poproute(id, cust_id)
{
	parent.ratewindow = window.open('routepick.php?routing_id='+id+'&cust_id='+cust_id, '', 'width=740,height=400,status=yes,resizable=yes,scrollbars=yes,top=200,left=200');
	parent.ratewindow.opener = window;
	parent.ratewindow.focus();
}
function popmissing(routing)
{
	if(parent.ratewindow != null) parent.ratewindow.close();
	parent.ratewindow = window.open('missing.php?routing_group='+routing, '', 'width=520,height=400,status=yes,scrollbars=yes,top=200,left=200');
	parent.ratewindow.opener = window;
	parent.ratewindow.focus();
}

function popbrowser(product)
{
	if(parent.ratewindow != null) parent.ratewindow.close();
	parent.ratewindow = window.open('pinbrowser.php?product_id='+product, '', 'width=800,status=yes,height=350,resizable=yes,scrollbars=yes,top=200,left=200');
	parent.ratewindow.opener = window;
	parent.ratewindow.focus();
}

