/**
 * popup a window
 * @param {Object} url
 * @param {Object} name
 */
var global_popwin=new Object();
function popup(url,name) {	
	if(global_popwin[name]){
		global_popwin[name].close();
	}
	global_popwin[name]=window.open(url,name,"menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=960,height=600");	
	global_popwin[name].focus();
	//window.open(url,name,"menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=960,height=600");
}
function popupwh(url,name,width,height) {
	if(global_popwin[name]){
		global_popwin[name].close();
	}
	global_popwin[name]=window.open(url,name,"menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width="+width+",height="+height);
	global_popwin[name].focus();
}
function popupfocus(url,name) {	
	if((global_popwin[name])&&(global_popwin[name]!=null)&&(!global_popwin[name].closed)){
		global_popwin[name].focus();
	}else{
	global_popwin[name]=window.open(url,name,"menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=960,height=600");	
	}
}
function popupwh2(url,name,width,height) {
	global_popwin[name]=window.open(url,name,"menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width="+width+",height="+height);
	global_popwin[name].focus();
}
function popup2(url,name) {	
	global_popwin[name]=window.open(url,name,"menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=960,height=600");	
	global_popwin[name].focus();
}
/**
 * set item value
 * @param {Object} itemId
 * @param {Object} value
 */
function pickupToItem() {
	if (!window.opener) {return;}	
	if ('1'==document.getElementById("shoppingListPopup").value||null != window.opener.document.getElementById("shoppingListPopup")){
		document.getElementById("shoppingListPopup").value='1';
		if(null==arguments[5]){return;}
		var s=arguments[5].parentNode.parentNode;
		var url='';
		if(s.cells[0].firstChild.style.display=="none"){
				s.cells[0].firstChild.style.display="block";
				url='user.shoppingListItem.new.do?field(ID)='+arguments[1]+'&field(name)='+arguments[2]+'&field(LID)='+arguments[4];	
		}else{
				url='user.shoppingListItem.delete.do?field(ID)='+arguments[1]+'&field(name)='+arguments[2]+'&field(LID)='+arguments[4];	
				s.cells[0].firstChild.style.display="none";
		}
		window.opener.document.location.href=url;
	}else{
		var e, last="";
		for(var i=0;i<arguments.length-1;i++) {
		    e = window.opener.document.getElementById(arguments[0] + last);	
			if (!e) {break;}
			else {
				if (i < 2) {
		            e.value = arguments[i+1];			
				} else {
					e.innerHTML = arguments[i+1];
				}
				last+="_";
			}
		}
		window.close();
	}
}
