function isAlphaNumeric(str) {
	if (str.match(/^[a-zA-Z0-9]+$/))
		return true;
	else
		return false;
}

function isEmail(email) {
	if (email.match(/\w+\@\w+\.\w+/))
		return true;
	else
		return false;
}

function isNumber(num) {
	if (num.match(/^\d+$/))
		return true;
	else
		return false;
}

function isValue(value) {
	if (value.match(/[a-zA-Z0-9]/))
		return true;
	else
		return false;
}

function view_image(url,title) {
	open('/image.html?title='+title+'&url='+url,'_blank','width=1,height=1,toolbars=no');
}

// jukebox

function jukeError(error) {
	alert('The file you are trying to view cannot be played for the following reason(s):\n'+error);
}

function jukeBox(code,track,type) {
	url='/jukebox/'+code+'/'+track+'/'+type+'/';
	jLeft=(screen.width-320)/2;
	jTop=(screen.height-310)/2;
	jukebox=window.open(url,'_blank','width=320,height=310,resize=no,toolbar=no,top='+jTop+',left='+jLeft);
	jukebox.focus();
}

function jukeBoxDeBug(code,track,type) {
	url='/jukebox/'+code+'/'+track+'/'+type+'/debug/';
	jLeft=(screen.width-320)/2;
	jTop=(screen.height-310)/2;
	jukebox=window.open(url,'_blank','width=320,height=310,resize=no,toolbar=no,top='+jTop+',left='+jLeft);
	jukebox.focus();
}

function reDux(width,height) {
	wLeft=(screen.width-width)/2;
	wTop=(screen.height-height)/2;
	window.resizeTo(width,height);
	window.moveTo(wLeft,wTop);
}

// cart

function addToCart(code) {
	viewCart("/shop/cart.html?action=add&item="+code+"&ref="+window.location);
}

function viewCart(url) { 
	if (!url)
		url="/shop/cart.html?ref="+window.location;
	window.location=url;
//+( url.match(/\?/) ? "&" : "?" )+"ref="+escape(document.location)	
}

// validation

function valAddClip(Form) {
	if (!Form.file.disabled && !Form.file.value.match(/\.(flv|mp3)$/i)) {
		alert("Only FLVs and MP3s are accepted for clips.");
		Form.file.focus();
	} else if (Form.song_id[Form.song_id.selectedIndex].value==-1) {
		alert("Please select a song.");
		Form.file.focus();
	} else
		Form.submit();
}

function valCheckOut(Form) {
	if (!isValue(Form.name.value)) {
		alert("Please enter your name.");
		Form.name.focus();
		return false;
	} else if (!isEmail(Form.email1.value)) {
		alert("Please enter a valid email address.");
		Form.email1.focus();
		return false;
	} else if (Form.email1.value!=Form.email2.value) {
		alert("Your email addresses do not match.");
		Form.email1.focus();
		return false;
	} else if (!isValue(Form.phone.value) && !isValue(Form.cell_phone.value) && !isValue(Form.work_phone.value)) {
		alert("Please enter a phone number.");
		Form.phone.focus();
		return false;
	} else if (!isValue(Form.address.value)) {
		alert("Please enter an address.");
		Form.address.focus();
		return false;
	} else
		return true;
}