// BEGIN GALLERY SCRIPTS
// BEGIN SHOWHIDE ADD NEW DETAIL
function showElement(td,el){
	//alert(td + el);
	var thisTD = td;
	var box = getElem(el);
	if(box.style.display == "none"){
		box.style.display = "";
	} else {
		box.style.display = "none";
	}
	if(thisTD.className == "clickable_id"){
		thisTD.className = "clickable_id_selected";
	} else {
		thisTD.className = "clickable_id";
	}
}
function getElem(el){
	//return document.all ? document.all[el] : document.getElementById(el);
	return document.getElementById(el);
}
// END SHOWHIDE ADD NEW DETAIL

// BEGIN DELETE GALLERY CONFIRMATION
function delGallery(page) {
	var i = document.getElementById("E_GalleryId").value;
	if (i == "") {
		alert("Select a Gallery to Delete.");
	}
	else {
		if (confirm("Are you sure you wish to delete this Gallery?")) {	
			window.location = page + "?deltypeid=" + i;
			return true;
		}
	}
}
// END DELETE GALLERY CONFIRMATION
// BEGIN FUNCTION FOR GALLERY INFORMATION
function sendFormEditGalleryr() {
	var form=document.getElementById("EditGallery");
	if(document.getElementById("E_GalleryId").value == "") {
		alert("Please select a Gallery to edit.");
		return false;
	}
	else if(document.getElementById("E_Gallery").value == "") {
		alert("Please enter the updated Gallery into the field provided.");
		document.getElementById("E_Gallery").focus();
		return false;
	}
	else {
		var agree=confirm("Are you sure you wish to update this Gallery?");
		if (agree){
			return true;
		}
		else {return false;}
	}
}
// END FUNCTION FOR GALLERY CATEGORY
// BEGIN FUNCTION FOR ADDING NEW IMAGES VALIDATION
function sendFormAddImage() {
	var form=document.getElementById("AddImage");
	if(document.getElementById("UpFile").value == "") {
		document.getElementById("trmsg").style.display = "block";
		document.getElementById("pmsg").innerHTML = "<span class='message'>Please Attach Image File</span>";
		document.getElementById("UpFile").focus();
		return false;
	}
	else {
		document.getElementById("trmsg").style.display = "none";
		return true;
	}
}
// END FUNCTION FOR ADDING NEW IMAGES VALIDATION
// BEGIN CONFIRM DELETE IMAGE
function delImage(dImage, pageName){
	var agree=confirm("Are you sure you wish to delete this Image?");
	if (agree){
		window.location = pageName +'?doid=' + dImage;
		return true;
	}
}
// END CONFIRM DELETE IMAGE
// BEGIN OPEN IMAGE FILE
function getImage(ofile, local) {
	window.open(local + ofile,'_blank','width=800,height=600,menubar=no,scrollbar=no,resizable=no,toolbar=no');
}
// END OPEN IMAGE FILE
// BEGIN FUNCTION FOR ALL SORT BY TYPE FORM ONCHANGE
function sorttype(s) {
	var form=document.getElementById('SearchType');
	form.submit();
}
// END FUNCTION FOR ALL SORT BY TYPE FORM ONCHANGE
//END GALLERY SCRIPTS

var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}

function enlarge(desc, which, e, position, imgwidth, imgheight){
if (ie||ns6){
crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
if (window.opera && window.innerHeight) //compensate for Opera toolbar
vertpos=pgyoffset+window.innerHeight/2-imgheight/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
// var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
var vertposcenter=ns6? pgyoffset+window.innerHeight/4 : pgyoffset+ietruebody().clientHeight/4
}
 // crossobj.style.left=horzpos+"px"
// crossobj.style.top=vertpos+"px"
crossobj.style.left="25%" // MCS Mod
crossobj.style.top=vertposcenter+"px" // MCS Mod

crossobj.innerHTML='<img src="'+which+'" width="500px"><br/><div align="center" id="dragbar"><span class="captionTxt"><br/>'+desc+'<br/></span><span id="closetext" class="closeImg" onClick="closepreview()" style="cursor:pointer;"><a href="#" class="closeImg">Close</a></span> </div>'
crossobj.style.visibility="visible"
return false
}
else //if NOT IE 4+ or NS 6+, simply display image in full browser window
return true
}

function closepreview(){
crossobj.style.visibility="hidden"
}

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx+"px"
crossobj.style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
