//[Samir - 02/17/2005] Bug # 1109 - Preload image
image2 = new Image();
image2.src = "/bNetStore/Admin/Images/UploadWait.gif";
// -- End Bug #1109

//--------------------------------
//--- Cookie-related Functions ---
//--------------------------------
function getexpirydate(nodays) {
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toGMTString();
	return UTCstring;
}

function setcookie(name, value, duration) {
	cookiestring=name + "=" + escape(value) +"; expires=" + getexpirydate(duration);
	document.cookie=cookiestring;
}

function del_cookie(name, duration) {
	document.cookie = name + '=' + '; expires=' + getexpirydate(duration) + '; path=/';
}
//--- endof Cookie-related Functions ---

var adminWin

function AdminPath(a) {
	OpenAdminWindow();
	adminWin = window.open(a, '', settings);	
	//return false;
}

function Logout() {
	del_cookie('bNetSoftware', -1);
	return false;
}

//-- [Samir - 02/23/2005] Added/Modified. Bug # 1516. Handling Session state.
function Logout_Click() {
	Logout();
	window.top.location.reload();
	return false;
}

function OpenWindow() {
	myname = "bNetSoftware.com";
	Width="800";
	Height="600";
	Scroll = "yes";
	pos = "center";
	w = screen.width;
	h = screen.height - 80;

	if(pos == "random") {
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height - 80)?Math.floor(Math.random()*((screen.height- 80 -h)-75)):100;
	}
	if(pos == "center") {
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height - 80)?(screen.height- 80 - h)/2:100;
	}
	else if((pos != "center" && pos != "random") || pos == null) {
		LeftPosition=0;
		TopPosition=20;
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars,location=no,directories=no,status=no,menubar=no,toolbar=yes,resizable=no';
}

function OpenAdminWindow() {
	myname = "bNetSoftware.com";
	Width="800";
	Height="600";
	Scroll = "yes";
	pos = "center" ;
	w = screen.width;
	h = screen.height - 80;

	if(pos=="random") {
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height - 80)?Math.floor(Math.random()*((screen.height- 80 -h)-75)):100;
	}
	if(pos=="center") {
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height - 80)?(screen.height- 80 - h)/2:100;
	}
	else if((pos!="center" && pos!="random") || pos==null) {
		LeftPosition=0;
		TopPosition=20;
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes';
}

function OpenLink(a, target) {
	window.open(a, target);
	return false;
}

function refreshPage(refresh) {
	if(refresh != "")
		window.top.location.reload();
}

function ShowPromoAndRebate(iType, iCode, width, height) {
	var szURL;
	var minWidth, minHeight;
	
	minWidth = 400;
	minHeight = 200;
    		
	if( width < minWidth ) {width = minWidth};
	if( height < minHeight ) {height = height + minHeight};
	
	var szStyle = 'top=200,left=200,toolbars=no,scrollbars=yes,status=no,resizable=yes,' + 'width=' + width + ',height=' + height;
		
	if(iType == 1)
		szURL = "/bNetStore/Commons/ViewPromotionDetail.aspx?iCode=" + iCode;
	else
		szURL = "/bNetStore/Commons/ViewRebateDetail.aspx?iCode=" + iCode;	
	
	window.open( szURL, '_blank', szStyle);
	
	return false;
}

function ShowProcessing(oTable) {
	// Insert two rows.
	var oRow1=oTable.insertRow(oTable.rows.length);
	var oRow2=oTable.insertRow(oTable.rows.length);
	// Retrieve the rows collection for the table.
	var aRows=oTable.rows;
	// Retrieve the cells collection for the first row.
	var aCells=oRow1.cells;
	// Insert two cells into the first row.
	var oCell1_1=aRows(oRow1.rowIndex).insertCell(aCells.length);
	// Retrieve the cells collection for the second row.
	aCells=oRow2.cells;
	// Insert two cells into the second row.
	var oCell2_1=aRows(oRow2.rowIndex).insertCell(aCells.length);
	// Add regular HTML values to the 4 new cells. 
	oCell1_1.innerHTML="<img src='/bNetStore/Admin/Images/UploadWait.gif'>";
	oCell2_1.innerHTML="<B><font class='lable'>Please wait...Processing.</font></B>";
}

// This is the common javascript function called by the Help link in the Store in all the Features
function OpenHelpWin(navURL) {
	settings = "width=800,height=500,resizable=yes,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no";
	window.open(navURL, "Help", settings);
}
