$(document).ready(function(){
	if(document.getElementById('removePhotos')){
		$('#removePhotos').click(function(){
			 removePhotos();
		});
	}
});
// gallery photos
function changePhoto(photo){
	var photoVar = 'photos/'+photo;
	var photos = document.getElementById('photoArray').value;
	var photoArray = new Array();
	photoArray = photos.split('|');
	for(var i=0; i<photoArray.length; i++){
		var thePhoto = photoArray[i];
		document.getElementById(thePhoto).style.borderColor = "white";
	}
	var thisPhotoArray = new Array();
	var thisPhotoArray = photo.split('/');
	var thisPhoto = thisPhotoArray[1];
	document.getElementById(thisPhoto).style.borderColor = "red";
	$('#mainPhoto').fadeOut(1000,function(){$('#mainPhoto').attr('src',photoVar);}).fadeIn(1000);
}

// showroom photos
function changeShowroomPhoto(photo){
	var photos = document.getElementById('photoArray').value;
	var photoArray = new Array();
	photoArray = photos.split('|');
	for(var i=0; i<photoArray.length; i++){
		var thePhoto = photoArray[i];
		document.getElementById(thePhoto).style.borderColor = "white";
	}
	var thisPhotoArray = new Array();
	var thisPhotoArray = photo.split('/');
	var thisPhoto = thisPhotoArray[1];
	document.getElementById(thisPhoto).style.borderColor = "red";
	$('#mainWindow').animate({opacity: .0},1000);
	setTimeout('document.mainPhoto.src = "'+photo+'"',1000);
	$('#mainWindow').animate({opacity: 1.0},1000);
}

// adds a news item
function addNews(rec){
	var newsTitle = $.trim($('#newsTitle').val());
	var newsText = $.trim($('#newsText').val());
	if(newsTitle == "" || newsText == ""){
		$('#pageError').html("*You must complete all fields*");
	} else {
		var sendInfo = 'newsTitle='+escape(newsTitle)+'&newsText='+escape(newsText);
		if(rec != ""){
			sendInfo += '&newsRec='+rec;
		}
		$.post("submitNews.php",sendInfo,function(msg){$('#content').html(msg)})
	}
}

// Delete news item confirm
function deleteNews(rec){
	if(confirm('Press "OK" to delete this news item or press "Cancel" to go back.')){
		$.get("deleteNews.php","newsRec="+escape(rec),function(msg){$('#content').html(msg)});
	}
}

// Update page Text
function updatePage(rec){
	var sendInfo = "pageRec="+rec+"&pageText="+escape($('#pageText').val());
	$.post("submitPage.php",sendInfo,function(msg){$('#content').html(msg)});
}

// remove selected photos
function removePhotos(){
	var photos = $('input[name=photo]:checkbox:checked');
	alert(photos.length);
}





