var isOpen = 0;
var pop_window;

/*
// For Production
var h_s_ad = "https://secure.talk011.com/";
var h_ad = "http://www.talk011.com/";
*/

// For Systest
var h_s_ad = "https://4.61.143.162/r/";
var h_ad = "http://4.61.143.162/r/";

//var h_pay_link = "https://4.61.153.94/mams_sub2/viewpayment.asp";
var h_pay_link = "https://secure.mindsgate.com/mams/viewpayment.asp";

function showHome()
{
	top.T_Body.location.href = "bdhome.asp";
}

function doLogoff()
{
	if(confirm("Are you sure, you want to logoff?"))
	{
		top.location.href = "logoff.asp";
	}
}

function showUsrPass(name,w,h)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	if (pop_window)
	{
		if (pop_window.closed == false)
		{
			pop_window.focus();
		}
	}
	var link = "viewusrpass.asp";
	var settings = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width='+ w +',height='+ h  +',top='+ TopPosition +',left='+ LeftPosition +',resizable=1';
	pop_window = window.open(link,name);
}

function showMyAccount(uid)
{
	var loc = "viewcustomer.asp?uid=" + uid;
	top.T_Body.location.href = loc;
}

function showMyPayments(uid)
{
	var loc = "viewcustomerfin.asp?uid=" + uid;
	top.T_Body.location.href = loc;
}

function showCustCampaigns(uid)
{
	var loc = "viewcustcamps.asp?uid=" + uid;
	top.T_Body.location.href = loc;
}

function showCustFiles(uid)
{
	var loc = "viewcustfiles.asp?uid=" + uid;
	top.T_Body.location.href = loc;
}

function GetFile(fid, uid)
{
	var w = 200;
	var h = 100;
	var name = "getfiles";

	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	if (pop_window)
	{
		if (pop_window.closed == false)
		{
			pop_window.focus();
		}
	}
	var link = "getfile.php?fid="+ fid +"&uid="+ uid;
	var settings = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width='+ w +',height='+ h  +',top='+ TopPosition +',left='+ LeftPosition +',resizable=1';
	pop_window = window.open(link,name,settings);
	
	//alert(l);
}

function delFile(fid, uid, p)
{
	if(confirm("Are you sure? You want to delete this file?"))
	{
		var link = "c_dodelfile.asp?fid="+ fid + "&uid=" + uid + "&page=" + p;
		document.location.href = link;
	}
}

function DoActionAdver(uid, act)
{
	if(act == "View")
	{
		var loc = "viewcustomer.asp?uid=" + uid;
		this.location.href = loc;
	}
	else if(act == "Edit")
	{
		var loc = "viewedtcustomer.asp?uid=" + uid;
		this.location.href = loc;
	}
	else if(act == "Disable")
	{
		var loc = "disablecustomer.asp?uid=" + uid;
		if(confirm("Are you sure you want to DISABLE this Advertiser?\n\nPlease note that if you disable a customer\nall CAMPAIGNS and ADS will also be disabled for this Advertiser."))
		{
			this.location.href = loc;
		}
	}
	else if(act == "Enable")
	{
		var loc = "enablecustomer.asp?uid=" + uid;
		if(confirm("Are you sure you want to ENABLE this Advertiser?"))
		{
			this.location.href = loc;
		}
	}
	else if(act == "Delete")
	{
		alert("DELETE: Working on it");
	}
	else if(act == "Fin")
	{
		var loc = "viewcustomerfin.asp?uid=" + uid;
		this.location.href = loc;
	}
	else
	{
		alert("Well!!! you are at the wrong place at the wrong time");
		alert("Formatting you hard drive .....");
	}
}

