function previous(){
	if(s > 0){
		s = s - 4;
		renderPreview();
	}
}
function next(){
	if(pressItems.length > s + 4){
		s = s + 4;
		renderPreview();
	}
}
function renderPreview(){
	var preview = document.getElementById("preview");
	if(preview.hasChildNodes()){
		while(preview.childNodes.length >= 1){
			preview.removeChild(preview.firstChild);       
		} 
	}
	if(s == 0){ document.getElementById("previousButton").src = "http://tarastiles.com/images/previousDisabled.jpg"; }
	else{ document.getElementById("previousButton").src = "http://tarastiles.com/images/previous.jpg"; }
	if(pressItems.length - s <= 4){ document.getElementById("nextButton").src = "http://tarastiles.com/images/nextDisabled.jpg"; }
	else{ document.getElementById("nextButton").src = "http://tarastiles.com/images/next.jpg"; }
	limit = (pressItems.length - s < 4) ?
		pressItems.length - s :
		s + 4;
	for(p = s; p < limit; p++){
		previewImage = preview.appendChild(document.createElement("img"));
		previewImage.id = p;
		previewImage.src = "http://tarastiles.com/images/"+pressItems[p].img;
		previewImage.className = "previewImage";
		previewImage.width = 180;
		previewImage.height = 240;
		previewImage.onclick = function(){
			createModalContainer(this);
		}
	}
}
function clearField(field){
	if(field.className == 'field'){
		field.className = 'fieldActive';	
		field.value = '';
	}
}
window.onload = function(){
	var httpRequest;
	if(window.XMLHttpRequest){
		httpRequest = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	httpRequest.onreadystatechange = function(){
		if(httpRequest.readyState == 4){
			eval(httpRequest.responseText);
			var flashticker = document.getElementById("flashticker");
			img = flashticker.appendChild(document.createElement("img"));
			img.id = "quoteImage";
			img.width = 25;
			img.height = 27;
			img.src = "http://tarastiles.com/images/"+quote.img;
			quoteContainer = flashticker.appendChild(document.createElement("div"));
			quoteContainer.id = "quote";
			//quoteText = quoteContainer.appendChild(document.createTextNode(quote.quote));
			quoteContainer.innerHTML = quote.quote;
		}
	}
	var time = new Date();
	httpRequest.open('GET', 'http://tarastiles.com/quote.php?h='+time.getHours(), true);
	httpRequest.send();
}
