function rowover(item, row) {
	
	if (document.getElementById("c" + row)) {
		if (document.getElementById("c" + row).checked == true) {
			item.className='highlistrow';
		} else {
			item.className='hoverlistrow';
		}
	} else {
		item.className='hoverlistrow';
	}

}

function rowout(item, row) {

	if (document.getElementById("c" + row)) {
		if (document.getElementById("c" + row).checked == true) {
			item.className='highlistrow';
		} else {
			item.className='listrow';
		}
	} else {
		item.className='listrow';
	}

}

function hrow(row, buttons, listname) {
	if (document.getElementById("c" + row).checked == true) {
		document.getElementById("r" + row).className = "highlistrow";
	} else {
		document.getElementById("r" + row).className = "listrow";
	}

	togglebtns(buttons, listname);
}

function togglebtns(buttons, listname) {

	if (buttons == 1) {
		ticked(listname + "item", listname + "delete");
	} else if (buttons == 2) {
		ticked(listname + "item", listname + "copy");
		ticked(listname + "item", listname + "delete");
	} else if (buttons == 3) {
		ticked(listname + "item", listname + "copy");
		ticked(listname + "item", listname + "delete");
		ticked(listname + "item", listname + "publish");
	}

}


function checkall(FieldName, CheckValue) {

	var objCheckBoxes = document.getElementsByName(FieldName);
	if(!objCheckBoxes) {
		return;
	}
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes) {
		objCheckBoxes.checked = CheckValue;
	} else {
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++) {
			objCheckBoxes[i].checked = CheckValue;
			objCheckBoxes[i].onclick();
		}
	}
}

function ticked(name, button) {
	var checkflag = "false";

	var field = document.getElementsByName(name);
	for (i = 0; i < field.length; i++) {
		if (field[i].checked == true) {
			checkflag = "true";
		}
	}

	if (checkflag == "true") {
		document.getElementById(button).disabled = false;
	} else {
		document.getElementById(button).disabled = true;
	}

}

function uploadsubmit(type) {
	
	if (type != 'admin') {
		// Get the name and id
		var galleryid = $('#galleryid').val();
		var galleryname = $('#galleryname').val();
		
		if (!galleryid && galleryname == '') {
			alert("You must enter a name for your new gallery.");
			return false;
		}
	}

	var Flash;

	if (document.embeds && document.embeds.length >= 1 && navigator.userAgent.indexOf("Safari") == -1) {
		Flash = document.getElementById("EmbedFlashFilesUpload");
	} else {
		Flash = document.getElementById("FlashFilesUpload");
	}
	
	var FormObj = document.getElementById("uploadform");

	var FormValues = "";
	for (var i = 0; i<FormObj.elements.length; i++) {
		FormValues += escape(FormObj.elements[i].name) + "=" + escape(FormObj.elements[i].value) + ((i!=(FormObj.elements.length-1))?'&':'');
	}

	Flash.SetVariable("SubmitFlash", FormValues);

	return false;
}

function ajaxsubmitform(formid, action, resultbox) {

	var str = $("#" + formid).serialize();

	$.ajax({
		type: "POST",
		url: action,
		data: str,
		cache: false,
		success: function(html){
			alert(html);
			document.getElementById("resultbox").innerHTML = html;
//			alert($("#" + resultbox).html);
//			$("#" + resultbox).innerHTML = html;
		}
	});

}


