function PopupPic(sPicURL) { 
  window.open( "popuppic.html?"+sPicURL, "",  
  "resizable=1,HEIGHT=300,WIDTH=200,TOP=0,Left=0"); 
} 

function xhtmlpopup() { 
  window.open("xhtml.php", "", 
  "resizable=1,scrollbars=1,HEIGHT=300,WIDTH=600,TOP=30,Left=30"); 
} 

function w3cpage(thepage) { 
  window.open(thepage, "", 
  "resizable=1,scrollbars=1,TOP=30,Left=30"); 
} 

function isBlank(item){
	if (item != '')
		return false;
	
	return true;
}

function validate(strFormName) {
 	errfound = false;
	errtext= '';

 	if (document.forms[strFormName].manufacturer.value == "") {
 		errtext+="Please enter the manufacturer of the product.\n"; 

		setfocusto = "manufacturer"
		errfound = true;
	}

 	if (document.forms[strFormName].name.value == "") {
 		errtext+="Please enter the name of the product.\n"; 

		setfocusto = "name"
		errfound = true;
	}

 	var pass=false;
	var el=document.forms[strFormName].elements['thecategory[]'];
	
	for (var i=0; i<el.length; i++){
	  if (el[i].checked){
	    pass=true;
	    break;
	  }
	}

	if (!pass) {
 		errtext+="Please select at least one category for this product.\n"; 

		setfocusto = "name"
		errfound = true;
	}

	if (errfound) {
		alert(errtext); 
		eval("document.forms[strFormName]."+setfocusto+".focus()");
		
		return !errfound;
	}
	
 	return !errfound; /* true if there are no errors */
}

function selectFocus() {
		
	if (document.forms['logon']) {
		if (document.forms['logon'].username) {
			document.forms['logon'].username.focus();
			
			return true;
		}
	}
	if (document.forms['NewStockItem']) {
		if (document.forms['NewStockItem'].product_code) {
			document.forms['NewStockItem'].product_code.focus();
			
			return true;
		}
	}

}

function confirmDeleteProduct(Product_ID, Product_Code, Name, variant) {
	formname = "prod" + Product_ID;

	if  (document.forms[formname]) {
		variant_id = document.forms[formname].variant_id.value;
	
		num_opts = document.forms[formname].variant_id.options.length;
		for (x=0; x<num_opts; x++) {
			if  (document.forms[formname].variant_id.options[x].value == variant_id) {
				variant = document.forms[formname].variant_id.options[x].text;
			}
		}
	}

	question = "Are you sure want to remove the following product from \nthe database?\n\n"
	question = question + "Product Code: " + Product_Code + "\nName: " + Name + "\nVariant: " + variant;
	if (confirm(question)) {
		return true;
	}	else {
		return false;
	}
}

function admin(Action, Product_ID) {
	formname = "prod" + Product_ID;
	variant_id = '';
	if  (document.forms[formname]) {
		variant_id = document.forms[formname].variant_id.value;
	}

	location.href='admin.php?action=' + Action + '&variant_id=' + variant_id;
	//document.write ('admin.php?action=' + Action + '&variant_id=' + variant_id + '&PHPSESSID=' + Session_ID);
}

<!-- Very neat date function thing from http://www-k12.atmos.washington.edu/~ovens/javascript/jsindex.html
var min_year = 2004;
var max_year = 2012;

var weekday_showing = false;
var dayofweek_returned_as_number = true;
var month_returned_as_number = true;

if (min_year <= 400)
 alert("Minimum year must be higher than 400 for this algorithm to work.");

function changeDays(numb,date_form) {
if (date_form.month) {
 mth = date_form.month.selectedIndex;
 sel = date_form.year.selectedIndex;
 yr = date_form.year.options[sel].text;
 if (numb != 1) {
  numDays = numDaysIn(mth,yr);
  date_form.day.options.length = numDays;
  for (i=27;i<numDays;i++) {
   date_form.day.options[i].text = i+1;
  }
 }
 day = date_form.day.selectedIndex+1;
 if (weekday_showing)
  date_form.dayofweek.selectedIndex = getWeekDay(mth,day,yr);
}

if (date_form.frommonth) {
 mth = date_form.frommonth.selectedIndex;
 sel = date_form.fromyear.selectedIndex;
 yr = date_form.fromyear.options[sel].text;
 if (numb != 1) {
  numDays = numDaysIn(mth,yr);
  date_form.fromday.options.length = numDays;
  for (i=27;i<numDays;i++) {
   date_form.fromday.options[i].text = i+1;
  }
 }
 day = date_form.fromday.selectedIndex+1;
 if (weekday_showing)
  date_form.fromdayofweek.selectedIndex = getWeekDay(mth,day,yr);
}

if (date_form.tomonth) {
 mth = date_form.tomonth.selectedIndex;
 sel = date_form.toyear.selectedIndex;
 yr = date_form.toyear.options[sel].text;
 if (numb != 1) {
  numDays = numDaysIn(mth,yr);
  date_form.today.options.length = numDays;
  for (i=27;i<numDays;i++) {
   date_form.today.options[i].text = i+1;
  }
 }
 day = date_form.today.selectedIndex+1;
 if (weekday_showing)
  date_form.todayofweek.selectedIndex = getWeekDay(mth,day,yr);
}
}
function numDaysIn(mth,yr) {
 if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
 else if ((mth==1) && leapYear(yr)) return 29;
 else if (mth==1) return 28;
 else return 31;
}
function leapYear(yr) {
 if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
  return true;
 else
  return false;
}
function arr() {
 this.length=arr.arguments.length;
 for (n=0;n<arr.arguments.length;n++) {
  this[n] = arr.arguments[n];
 }
}

weekdays = new arr("Sun.","Mon.","Tues.","Wed.",
 "Thurs.","Fri.","Sat.");

months = new arr("Jan","Feb","Mar","Apr","May",
 "Jun","Jul","Aug","Sep","Oct","Nov","Dec");

var cur = new Date();

function getWeekDay(mth,day,yr) {
 first_day = firstDayOfYear(yr);
 for (num=0;num<mth;num++) {
  first_day += numDaysIn(num,yr);
 }
 first_day += day-1;
 return first_day%7;
}
function firstDayOfYear(yr) {
 diff = yr - 401;
 return parseInt((1 + diff + (diff / 4) - (diff / 100) + (diff / 400)) % 7);
}
function getFullYear(d) { // d is a date object
 yr = d.getYear();
 if (yr < 1000)
  yr+=1900;
 return yr;
}
//-->

