var orderArr = new Array;
var orderCount = 0;

function displayPics(){
		var cbx = document.getElementById('cbxEventList');
		var pwd = trim(document.getElementById('pwd').value);
		if (cbx.options[cbx.selectedIndex].value == pwd){
			location = 'CustOrder.php?eventId=' + cbx.options[cbx.selectedIndex].text;
		}else{
			alert('Password is incorrect - please try again');
		}
	return false;
}

function enlargeimage(path){
	var win;
	var winattributes="width="+300+",height="+200+",resizable=yes, scrollbars=yes"
	win = window.open("FsPicDisplay.html?path=" + path,"", winattributes);
}

function loadCart(picIds){
	orderArr = picIds.split(';');
	orderCount = orderArr.length; 
}

function addToCart(photoId){
	var found = false;
	for (i=0;i<orderArr.length;i++){
		found = orderArr[i]==photoId;
		if (found) break;
	}
	
	if(found){
		alert(photoId.split('.')[0] + ' is already in the cart');
	}else{
		orderArr[orderCount] = photoId;
		orderCount++;
		alert(photoId.split('.')[0] + ' added to cart');
	}
}

function clearCart(){
	orderArr = new Array;
	orderCount = 0;
	alert('Cart Cleared');
}

function viewCart(folderId){
	if (orderArr.length == 0){
		alert("Cart is empty");
	}else{
		var win;
		var winattributes="width="+800+",height="+500+",resizable=1, scrollbars=1, location=0, toolbar=0"
		win = window.open("CustCart.php?modeId=view&folderId=" + folderId + "&picIds=" + orderArr.join(";"),"", winattributes);
	}
}

function checkoutCart(folderId){
	if (orderArr.length == 0){
		alert("Cart is empty");
	}else{
		location = "CustCart.php?modeId=checkout&folderId=" + folderId + "&picIds=" + orderArr.join(";");
	}
}

