function weddingImages() {
var req=null;
if (window.XMLHttpRequest)
  {// code for all new browsers
  req=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5 and IE6
  req=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (req!=null)
  {
  var url="ajax.iml?mdl=design120/weddingImages.aj";
  var params="IEFIX="+Math.random()+"&DEBUG=1";
  req.open("GET",url+"&"+params,true);
  req.onreadystatechange=function() {
    if (req.readyState==4&&req.status==200) {
		el('weddingDiv').innerHTML=req.responseText;
		var divider=1;
		if(el('weddingImages').getElementsByTagName('img')[0].parentNode.tagName.toLowerCase()=="a") divider=2;
		var divMax=540*((el('weddingImages').getElementsByTagName('img').length-divider)/divider);
		hide('previous_link');show('previous_gray');
		hide('first_link');show('first_gray');
		if (divMax>0) {
			show('next_link');hide('next_gray');
			show('last_link');hide('last_gray');
		} else {
			show('next_gray');hide('next_link');
			show('last_gray');hide('last_link');
      }
    }
  }
  req.send(null);
  }
else
  {
  }
}

weddingImages();


function ShowImg(increment) {
	var divider=1;
	if(el('weddingImages').getElementsByTagName('img')[0].parentNode.tagName.toLowerCase()=="a") divider=2;
	var divMax=540*((el('weddingImages').getElementsByTagName('img').length-divider)/divider);
	var curLeft=parseFloat(el('weddingImages').style.left);
	el('weddingImages').style.left=(curLeft-(540*increment))+"px";
	if (parseFloat(el('weddingImages').style.left)==0) {
	  show('previous_gray');hide('previous_link');
	  show('first_gray');hide('first_link');
	} else {
	  hide('previous_gray');show('previous_link');
	  hide('first_gray');show('first_link');
	}
	if (parseFloat(el('weddingImages').style.left)==-divMax) {
	  show('next_gray');hide('next_link');
	  show('last_gray');hide('last_link');
	} else {
	  show('next_link');hide('next_gray');
	  show('last_link');hide('last_gray');
	}
}

function jumpFirst() {
	el('weddingImages').style.left=0;
	show('previous_gray');hide('previous_link');
	show('first_gray');hide('first_link');
	if(el('weddingImages').getElementsByTagName('img')[1]) {
		show('next_link');hide('next_gray');
		show('last_link');hide('last_gray');
	} else {
		show('next_gray');hide('next_link');
		show('last_gray');hide('last_link');
	}
}

function jumpLast() {
	var divider=1;
	if(el('weddingImages').getElementsByTagName('img')[0].parentNode.tagName.toLowerCase()=="a") divider=2;
	el('weddingImages').style.left=-(540*((el('weddingImages').getElementsByTagName('img').length-divider)/divider))+"px";
	show('next_gray');hide('next_link');
	show('last_gray');hide('last_link');
	if(el('weddingImages').getElementsByTagName('img')[1]) {
		show('first_link');hide('first_gray');
		show('previous_link');hide('previous_gray');
	} else {
		show('first_gray');hide('first_link');
		show('previous_gray');hide('previous_link');
	}
}

function deleteImg(name) {
	if(confirm('Are you sure you want to delete the image \''+name+'\'? This action cannot be undone.')) {
		ajaxCallFunction('ajax.iml?mdl=design120/weddingImagesDelete.mdl&File='+name+'&ieFix=Math.random()',function(sc,st,rt,rxml) { document.getElementById('weddingDiv').innerHTML=rt;var divider=1;if(el('weddingImages').getElementsByTagName('img')[0].parentNode.tagName.toLowerCase()=="a") divider=2;var divMax=540*((document.getElementById('weddingImages').getElementsByTagName('img').length-divider)/divider);hide('previous_link');show('previous_gray');hide('first_link');show('first_gray');if (divMax>0) { show('next_link');hide('next_gray');show('last_link');hide('last_gray'); } else { show('next_gray');hide('next_link');show('last_gray');hide('last_link'); } });
	}
}
