/*-----------------------------------------------------------------
AquaBoss Version 1.0 - Online Boat Inventory Manager
AquaBoss is (c) Copyright 2004 Curve2 Design.  All Rights Reserved.

THE WRITTEN AND GRAPHICAL CONTENT OF AQUABOSS IS FULLY PROTECTED 
BY THE UNITED STATES COPYRIGHT LAWS AND INTERNATIONAL TREATY
PROVISIONS AND IS CONSIDERED A TRADE SECRET BELONGING TO THE 
COPYRIGHT HOLDER.

ANY UNAUTHORIZED REPRODUCTION OR DISTRIBUTION OF AQUABOSS IN PART
OR IN ITS ENTIRETY IS STRICTLY PROHIBITED.

For more information visit: www.curve2.com/license-aquaboss.php
-----------------------------------------------------------------*/
// JavaScript Document

// verify required fields
function checkrequired(form) {
	var pass = true;
	for(i = 0; i < form.length; i++) {
		var tempobj = form.elements[i];
		if(tempobj.alt == "required") {
			if(tempobj.value == '') {
				pass = false;
				break;
			}
		}
	}
	if(!pass) {
		alert("Please enter the required information.");
		tempobj.focus(); // set focus to missing field
		return false;
	}
	else { return true; } 
}

// image swap for view page
function swap(target, fname) {
	document[target].src = "boats/images/" + fname;
}

// make sure at least one search criteria has been provided
function checksearch(form) {
	var count = 0;
	
	for(i = 0; i < form.length; i++) {
		var tempobj = form.elements[i];
		if(tempobj.value == '') {
			count++;
		}
	}
	i-=2;
	if(count == i) {
		alert("You have not entered any search criteria.");
		return false;
	}
	else {
		//alert("You DID enter search criteria." + count + "  " + i);
		return true;
	} 
}

// confirm removal of listing
function verify_removal(ccode) {
	msg = "Are you sure you want to remove this listing?";
	if(confirm(msg)) {
		window.location='cp_remove.php?ccode=' + ccode;
	} else {
		return false;
	}
}

// confirm removal of image from listing
function verify_image(imageid, ccode) {
	msg = "Are you sure you want to remove this image?";
	if(confirm(msg)) {
		window.location='cp_removeimg.php?id=' + imageid + '&ccode=' + ccode;
	} else {
		return false;
	}
}

// display invalid stock number message
function invalid_stock(stock) {
	msg = "The stock number " + stock + " appears to be invalid.";
	if(confirm(msg)) {
		window.location='cp_index.php';
	} else {
		window.location='cp_index.php';
	}
}

