
$(document).ready(function () {
	$("a.logo_h").click(function () {
		$("body, html").animate({ scrollLeft: 0 }, 250);
		return false;
	});
	$("a.left").click(function () {
		var id = $("div.image").attr("id");
		var k = $("a.left").attr("id");
		var tot = $("div.imgnum").attr("id"); 
		$("div.image").load("/php/getimage.php",{id:id,k:k},function (){
			var next = parseInt(k) + parseInt(1);
			if (parseInt(next) > parseInt(tot)){
				next = 1;
			}
			$("a.right").attr("id",next);
			var prev = parseInt(k) - parseInt(1);
			if (parseInt(prev) < 1){
				prev = parseInt(tot);
			}
			$("a.left").attr("id",prev);
			$("div.imgnum").html("<h2>"+k+" of "+tot+"</h2>");
			sifrH2();
		});
		
		return false;
	});
	$("a.right, div.image").click(function () {
		var id = $("div.image").attr("id");
		var k = $("a.right").attr("id");
		var tot = $("div.imgnum").attr("id"); 
		$("div.image").load("/php/getimage.php",{id:id,k:k},function (){
			var next = parseInt(k) + parseInt(1);
			if (parseInt(next) > parseInt(tot)){
				next = 1;
			}
			$("a.right").attr("id",next);
			var prev = parseInt(k) - parseInt(1);
			if (parseInt(prev) < 1){
				prev = parseInt(tot);
			}
			$("a.left").attr("id",prev);
			$("div.imgnum").html("<h2>"+k+" of "+tot+"</h2>");
			sifrH2();
		});
		
		return false;
	});
	$("a.email").click(function () {
		
	});
});

function email(user,domain,subject) {
	locationstring = "mailto:" + user + "@" + domain+"?subject="+subject;
	window.location = locationstring;
}

function getMap(el){
	var projecturl = $(el).attr("id");
	var destination = $(el).parent().attr("id");
	var imgdiv = destination.replace("info","img");
	var container = destination.replace("info","cont");
	var w = $("#"+container).width();
	$("#"+destination).load("/php/getinfo.php",{p:projecturl,w:w,t:2});
	$("#"+imgdiv).load("/php/getmap.php",{p:projecturl,w:w});
}

function getInfo(el,getimg){
	var projecturl = $(el).attr("id");
	var destination = $(el).parent().attr("id");
	$("#"+destination).load("/php/getinfo.php",{p:projecturl,t:1});
	if (getimg){
		var imgdiv = destination.replace("info","img");
		$("#"+imgdiv).load("/php/getindeximg.php",{p:projecturl});
	}
}
function getIndx(el,getimg){
	var projecturl = $(el).attr("id");
	var destination = $(el).parent().attr("id");
	$("#"+destination).load("/php/getinfo.php",{p:projecturl,t:3,g:getimg});
	if (getimg){
		var imgdiv = destination.replace("info","img");
		$("#"+imgdiv).load("/php/getindeximg.php",{p:projecturl});
	}
}

function sifrH2(){
	sIFR.replace(hermes, {
	selector: 'h2',
	wmode: 'transparent',
	fitExactly: true,
	tuneHeight: -4,
	offsetTop: 1,
	forceSingleLine: true,
	css: '.sIFR-root { color: #000000;}'
	});
}