/* ------------------------------------------------------------
 * PROJECT        : 
 * FILENAME       : common.js
 * ------------------------------------------------------------
 * LAST UPDATED   : 17 Dec 2009
 * ------------------------------------------------------------
 * AUTHOR(S)      : Kevin Scholl (kevin@ksscholl.com)
 * ------------------------------------------------------------
 * NOTE(S)        : 
 * ------------------------------------------------------------ */

var IS_IE6_BELOW = false;

/* ------------------------------------------------------------
 * GET DAY OF WEEK, MONTH, DAY, YEAR
 * ------------------------------------------------------------ */

var d         = new Date();
var weekday   = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monthname = new Array("January","February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var daynum    = new Array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");

/* ------------------------------------------------------------
 * GET TIME
 * ------------------------------------------------------------ */

var time      = new Date();
var hours     = time.getHours();
var minutes   = time.getMinutes();
var seconds   = time.getSeconds();

timeDay       = (hours   <  12 ? "AM" : "PM");
hours         = (hours   <= 12 ? hours : hours - 12);
hours         = (hours   <  10 ? "0" : "") + hours;
hours         = (hours   == 00 ? "12" : hours);
minutes       = (minutes <  10 ? "0" : "") + minutes;
seconds       = (seconds <  10 ? "0" : "") + seconds;

var clock     = hours + ":" + minutes + " " + timeDay;
	
/* ------------------------------------------------------------
 * DISPLAY DAY, DATE, AND TIME (MASTHEAD)
 * ------------------------------------------------------------ */

function displayDayDateTime() {
	document.write(weekday[d.getDay()] + " <span>|</span> ");
	document.write(monthname[d.getMonth()] + " ");
	document.write(daynum[d.getDate()-1] + ", ");
	document.write(d.getFullYear() + " <span>|</span> ");
	document.write(clock);
	}

/* ------------------------------------------------------------
 * POPUP WINDOW: GLOBAL VARIABLE(S)
 * ------------------------------------------------------------ */

var POPWIN  = null;

/* ------------------------------------------------------------
 * POPUP WINDOW: CLOSE EXISTING POPUP WINDOW
 * ------------------------------------------------------------ */

function closePopWin(theWin) {
  if ((window.theWin != null) && (window.theWin.closed != true))
  	window.theWin.close();
	}

/* ------------------------------------------------------------
 * POPUP WINDOW: DISPLAY POPUP WINDOW
 * ------------------------------------------------------------ */

function popWindow(loc,n,w,h,m,t) {

  closePopWin(n);	// closes an existing popup window if user opens 
                	// new window before closing existing window
												
	var wName          = (n ? n : "POPUP WINDOW");
	var wWidth         = (w ? w + 20 : screen.width - 100);
	var wHeight        = (h ? h + 20 : screen.height - 150);
	var hasMenubar     = (m ? m : "no");
	var hasToolbar     = (t ? t : "no");
	
	var params  = "width=" + wWidth + ",height=" + wHeight + ",status=yes,toolbar=" + hasToolbar + ",directories=no,scrollbars=yes,resizable=yes,menubar=" + hasMenubar + ",location=no,top=50,left=50,screeny=50,screenx=50";

	POPWIN = window.open(loc,wName,params);
	POPWIN.focus;
	}
	
/* ------------------------------------------------------------
 * DISPLAY LARGE PHOTO
 * ------------------------------------------------------------ */

function viewPhoto(img,n,w,h) {

  closePopWin(n); 	// closes an existing popup window if user opens 
        					  // new window before closing existing window

	var wName          = (n ? n : "Detail");
	var wWidth         = (w ? w : 640);
	var wHeight        = (h ? h : 480);

	var params  = "width=" + (wWidth) + ",height=" + (wHeight) + ",status=yes,toolbar=no,directories=no,scrollbars=yes,resizable=yes,menubar=no,location=no,top=50,left=50,screeny=50,screenx=50";

	POPWIN = window.open("",wName,params);

  POPWIN.document.writeln('<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
  POPWIN.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml">');
	POPWIN.document.writeln('<head><title>Diamond Sports Pro Shop</title></head>');
  POPWIN.document.writeln('<body style="margin: 0;  background: #FFF url(' + img + ') top center no-repeat; padding: 0;">');
  POPWIN.document.writeln('  <div style="margin: 0; border: 0; padding: 10px; text-align: right;">');
  POPWIN.document.writeln('    <a href="javascript: window.close();" style="font: bold 12px/1.0 Arial, Helvetica, Sans-Serif;">CLOSE</a>');
  POPWIN.document.writeln('  </div>');
  POPWIN.document.writeln('</body>');
  POPWIN.document.writeln('</html>');

	POPWIN.document.close();
  }