function DoActionCamp(cid, uid, act)
{
	if(act == "View")
	{
		var loc = "viewcamps.asp?cid=" + cid +"&uid="+ uid;
		this.location.href = loc;
	}
	else if(act == "Edit")
	{
		var loc = "viewedtcamp.asp?cid=" + cid +"&uid="+ uid;
		this.location.href = loc;
	}
	else if(act == "Disable")
	{
		var loc = "disablecamp.asp?cid=" + cid +"&uid="+ uid;
		if(confirm("Are you sure you want to DISABLE this Campaign?\n\nPlease note that if you disable a campaign\nall ADS will also be disabled for this Campaign."))
		{
			this.location.href = loc;
		}
	}
	else if(act == "Enable")
	{
		var loc = "enablecamp.asp?cid=" + cid +"&uid="+ uid;
		if(confirm("Are you sure you want to ENABLE this Campaign?"))
		{
			this.location.href = loc;
		}
	}
	else if(act == "Delete")
	{
		alert("DELETE: Working on it");
	}
	else
	{
		alert("Well!!! you are at the wrong place at the wrong time");
		alert("Formatting you hard drive ..... :) ha ha just say ok!!!");
	}
}

function ShowPayment(name,uid,w,h)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	if (pop_window)
	{
		if (pop_window.closed == false)
		{
			pop_window.focus();
		}
	}
	var link = h_pay_link + "?uid=" + uid;
	var settings = 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,width='+ w +',height='+ h  +',top='+ TopPosition +',left='+ LeftPosition +',resizable=0';
	pop_window = window.open(link,name,settings);
}

function showAdJLKInvoice()
{
	//alert("working");
	var loc = "viewjlkinvoices.asp";
	top.T_Body.location.href = loc;
}

function ShowJLKInvNew()
{
	top.T_Body.TSUB_Top.location.href = "viewjlkinvoices_cust.asp";
	top.T_Body.TSUB_Body.location.href = "viewjlkinvoices_body.asp";
}

function ShowAllPendingInvs()
{
	top.T_Body.TSUB_Body.location.href = "viewjlkcustinvoicespending_body.asp";
}

function ShowAllInvs()
{
	top.T_Body.TSUB_Body.location.href = "viewjlkcustinvoicesall_body.asp";
}

function printInv(invid)
{
	var name = "printinvoice";
	var w = 700;
	var h = 500;
	
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	if (pop_window)
	{
		if (pop_window.closed == false)
		{
			pop_window.focus();
		}
	}
	var link = "viewjlkinvoices_print.asp?invid="+ invid;
	var settings = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width='+ w +',height='+ h  +',top='+ TopPosition +',left='+ LeftPosition +',resizable=0';
	pop_window = window.open(link, name, settings);
}

function printInv2(invid)
{
	var name = "printinvoice";
	var w = 700;
	var h = 500;
	
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	if (pop_window)
	{
		if (pop_window.closed == false)
		{
			pop_window.focus();
		}
	}
	var link = "viewjlkinvoicesprint_venus.asp?invid="+ invid;
	var settings = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width='+ w +',height='+ h  +',top='+ TopPosition +',left='+ LeftPosition +',resizable=0';
	pop_window = window.open(link, name, settings);
}

function emailInv(invid)
{
	document.location.href = "viewjlkinvoices_mail.asp?invid="+ invid;
}

function emailInv2(invid)
{
	document.location.href = "viewjlkinvoicesmail_venus.asp?invid="+ invid;
}

function IsEmailAddress(s)
{
	re = /\s+/g
	if (re.test(s))
	{
		return false;
	}
	//validate email address syntax and remove any emails that don't 
	//match the basic syntax pattern below.
	re = /^(\w|[^_]\.|[\-])+((\@){1}([^_]))(([a-z]|[\d]|[\-]|\.)+|([^_]\.[^_])*)+\.[a-z]{2,6}$/i
	if (!re.test(s))
	{
		return false;
	}

	//fix the .. problem...
	re = /\.\./
	if (re.test(s))
	{
		return false;
	}

	//fix the @@ problem...
	re = /\@\@/
	return(!re.test(s));
}
