function hide(){for(var i=0;i<arguments.length;i++){document.getElementById(arguments[i]).style.display='none';}}
function show(){for(var i=0;i<arguments.length;i++){document.getElementById(arguments[i]).style.display='block';}}
function showi(){for(var i=0;i<arguments.length;i++){document.getElementById(arguments[i]).style.display='inline';}}
function showhide(){
	for(var i=0;i<arguments.length;i++){
		if (document.getElementById(arguments[i]).style.display=='block') {
			document.getElementById(arguments[i]).style.display='none';
		} else if(document.getElementById(arguments[i]).style.display=='none') {
			document.getElementById(arguments[i]).style.display='block';		
		}
	}
}
function openConfirm(bid, key) {
  Dialog.confirm("My requesting contact information from a seller, you will open a transaction between the user. Are you sure you want to open a transaction?", 
         {top: 300,
         	width:250, 
         	className: "alphacube",
         	okLabel: "Yes",
         	cancelLabel:"No",
         	ok:function() {
         		location.href = "/contact-seller?bid=" + bid + "&key=" + key;
         		return true;
         		}
         	}
         )
}

function confirmDelete(id, content, code){
	if (code != 'undefined') {
		var deleteYes = confirm ("Are you sure you mark this " + content + " as " + code + "?")		
	} else {
		var deleteYes = confirm ("Are you sure you want to delete this " + content + "?")
	}
	if (deleteYes){
		var urlvars = "?" + content + "&id=" + id;
		if (code != 'undefined') {urlvars += "&code=" + code;}
		window.location="/delete.php" + urlvars;
	}
}

function toggleButton(checkId, buttonId){
	if(document.getElementById(checkId).checked == true){
		document.getElementById(buttonId).disabled = false;
	} else {
		document.getElementById(buttonId).disabled = true;
	}
}

function termsReminder(checkId){
	if(document.getElementById(checkId).checked == false){
		alert('You must agree to the BookMaid Terms of Use.');
		return false;
	} else {
		alert('2You must agree to the BookMaid Terms of Use.');
		return true;
	}
}

function setSearch(searchType){
	if (searchType != 'isbn'){document.getElementById('search_type_isbn').className = '';}
	if (searchType != 'title'){document.getElementById('search_type_title').className = '';}
	if (searchType != 'author'){document.getElementById('search_type_author').className = '';}
	document.getElementById('search_type_' + searchType).className = 'search_type_active';
	document.getElementById('search_type').name = searchType;
}

function transAttempt(pNode){
	pNode.removeChild(pNode.lastChild);
	must_login = document.createElement("span");
	must_login.setAttribute("class", "errorspan");
	must_login.innerHTML = "You must <a href=\"/login\">login</a> to open a transaction."
	pNode.appendChild(must_login);
}
