var xmlHttp;
var ShowWait;
function AjaxShowPage(GalleryID,PageNumber){
	document.getElementById("loading").style.display = "block";
	AjaxShowPageImages(GalleryID,PageNumber);
}
function AjaxPartsShowPage(GalleryID,PageNumber){
	document.getElementById("loading").style.display = "block";
	AjaxShowPartImages(GalleryID,PageNumber);
}
function AjaxPart(path_name,gallery_id,page_number,short_name){
	document.getElementById("loading").style.display = "block";
	AjaxShowPart(path_name,gallery_id,page_number,short_name);
}
function AjaxShowPart(path_name,gallery_id,page_number,short_name){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ('Browser does not support HTTP Request');
		return
	}
	var url='/ajax/get_part.php?gallery_id='+gallery_id+'&page_number='+page_number+'&path_name='+path_name+'&short_name='+short_name;
	xmlHttp.onreadystatechange=AjaxPageStateChanged
	xmlHttp.open('GET',url,true)
	xmlHttp.send(null)
}
function AjaxShowPageImages(GalleryID,PageNumber){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ('Browser does not support HTTP Request');
		return
	}
	var url='/ajax/get_gallery_page.php?gallery_id='+GalleryID+'&page='+PageNumber;
	xmlHttp.onreadystatechange=AjaxPageStateChanged
	xmlHttp.open('GET',url,true)
	xmlHttp.send(null)
}
function AjaxShowPartImages(GalleryID,PageNumber){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ('Browser does not support HTTP Request');
		return
	}
	var url='/ajax/get_parts_page.php?gallery_id='+GalleryID+'&page='+PageNumber;
	xmlHttp.onreadystatechange=AjaxPageStateChanged
	xmlHttp.open('GET',url,true)
	xmlHttp.send(null)
}
function AjaxPageStateChanged(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete'){
		document.getElementById('txt_ajax_out').innerHTML=xmlHttp.responseText;
		document.getElementById("loading").style.display = "none";
	}
}
function ToggleTabs(TagName,TagCount,TagCurrent,ShowWaitDiv){
	ShowWait = ShowWaitDiv;
	if (ShowWaitDiv=='1'){
		document.getElementById("loading").style.display = "block";
	}
	var MaxCount = TagCount+1;
	for (tc=1;tc<TagCount;tc++){
		document.getElementById(TagName+"_select"+tc).className="";
	}
	document.getElementById(TagName+"_select"+TagCurrent).className="current";
	showPhotoGroup(TagCurrent,ShowWait);
}
function showPhotoGroup(str){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ('Browser does not support HTTP Request');
		return
	}
	var url='/ajax/get_ajax_group.php?q='+str
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open('GET',url,true)
	xmlHttp.send(null)
}
function stateChanged(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete'){
		document.getElementById('txt_ajax_out').innerHTML=xmlHttp.responseText;
//		wait(350);
		if (ShowWait=='1'){
			document.getElementById("loading").style.display = "none";
		}
	}
}
function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		try{
			xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e){
			xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
		}
	}
	return xmlHttp;
}
function wait(msecs) {
	var start = new Date().getTime();
	var cur = start
	while(cur - start < msecs) {
		cur = new Date().getTime();
	} 
}
function externalLinks(){
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
		}
	}
}
window.onload = externalLinks;