function settab(thistab) {
	//alert(document.MM_sr[0].oSrc);
	//alert(x.oSrc);
	var thiselement = "";
	var thisimage = "";
	for(i = 1; i <= 4; i++) {
		var thisitem = "tab_content_" + i;
		var thisicon = "tab_off_" + i;
		if(i == thistab) {
			thiselement = document.getElementById(thisitem);
			thiselement.style.display = "block";
			thisimage = document.getElementById(thisicon);
			thisimage.src = "images/tab_on_" + i + ".gif";
			document.MM_sr[0].oSrc = "images/tab_on_" + i + ".gif";
			
		}
		else {
			thiselement = document.getElementById(thisitem);
			thiselement.style.display = "none";
			thisimage = document.getElementById(thisicon);
			thisimage.src = "images/tab_off_" + i + ".gif";
			//document.MM_sr[0].oSrc = "images/tab_off_" + i + ".gif";
			
		}
	}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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];}
}
function viewpageid(thispage, thisid, thiswidth, thisheight) {
	var thiswindow;
	thiswindow = window.open(thispage + '?id=' + thisid, 'viewpage', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable');
	thiswindow.focus();
}
function viewpage(thispage, thiswidth, thisheight) {
	var thiswindow;
	thiswindow = window.open(thispage, 'viewpage2', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable');
	thiswindow.focus();
}
function viewimage(thisimg, thiswidth, thisheight) {
	var thiswindow;
	thiswindow = window.open('viewimage.php?id=' + thisimg, 'viewphoto', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable');
	//alert('viewimage.php?id=' + thisimg);
	thiswindow.focus();
}
function viewphotogallery(thisimg, thiswidth, thisheight) {
	var thiswindow;
	thiswindow = window.open('viewphotogallery.php?id=' + thisimg, 'viewphotogallery', 'width=' + thiswidth + ',height=' + thisheight + ',scrollbars,resizable');
	//alert('viewimage.php?id=' + thisimg);
	thiswindow.focus();
}
function closethiswindow() {
	window.close();
	window.opener.focus();
}
function inittb(pagestr)
{
tb_show('Loaded onload', pagestr, null);
}

function rebindLinks() {
		$("#pg_thumb_strip a").unbind('click');
		$("#pg_thumb_strip a").bind('click', function(e) {
		//alert(this.href);
		e.preventDefault();
		$("#photoloading").show();
		$("#photo_img").hide();
		var tmpUrl = this.href;
		var tmpQueryString = tmpUrl.split("?")
		//var tmpAlbumId = getQuerystring(tmpQueryString, "album");
		//alert(tmpQueryString[1]);
		tmpQueryString = tmpQueryString[1] + "&xml=1";
		$.ajax({
			type: "GET",
			url: "inc_pg_pic.php",
			data: tmpQueryString,
			timeout: 5000,
			error: function (XMLHttpRequest, textStatus, errorThrown) {
				xmlDataError(XMLHttpRequest, textStatus, errorThrown);
			},
			success: function (data) {
				UpdatePhoto(data);
			}
		});
	});
}




function xmlDataError(XMLHttpRequest, textStatus, errorThrown) {
	/*
	$("#forgotpassword_feedback").html("<p class='error'>We were unable to retrieve your login details.  Please try again.</p>");
	// Send error details in a support email
	$("#forgotpassword_message").hide('fast');
	$("#forgotpasswordform").show('fast');
	*/
	//alert(XMLHttpRequest + "\n\n" + textStatus + "\n\n" + errorThrown);
	return false;
}
/*
View PHotos in Album
*/

function UpdatePhotoData(data) {
	$("#pg_thumb_strip").html($(data).find("thumbstrip").text());
	$("#pg_prevlink").attr("href", ("gallery.php?p=" + $(data).find("prevlink").text() + "&catid=" + $(data).find("catid").text()));
	$("#pg_nextlink").attr("href", ("gallery.php?p=" + $(data).find("nextlink").text() + "&catid=" + $(data).find("catid").text()));
	$("#pg_prevlink").removeClass("hidepglink");
	$("#pg_prevlink").removeClass("showpglink");
	$("#pg_nextlink").removeClass("hidepglink");
	$("#pg_nextlink").removeClass("showpglink");
	$("#pg_prevlink").addClass($(data).find("prevlinkclass").text());
	$("#pg_nextlink").addClass($(data).find("nextlinkclass").text());
	$("#pg_thumb_loading").hide();
	$("#pg_thumb_strip").animate({"opacity": "show"});
	rebindLinks();
}

function UpdatePhoto(data) {
	$("#photo_img_nav_img").html($(data).find("thumbstrip").text());
	$("#photo_img_caption").html($(data).find("pictitle").text());
	$("#pg_main_left").removeClass("hidepglink");
	$("#pg_main_left").removeClass("showpglink");
	$("#pg_main_right").removeClass("hidepglink");
	$("#pg_main_right").removeClass("showpglink");
	$("#pg_main_left").addClass($(data).find("prevlinkclass").text());
	$("#pg_main_right").addClass($(data).find("nextlinkclass").text());
	$("#pg_main_left").attr("href", ("gallery.php?id=" + $(data).find("prevlink").text() + "&catid=" + $(data).find("catid").text()));
	$("#pg_main_right").attr("href", ("gallery.php?id=" + $(data).find("nextlink").text() + "&catid=" + $(data).find("catid").text()));
	$("#photoloading").hide();
	$("#photo_img").animate({"opacity": "show"});
	rebindLinks();
}
