function openWin(url,width,height) {
	window.open(url,'DVXcamWindow','height='+height+',width='+width+',status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no');
}

// MENU IMAGE SWAP
var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
var opr=navigator.userAgent.indexOf("Opera");

function replaceImg(id,toShow,toHide) {
	var hiddenStyle = (ns6||ie4)? "hidden" : "hide"
	var visibleStyle = (ns6||ie4)? "visible" : "show"
	var blockToHide = ns6 ? document.getElementById('block' + id + toHide): eval('block' + id + toHide);
	var blockToShow = ns6 ? document.getElementById('block' + id + toShow): eval('block' + id + toShow);
	var blockToHideStyle = (ns6||ie4) ? blockToHide.style : blockToHide;
	var blockToShowStyle = (ns6||ie4) ? blockToShow.style : blockToShow;
	blockToHideStyle.visibility = hiddenStyle;
	blockToHideStyle.display = 'none';
	blockToShowStyle.visibility = visibleStyle;
	blockToShowStyle.display = 'block';
}

// submit 'formname' form to 'url' page
function submitForm(formname,url) {
	this.document[formname].action = url;
	this.document[formname].submit();
};

// checkes if string includes invalid charecters
// returs true when there are no invalid charecters 
function isValidChars(testie) {
	var invalid = /[<>'|]/
	return !invalid.test(testie);
};

// checkes if string is syntex valid email
// returns true when the email is syntex valid
function isValidEmail(testie) {
	var invalid = new RegExp("^[-0-9a-z_][-0-9a-z_.]*[^.]@[0-9a-z_][-0-9a-z.]*[0-9a-z_]\.[0-9a-z_]{2,3}$", "i");
	return (invalid.test(testie));
};

// checks if the a string is a number
// returns true when the string is a valid number
// canBeEmpty - optional when set to 'true' will allow empty string
// else will not alow empty string
function isNumber(testie,canBeEmpty) {
	if (canBeEmpty) {
		var valid = /^[0-9-. ]*$/
	} else {
		var valid = /^[0-9-. ]+$/
	};
	return valid.test(testie);
};

	
// Validate the the 'formName' form 'fieldName' 
// when not valid will alert 'msg'
// type - optional when empty will check if empty
// type = 'number' checks if a number
// type = 'nullnumber' checks if a empty or number
// type = 'email' checks if a valid email
function isValidField(formName,fieldName, msg, type) {
	var valid = true
	var form = eval(document[formName])
	var field = eval(form[fieldName])
	var value = field.value

	switch (type) {
		case 'number' :
			if (!isNumber(value)) {
				valid = false;
			}
			break;
		case 'nullnumber' :
			if (!isNumber(value,true)) {
				valid = false;
			}
			break;
		case 'email' :
			if (!isValidEmail(value)) {
				valid = false;
			}
			break;
		case 'chk' :
			if (!field.checked) {
				valid = false;
			}
			break;
		default :
			if (value.length == 0) {
				valid = false;
			}
	} 
	if (!valid) {
		alert(msg);
		field.focus();
		return false
	}  else {
		return true
	}
}

// clear form
function clearForm(formName) {
	var form = eval(document[formName]) 
	form.reset()

}
