// PhotoGallery Load Javascript

var xmlhttp;

function loadXMLDoc(id,gID){
	url = "photogallery/default_photo_details.php?id="+id+"&gID="+gID+"&c="+Math.random();
	
	xmlhttp=null;
	var b = 1;
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest();	  
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");	  
	  }
	if (xmlhttp!=null)
	  {	  
	  xmlhttp.onreadystatechange=state_Change;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.send(null);
	  }
	else
	  {
	  alert("Your browser does not support XMLHTTP.")
	  }
}

function state_Change(){
	
	var content = document.getElementById('photo_content');
	var isIE = false;
	var ua = navigator.userAgent;	
	var s = "MSIE";	
		
	// Checking for IE Version
	if (ua.indexOf(s)>0) {
    	isIE = true;		
		document.getElementById('gallery_form').style.display='none';
		document.getElementById('gallery_prv').style.display='block';
	}	
	// if xmlhttp shows "loaded"
	if (xmlhttp.readyState==4){
		// if "OK"
		if (xmlhttp.status==200){
			if(isIE==true){
				//alert("XML data OK");
				content.style.display = 'block';
				content.style.filter = 'progid:DXImageTransform.Microsoft.Pixelate(maxSquare=10, duration=1, enabled=false)';
				content.filters[0].apply();
				//content.filters.item("DXImageTransform.Microsoft.CheckerBoard").apply();
				content.innerHTML=xmlhttp.responseText;			
				content.filters[0].play();
			}
			else{							
				content.style.display = 'block';				
				content.innerHTML=xmlhttp.responseText;
			}
		}
		else{
			alert("Problem retrieving Data:" + xmlhttp.statusText);
		}
	}
	else{		
		content.style.display = '';
		content.innerHTML='<span style="background:#333333;width:150px;display:block" class="text"><center>Loading... Please Wait!<br><br><img src="./photogallery/images/icon_loading.gif" align="absmiddle"><br><br></center></span>';
	}
	resize();
}

function photo_close(){
	document.getElementById('photo_content').style.display = 'none';
	document.getElementById('gallery_form').style.display='';
	document.getElementById('gallery_prv').style.display='none';
}

function resize()
{
  var wide = window.screen.availWidth
  var high = window.screen.availHeight
  var maxh = 600 // your max height here; enter 0 if not used
  var maxw = 800 // your max width here; enter 0 if not used
  var content = document.getElementById('photo_content')
  content.style.position = 'absolute'
  if(maxh > 0 && high <= maxh)
  {
  content.style.height = high
  }
  if(maxw > 0 && wide <= maxw)
  {
  content.style.height = high
  }
  if(maxh > 0 && high > maxh)
  {
  content.style.height = maxh
  high = (high - maxh) / 2
  content.style.top = high
  }
  if(maxw > 0 && wide > maxw)
  {
  content.style.width = maxw
  wide = (wide - maxw) / 2
  content.style.left = wide
  }  
}

function validate_photoUpload(f){
	if(f.lprn.value == ""){
		alert("Please select a Section");
		f.lprn.focus();
		return false;
	}
	else if(f.Submit.value != 'Update' && f.file.value == ""){
		alert("Please provide a File to upload");
		f.file.focus();
		return false;
	}
	else if(f.priority.value == "" || f.priority.value <= 0){
		alert("Please give a display priority");
		f.priority.focus();
		return false;
	}
	else{
		return true;
	}
}

// Disable Right Click
var message = ""; // The Message box message here I Don't want a alert so blank

function clickIE() {	
	if (document.all) {
		//alert(message);
		return false;
	}
}
function clickNS(e) {	
	if (document.layers||(document.getElementById && !document.all)) {
		if (e.which==2||e.which==3) {
			//alert(message);
			return false;
		}
	}
}
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
}
else{
	document.onmouseup=clickNS;
	document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return false")

function disableselect(e){
	return false
}

function reEnable(){
	return true
}
document.onselectstart=new Function ("return false")

/*// Right Click and Drag Disable
var specialcase = ((navigator.userAgent.indexOf('Mac') != -1) || document.all)
var flag = 0;
var msg = 'This image is protected by copyright.\nWe request you not to copy it.';
var x,y,x1,y1,copyAttempt;

function init()
{
	if (!(document.getElementById || document.all || document.layers)) return;
	if (specialcase && document.layers)
	{
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = special;
	}
	for (i=0;i<document.images.length;i++)
	{
		document.images[i].onmousedown = checkIt;
		document.images[i].onmouseup = function() {return false};
		if (specialcase)
		{
			document.images[i].onmousemove = special;
			document.images[i].onclick = clearIt;
		}
	}
}

function checkIt(e)
{
	copyAttempt = 0;
	if (window.Event)
	{
		x = e.screenX;
		y = e.screenY;
		theButt = (e.which == 3);
	}
	else
	{
		x = window.event.clientX;
		y = window.event.clientY;
		theButt = (window.event.button == 2);
	}
	if (theButt)
	{
		copyAttempt = 1;
		flag = 0;
		alert(msg);
		return false; // NN4 only
	}
	if (specialcase) flag = 1;
	return false;
}

function special(e)
{
	theObj = '';
	if (window.Event)
	{
		x1 = e.screenX;
		y1 = e.screenY;
		if (e.target.parentNode) theObj = e.target.parentNode.tagName;
	}
	else
	{
		x1 = window.event.clientX;
		y1 = window.event.clientY;
		theObj = window.event.srcElement.parentElement.tagName;
	}
	var isLink = (theObj == 'A');
	if (flag && (!isLink || ((Math.abs(x-x1) > 10) || (Math.abs(y-y1) > 10))))
	{
		copyAttempt = 1;
		flag = 0;
		alert(msg);
		return false;
	}
}

function clearIt()
{
	flag = 0;
	if (copyAttempt)
	{
		copyAttempt = 0;
		return false;
	}
}

window.onload = init;*/