//clear input type file userfile
function clearphoto() {	
	var userfile=document.getElementById('userfile');	
	userfile.value='';
	document.getElementById('lbluserfile').innerHTML='';
	document.getElementById('lnkaddphoto').style.display='none';
	document.getElementById('lnkclearphoto').style.display='none';
	document.getElementById('rowimgcaption').style.display='none';	
}
//edit thumbnail image caption
function editthumbimgcap(thumbimageid) {	
	document.getElementById('lblthumbimgcap'+thumbimageid).style.display='none';
	document.getElementById('lbleditthumbimgcap'+thumbimageid).style.display='none';
	document.getElementById('lnkdeletethumbimgcap'+thumbimageid).style.display='none';
	
	document.getElementById('txtthumbimgcap'+thumbimageid).style.display='';
	document.getElementById('lblcancelthumbimgcap'+thumbimageid).style.display='';
	document.getElementById('lblsavethumbimgcap'+thumbimageid).style.display='';		
}
//cancel edit
function cancelthumbimgcap(thumbimageid) {	
	document.getElementById('lblthumbimgcap'+thumbimageid).style.display='';
	document.getElementById('lbleditthumbimgcap'+thumbimageid).style.display='';
	document.getElementById('lnkdeletethumbimgcap'+thumbimageid).style.display='';
	
	document.getElementById('txtthumbimgcap'+thumbimageid).style.display='none';
	document.getElementById('lblcancelthumbimgcap'+thumbimageid).style.display='none';
	document.getElementById('lblsavethumbimgcap'+thumbimageid).style.display='none';		
}
//save thumbnail image caption
function savecaption(frmname, imageid) {	
	var frm=document.getElementById(frmname);
	var action=document.getElementById('action');
	var id=document.getElementById('iid');
	
	id.value=imageid;
	action.value='savecaption';	
	frm.submit();
}
//show hide row
function togglerowvisible(rowid) {
	var row=document.getElementById(rowid);	
	var lbl=document.getElementById('lblshowhidephotos');
	if (row.style.display == '') {
		row.style.display='none';
		lbl.innerHTML='Show Photos';		
	} else {
		row.style.display='';
		lbl.innerHTML='Hide Photos';
	}
}
//delete photo image 
function deleteproductimage(productid, imageid) {
	if (confirm('Are you sure you want to delete this image?  This action cannot be undone.')) {
		document.location.href='?c=productedit&pid=' + productid + '&action=deletephoto&iid=' + imageid;
	}	
}
//clear form
function clearform($form) {
	switch ($form) {
		case "dropaline":
			document.getElementById('txtname').value='';
			document.getElementById('txtemailadd').value='';
			document.getElementById('txtmessage').value='';
			break;
	}
}
//confirm delete category
function deletecategory(editpage,catid,returl) {
	if (confirm('Are you sure you want to delete this category?  This action cannot be undone.')) {
		editpage='admin.php?c='+editpage;
		params='&action=delete';	
		params+='&catid='+catid;
		params+='&returl='+returl;
		window.location=(editpage+params);		
	} return false;
}
//confirm delete product
function deleteproduct(editpage,pid,returl) {
	if (confirm('Are you sure you want to delete this product?  This action cannot be undone.')) {
		editpage='admin.php?c='+editpage;
		params='&action=delete';	
		params+='&pid='+pid;
		params+='&returl='+returl;
		window.location=(editpage+params);		
	} return false;
}
//enable/disable category 
function enablecategory(editpage,catid,status,returl) {	
	if (status==0) { status=1; } else { status=0;}	
	editpage='admin.php?c='+editpage;
	params='&action=save';	
	params+='&catid='+catid;
	params+='&chkenabled='+status;
	params+='&returl='+returl;
	window.location=(editpage+params);
}
//hide/show category
function hidecategory(editpage,catid,status,returl) {	
	if (status==0) { status=1; } else { status=0;}	
	editpage='admin.php?c='+editpage;
	params='&action=save';	
	params+='&catid='+catid;
	params+='&chkhidden='+status;
	params+='&returl='+returl;
	window.location=(editpage+params);
}
//enable/disable product 
function enableproduct(editpage,pid,status,returl) {	
	if (status==0) { status=1; } else { status=0; }	
	editpage='admin.php?c='+editpage;
	params='&action=save';	
	params+='&pid='+pid;
	params+='&chkenabled='+status;
	params+='&returl='+returl;
	window.location=(editpage+params);
}
//add/remove product to/from category
function addproductscategories(editpage,catid,pid,status,returl) {
	/*if (status==true) { status=1; } else { status=0; }	
	editpage='admin?c='+editpage;
	params='&action=addproductscategories';	
	params+='&catid='+catid;
	params+='&pid='+pid;	
	params+='&chkadd='+status;
	params+='&returl='+returl;
	window.location=(editpage+params); */
}
//show spinner 
function showspinner() { document.getElementById("divspinner").style.display=''; }
function showspinner2() { document.getElementById("divspinner2").style.display=''; }
//hide spinner
function hidespinner() { document.getElementById("divspinner").style.display='none'; }
function hidespinner2() { document.getElementById("divspinner2").style.display='none'; }