
	//START IMAGE SWAP
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	//END IMAGE SWAP
	
	//START AJX HERE
	var http = createRequestObject();
	
	function createRequestObject() {
		var ro;
		//var browser = navigator.appName;
		if(window.ActiveXObject) { //browser == "Microsoft Internet Explorer"){
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
			ro = new XMLHttpRequest();
		}
		return ro;
	}
	
	function pic(action) {
		http.open('get', '/common/classes/gallery/display_pic.php?pic='+action+'&rnd='+new Date().valueOf().toString());
		http.onreadystatechange = handleResponse;
		http.send(null);
		PrevID = action;
	}
	var counter = 0;
	var maxInRow = 10;
	var padding = 9;
	var paddingLeft = 9;
	var nextRow = 11;
	function linkActiveBar( action, count) {
		//id = "link_bar"+PrevID;
		id = "link_bar"; // +action;
		
		
		counter++;
		var spaces = "";
		var spaces2 = "&nbsp;&nbsp;&nbsp;";	
		if(count == nextRow) {
			spaces2 = "";
		}
		if(counter > maxInRow) {
			// maxInRow = 9;
			padding = 4;
			paddingLeft = 4;
			counter = 1;
			spaces = "<br /><br />";
			nextRow = nextRow+10;
		}
		
		if(count == 1) {
			maxInRow = 10;
			counter = 1;
			padding = 8;
			paddingLeft = 9;
			document.getElementById(id).innerHTML = "";
			nextRow = 11;
			spaces2 = "";
		}
		if(count == 10) {
			padding = 4;
			paddingLeft = 4;
		}
		document.getElementById(id).innerHTML += spaces2+spaces+"<a class=\"gallery_thumbnail_link_active\" style=\"width: 30px; height:30px; padding-left:"+paddingLeft+ "px; padding-right:"+padding+"px;\"href=\"javascript:pic('" + action + "')\">"+count+"</a>";
	}
	
	function linkBar( action, count) {
		//id = "link_bar"+PrevID;
		id = "link_bar"; // +action;
				
		counter++;
		var spaces = "";
		var spaces2 = "&nbsp;&nbsp;&nbsp;";	
		
		if(count == nextRow) {
			spaces2 = "";
		}
		
		if(counter > maxInRow) {
			// maxInRow = 9;
			padding = 4;
			paddingLeft = 4;
			counter = 1;
			spaces = "<br /><br />";
			nextRow = nextRow+10;
		}
		
		if(count == 1) {
			maxInRow = 10;
			counter = 1;
			padding = 8;
			paddingLeft = 9;
			nextRow = 11;
			document.getElementById(id).innerHTML = "";
			spaces2 = "";
		}
		
		if(count == 10) {
			padding = 4;
			paddingLeft = 4;
		}
		document.getElementById(id).innerHTML += spaces2+spaces+"<a class=\"gallery_thumbnail_link\" style=\"width: 30px; height:30px; padding-left:"+paddingLeft+ "px; padding-right:"+padding+"px;\"href=\"javascript:pic('" + action + "')\">"+count+"</a>";
	}
	function handleResponse() {
		if(http.readyState == 4){
			var response = http.responseText;
			
			var x = response.split("|"); 
			
			document.getElementById("pic_info").innerHTML = x[0];
			MM_swapImage('big','',x[1] ,0);
			
			if (x[2] != "")
				document.getElementById("previous").innerHTML = '<a href="javascript:pic(\''+x[2]+'\')"><img src="/common/images/gallery/previous.jpg" /></a>';
			else
				document.getElementById("previous").innerHTML ='';
			if (x[3] != "")
				document.getElementById("next").innerHTML = '<a href="javascript:pic(\''+x[3]+'\')"><img src="/common/images/gallery/next.jpg" /></a>';
			else
				document.getElementById("next").innerHTML = '';
			var k = 7;
			var xInt = (parseInt(x[6])+1)
				
			for(var i = 1; i < xInt; i++) {
				if(i != x[5]) {
					linkBar(x[k],i);
				}
				else {
					linkActiveBar(x[k],i);
				}
				k++;
			}
		}
	}
	//END AJAX HERE