function checkSearchForm(form){
	if (form.keywords.value==""){
		alert("请输入查询条件!");
		return false;
	}
	return true;
}
function goto(url){
	if (document.getElementsByTagName("base")){
		url = document.getElementsByTagName("base")[0].href + "/../" + url;
	}
	//window.navigate(url);
	this.location.href = url;
}
function newWindow2(url, width, height){
	var left = (screen.availWidth - width)/2;
	var top = (screen.availHeight - height)/2;
	var args = "height="+height+",width="+width+",left="+left+",top="+top;
	window.open(url,"",args);
	//window.showModalDialog(url,"","dialogHeight:300px");
	return false;
}
function newWindow1(url, width, height){
	var left = (screen.availWidth - width)/2;
	var top = (screen.availHeight - height)/2;
	var args = "height="+height+",width="+width+",left="+left+",top="+top;
	window.open(url,"",args);
	//window.showModalDialog(url,"","dialogHeight:300px");
	return false;
}
function newWindow(url, width, height){
	var left = (screen.availWidth - width)/2;
	var top = (screen.availHeight - height)/2;
	var args = "scrollbars=1,resizable=1,";
	args += "height="+height+",width="+width+",left="+left+",top="+top;
	window.open(url,"",args);
	//window.showModalDialog(url,"","dialogHeight:300px");
	return false;
}
function newWindow3(url, width, height){
	var left = (screen.availWidth - width)/2;
	var top = (screen.availHeight - height)/2;
	var args = "scrollbars=1,resizable=1,";
	args += "height="+height+",width="+width+",left="+left+",top="+top+"status=yes";
	window.open(url,"",args);
	//window.showModalDialog(url,"","dialogHeight:300px");
	return false;
}
function newHiddenWindow(url){
	var height = 0;
	var width = 0;
	var left = screen.availWidth + 100;
	var top = screen.availHeight + 100;
	var args = "height="+height+",width="+width+",left="+left+",top="+top;
	window.open(url,"",args);	
}
function uploadPhoto(){
	var url = "private/upload.do";
	var width = 406;
	var height = 255;
	newWindow2(url,width,height);
}
function uploadPhotoEx(){
	var url = "../private/uploadEx.do";
	var width = 406;
	var height = 255;
	newWindow2(url,width,height);
	return false;
}
function editBag(bagId){
		var url = "editBag.do?bagId=" + bagId;
		newWindow(url, 700, 500);
}
function publishBag(bagId){
		var url = "publishBag.do?bagId=" + bagId;
		newWindow(url, 400, 200);
}
function deleteBag(bagId){
	if (confirm("是否要删除组照 #"+bagId)){
		var url = "saveBag.do?action=delete&bagId=" + bagId;
		//window.navigate(url);
		newWindow(url, 300, 200);
	}
}
function publishBag(bagId){
		var url = "publishBag.do?bagId=" + bagId;
		newHiddenWindow(url);
}
function selectBag(bagId){
		var url = "cartBags.do?method=add&bagId=" + bagId;
		newHiddenWindow(url);
}
function showBagCart(){
	var url = "cartBags.do";
	//if (document.getElementsByTagName("base")){
	//	url = document.getElementsByTagName("base")[0].href + "/../" + url;
	//}
	newWindow2(url, 600, 500);
	return false;	
}
function publishedAllPhoto(e){
	var form = e.form;
	for(var i=0; i<form.elements.length; i++){
		if (form.elements[i].name=="published"){
			form.elements[i].checked = e.checked;
		}
	}
}
function editUser(userId){
	var url = "editAccount.do?id=" + userId;
	if (document.getElementsByTagName("base")){
		url = document.getElementsByTagName("base")[0].href + "/../manage/" + url;
	}		
	newWindow(url, 600, 500);
}
function deleteUser(userId){
	if (confirm("是否确定删除该账号?") ){
		var url = "saveAccount.do?method=delete&id=" + userId;
		if (document.getElementsByTagName("base")){
			url = document.getElementsByTagName("base")[0].href + "/../manage/" + url;
		}		
		newWindow(url, 600, 500);
	}
}
function editRoles(userId){
	var url = "editUserProps.do?id=" + userId;
	if (document.getElementsByTagName("base")){
		url = document.getElementsByTagName("base")[0].href + "/../manage/" + url;
	}		
	newWindow(url, 600,500);
}
function add2Cart(photoId){
	var img_id = "photo"+photoId;
	if (document.getElementById(img_id)){
		//document.getElementById(img_id).style.filter="glow(color=#ff0000,strength=20)";
		document.getElementById(img_id).style.border="2px solid #ee0000";
	}	

	var url = "resource/cart.do?method=add&photoId=" + photoId;
	if (document.getElementsByTagName("base")){
		url = document.getElementsByTagName("base")[0].href + "/../" + url;
	}	
	var height = 0;
	var width = 0;
	var left = screen.availWidth + 100;
	var top = screen.availHeight + 100;
	var args = "height="+height+",width="+width+",left="+left+",top="+top;
	window.open(url,"",args);	
	return false;
}
function addPhotos2Cart(ids){
	var photoIds = new Array();
	photoIds = ids.split(' ');
	var params = "";
	for (x in photoIds){
		var photoId = photoIds[x];
		if(photoId != ""){
			var img_id = "photo"+photoId;
			if (document.getElementById(img_id)){
				//document.getElementById(img_id).style.filter="glow(color=#ff0000,strength=20)";
				document.getElementById(img_id).style.border="2px solid #ee0000";
			}	
			params += "&photoId="+photoId;
		}
	}

	var url = "resource/cart.do?method=add" + params;
	if (document.getElementsByTagName("base")){
		url = document.getElementsByTagName("base")[0].href + "/../" + url;
	}	
	var height = 0;
	var width = 0;
	var left = screen.availWidth + 100;
	var top = screen.availHeight + 100;
	var args = "height="+height+",width="+width+",left="+left+",top="+top;
	window.open(url,"",args);	
	return false;
}
function showCart(){
	var url = "resource/cart.do";
	if (document.getElementsByTagName("base")){
		url = document.getElementsByTagName("base")[0].href + "/../" + url;
	}
	newWindow2(url, 600, 500);
	return false;
}
function confirmOrder(orderId){
	var url = "confirmOrder.do?id="+orderId;
	newWindow2(url, 400, 300);
}
function selectPhoto(photoId){
	var img_id = "photo"+photoId;
	if (document.getElementById(img_id)){
		//document.getElementById(img_id).style.filter="glow(color=#ff0000,strength=20)";
		document.getElementById(img_id).style.border="2px solid #ee0000";
	}	
	
		var url = "photocart.do?method=add&photoId=" + photoId;
		//newWindow2(url, 600, 500);
		newHiddenWindow(url);
		return false;
}
function showPhotoCart(){
	var url = "photocart.do";
	//if (document.getElementsByTagName("base")){
	//	url = document.getElementsByTagName("base")[0].href + "/../" + url;
	//}
	newWindow2(url, 600, 500);
	return false;	
}