function initialize() {
	if (window.parent.scrollspeed!=0) {
		speed=window.parent.scrollspeed;
		scroll();
	}
}

function scroll() {
	temp=(document.all)? document.body.scrollTop : window.pageYOffset;
	alt=(alt==0)? 1 : 0;
	if (alt==0) {
		curpos1=temp;
	} else {
		curpos2=temp;
		window.scrollBy(0,speed);
	}
}

function displayNewsEntry(newsItemNum) {
	document.getElementById('News_Entry_'+(newsItemNum-1)).style.display = 'none';
	document.getElementById('News_Entry_'+(newsItemNum+1)).style.display = 'none';
	document.getElementById('News_Entry_'+(newsItemNum)).style.display = 'block';
}

function changeNewsEntry(direction) {
	newsFrameRef = window.News_Frame.window;
	prevButtonRef = document.getElementById('News_Prev');
	nextButtonRef = document.getElementById('News_Next');

	if (direction=='prev'&&currentNewsEntry>0) {
		newsFrameRef.document.getElementById('News_Entry_'+(currentNewsEntry)).style.display = 'none';
		newsFrameRef.document.getElementById('News_Entry_'+(currentNewsEntry-1)).style.display = 'block';
		currentNewsEntry--;
		newsFrameRef.scrollTo(0,0);
	} else if (direction=='next'&&currentNewsEntry<numOfNewsEntries-1) {
		newsFrameRef.document.getElementById('News_Entry_'+(currentNewsEntry)).style.display = 'none';
		newsFrameRef.document.getElementById('News_Entry_'+(currentNewsEntry+1)).style.display = 'block';
		currentNewsEntry++;
		newsFrameRef.scrollTo(0,0);
	}
	
	if (currentNewsEntry==0) { prevButtonRef.src = 'images/Main_Blank.gif'; }
	if (currentNewsEntry==1) { prevButtonRef.src = 'images/News_Prev.gif'; }
	if (currentNewsEntry==numOfNewsEntries-1) { nextButtonRef.src = 'images/Main_Blank.gif'; }
	if (currentNewsEntry==numOfNewsEntries-2) { nextButtonRef.src = 'images/News_Next.gif'; }
}

function changePostcard(postcardID) {
	document.getElementById('Postcard_Image').src = 'images/postcards/'+postcardID+'_front.jpg';
}

function flipPostcard(imageRef) {
	if (imageRef.src.indexOf('front')>=0) {
		imageRef.src = imageRef.src.replace('front','back');
	} else {
		imageRef.src = imageRef.src.replace('back','front');
	}
}

function changePhoto(direction) {
	polaroidRef = document.getElementById('Polaroid_Photo');
	prevButtonRef = document.getElementById('Photos_Prev');
	nextButtonRef = document.getElementById('Photos_Next');

	if (direction=='prev'&&currentPhoto>0) {
		polaroidRef.src = 'images/photos/'+photos[currentPhoto-1]+'.jpg';
		currentPhoto--;
	} else if (direction=='next'&&currentPhoto<numOfPhotos-1) {
		polaroidRef.src = 'images/photos/'+photos[currentPhoto+1]+'.jpg';
		currentPhoto++;
	}
	
	if (currentPhoto==0) { prevButtonRef.src = 'images/Main_Blank.gif'; }
	if (currentPhoto==1) { prevButtonRef.src = 'images/Photos_Prev.gif'; }
	if (currentPhoto==numOfPhotos-1) { nextButtonRef.src = 'images/Main_Blank.gif'; }
	if (currentPhoto==numOfPhotos-2) { nextButtonRef.src = 'images/Photos_Next.gif'; }
}

function changeAlbumInfo(album) {
	document.getElementById('Album_Cover').src = 'images/Music_'+album+'.jpg';

	document.getElementById('Album_Stars').style.display = 'none';
	document.getElementById('Album_Light').style.display = 'none';
	document.getElementById('Album_Self_Titled').style.display = 'none';
	document.getElementById('Album_Work').style.display = 'none';
	
	document.getElementById(album).style.display = 'block';
}

function writeEmailLink(name,host,imageName,alt) {
	document.write("<a href="+"mail"+"to:"+name+"@"+host+"><img src=\"images/Contact_"+imageName+".gif\" alt=\""+alt+"\">"+"</a>")
}

function popUpMailinglist() {
	var wint = (screen.height - 435) / 2;
	var winl = (screen.width - 300) / 2;
	window.open("mailinglist.php", "jocmailinglist", "width=300,height=435,top="+wint+",left="+winl+",scrollbars=no,menubar=no,toolbar=no,status=no");
}

function popUpPress(pressImage) {
	var wint = (screen.height - 500) / 2;
	var winl = (screen.width - 780) / 2;
	window.open("press_popup.php?pressImage="+pressImage, "jocpress", "width=780,height=500,top="+wint+",left="+winl+",scrollbars=yes,menubar=no,toolbar=no,status=no");
}

function validateEmail(form) {
	var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (regex.test(form.inpEmail.value)) {
		return true;
	} else {
		alert("You must enter a valid email address");
		form.inpEmail.focus();
		return false;
	}
}