
function popupCenteredWindow(sUrl, lWidth, lHeight, sName, bScroll, bStatus){
	//	sURL	(URL of the page to open)
	//	lWidth	(width of the popup)
	//	lHeight	(height of the popup)
	//	sName	(name given to the window)
	//	bScroll	(allow scroll bars [yes|no|1|0])
	//	bStatus	(allow status bar [yes|no|1|0])
	lLeft = (window.screen.width/2) - ((lWidth/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	lTop = (window.screen.height/2) - ((lHeight/2) + 30); //half the screen height minus half the new window height (plus title and status bars).
	newWin = window.open(sUrl, sName, "height=" + lHeight + ", width=" + lWidth + ", left=" + lLeft + ", top=" + lTop + ", screenX=" + lLeft + ", screenY=" + lTop + ", scrollbars=" + bScroll + ", status=" + bStatus);
	newWin.focus();
}


function Subscribe(){
	var sURL = '/signup.asp?email='
	popupCenteredWindow(sURL,650,600,'SGSignupWnd',0,0);
	}
	
	
function resizeIframe(obj)
	{
	var h = obj.offsetHeight;
	}	
	
function doEmailAddress(name1, name2, tip)
	{
	var ext;
	switch(tip)
		{
		case 1: tip="ro"; break;
		case 2: tip="co.uk"; break;
		case 3: tip="com"; break;
		case 4: tip="net"; break;
		}
	var emailaddress = name1 + "@" + name2 + "." + tip;
	document.write("<a href='mailto:" + emailaddress + "'>" + emailaddress + "</a>");
	}

function doSearch()
{
	if (document.searchForm.searchStr.value == ''){
		alert ("Please type something to search for!")
		return false;
	}
	else
		return true;

}

var tellwin;
var wincreated = false;
var pwdwin;
function tell(ProductID){

	if (wincreated) {
		tellwin.load("iframe", "tell.asp?pid=" + ProductID, "Tell someone");
		tellwin.show();
	
	}
	else {
	
		tellwin = dhtmlwindow.open("tellbox", "iframe", "tell.asp?pid=" + ProductID, "Tell someone", "width=500px,height=520px,resize=1,scrolling=1,center=1")
		wincreated = true;
		tellwin.onclose = function(){ 
			wincreated = false;
			return true;
		}
	}

}

function report(ProductID){

	if (wincreated) {
		tellwin.load("iframe", "report.asp?pid=" + ProductID, "Report this deal");
		tellwin.show();
	
	}
	else {
	
		tellwin = dhtmlwindow.open("tellbox", "iframe", "report.asp?pid=" + ProductID, "Report this deal", "width=500px,height=520px,resize=1,scrolling=1,center=1")
		wincreated = true;
		tellwin.onclose = function(){ 
			wincreated = false;
			return true;
		}
	}

}

function comment(ProductID){

	if (wincreated) {
		tellwin.load("iframe", "comment.asp?pid=" + ProductID, "Add a comment to this deal");
		tellwin.show();
	
	}
	else {
	
		tellwin = dhtmlwindow.open("tellbox", "iframe", "comment.asp?pid=" + ProductID, "Add a comment to this deal", "width=500px,height=520px,resize=1,scrolling=1,center=1")
		wincreated = true;
		tellwin.onclose = function(){ 
			wincreated = false;
			return true;
		}
	}
}

function storesWin (qs){

	if (wincreated) {
		tellwin.load("iframe", "storesfilter.asp?" + qs, "View all Stores (filtered)");
		tellwin.show();
	}
	else {
	
		tellwin = dhtmlwindow.open("tellbox", "iframe", "storesfilter.asp?" + qs, "View all Stores (filtered)", "width=500px,height=520px,resize=1,scrolling=1,center=1")
		wincreated = true;
		tellwin.onclose = function(){ 
			wincreated = false;
			return true;
		}
	}
	
	return false;
}

function catlistWin (cid){

	if (wincreated) {
		tellwin.load("iframe", "/catlistframe.asp?cid=" + cid, "Categories");
		tellwin && tellwin.contentWindow && tellwin.contentWindow.focus();
		tellwin.show();
	}
	else {
	
		tellwin = dhtmlwindow.open("tellbox", "iframe", "/catlistframe.asp?cid=" + cid, "Categories", "width=500px,height=520px,resize=1,scrolling=1,center=1")
		tellwin && tellwin.contentWindow && tellwin.contentWindow.focus();
		wincreated = true;
		tellwin.onclose = function(){ 
			wincreated = false;
			return true;
		}
	}
	
	return false;
}

function afflistWin (){

	if (wincreated) {
		tellwin.load("iframe", "/afflistframe.asp", "Stores on Deals Network");
		tellwin && tellwin.contentWindow && tellwin.contentWindow.focus();
		tellwin.show();
	}
	else {
	
		tellwin = dhtmlwindow.open("tellbox", "iframe", "/afflistframe.asp", "Stores on Deals Network", "width=500px,height=520px,resize=1,scrolling=1,center=1")
		tellwin && tellwin.contentWindow && tellwin.contentWindow.focus();
		wincreated = true;
		tellwin.onclose = function(){ 
			wincreated = false;
			return true;
		}
	}
	
	return false;
}




function categoriesWin (qs){

	if (wincreated) {
		tellwin.load("iframe", "categoriesfilter.asp?" + qs, "View all Categories (filtered)");
		tellwin.show();
	
	}
	else {
	
		tellwin = dhtmlwindow.open("tellbox", "iframe", "categoriesfilter.asp?" + qs, "View all Categories (filtered)", "width=500px,height=520px,resize=1,scrolling=1,center=1")
		wincreated = true;
		tellwin.onclose = function(){ 
			wincreated = false;
			return true;
		}
	}

	return false;

}

function closePwdWin(){
	pwdwin.close();
}

function closeDHTMLWin(){
	tellwin.close();
}

function pwd(){
	pwdwin = dhtmlwindow.open("pwdbox", "iframe", "pwd.asp", "Deals Network Password", "width=400px,height=210px,resize=1,scrolling=1,center=1")
}

var loginwin;

function register(){
	loginwin = dhtmlwindow.open("loginbox", "iframe", "register.asp", "Deals Network Registration", "width=500px,height=210px,resize=1,scrolling=1,center=1")
}

function login(){
	loginwin = dhtmlwindow.open("loginbox", "iframe", "login.asp", "Deals Network Login", "width=500px,height=210px,resize=1,scrolling=1,center=1")
}

function closeLoginWin(){
	loginwin.close();
}

function logout(s){
	var myDate = new Date();
	var tip = Date.UTC(myDate)

	if (confirm ("You are currently logged in as " + s + "\n\nThis will log you out!\nTo access your profile on our server you will need to log-in again.\n\nAre you sure?"))
		document.location.href = "logout.asp?tip=" + tip
}


function gettip(){
	var myDate = new Date();
	var tip = Date.UTC(myDate)
	return tip;
}

function hov(id, bgLogoURL){
	try {
			document.getElementById ("cl" + id).className = "csHCh";
			document.getElementById ("cli" + id).className = "csHCih";
			document.getElementById ("cli" + id).style.backgroundImage = "url('" + bgLogoURL + "')";
		}
			catch(e) 
		{}
}

function hou(id){

	try {
			document.getElementById ("cl" + id).className = "csHC";
			document.getElementById ("cli" + id).className = "csHCi";
			document.getElementById ("cli" + id).style.backgroundImage = "url('/images/1.gif')";
		}
			catch(e) 
		{}

}

   function roll_over(img_name, img_src)
   {
        document[img_name].src = img_src;
   }

   function rndhpd() {
       
       var sc = document.lateF.sch;
       var mxc = sc.options.length;
       var rn = Math.floor(Math.random() * mxc)
       sc.selectedIndex = rn;

       var sa = document.lateF.sah;
       var mxa = sa.options.length;
       rn = Math.floor(Math.random() * mxa)
       sa.selectedIndex = rn;

   }

   function gosch() {
       if (document.lateF.sch.value > 0)
            top.location.href = "/filter.asp?fid=22&ftid=4&cid=" + document.lateF.sch.value
}

function gosah() {
    if (document.lateF.sah.value > 0)
        top.location.href = "/filter.asp?fid=22&ftid=4&affid=" + document.lateF.sah.value
}

function jsgo(pid) {
    window.open("rdr.asp?pid=" + pid);
}

function jsm(affid) {
    top.location.href = "merchant.asp?affid=" + affid;
}
