var CurOpac = 100
var OpacTimer
var isNavi = false
var CurrentPage = ""
var CurrentHID = 0;
var CurWidth = 496
var mWidth = 400
var paintingShown = false;

$(document).ready(function(){
	$("a").each(function(){
		$(this).attr("href","#");					 
	});
	$("#mainTable a").each(function(){
		$(this).mousemove(function(){
			$("#HintBox").hide();
		});
	});
	$("#HintBox").show();
	$("#submitButton1").hide();
	$("#submitButton2").show();
});

function genNavi(t){
	NaviCode = ""
	switch(CurrentPage){
		case "PC_Schilderijen" : {NaviCode = NaviCode + "" + 0;}break;
		case "PC_Exposities" : {NaviCode = NaviCode + "" + 0;}break;
		case "PC_Contact" : {NaviCode = NaviCode + "" + 0;}break;
		case "PC_Biografie" : {NaviCode = NaviCode + "" + 0;}break;
	}
	switch(t){
		case "PC_Schilderijen" : {NaviCode = NaviCode + "-" + 0;}break;
		case "PC_Exposities" : {NaviCode = NaviCode + "-" + 0;}break;
		case "PC_Contact" : {NaviCode = NaviCode + "-" + 0;}break;
		case "PC_Biografie" : {NaviCode = NaviCode + "-" + 1;}break;
		case "mainTable" : {NaviCode = NaviCode + "-" + 0;}break;
	}
	
	if(t != "mainTable"){
		$("#mainTable").css("width","910px");
	}else{
		$("#mainTable").css("width","404px");
	}
	
	switch(NaviCode){
		case "-0" : {
			$("#" + t).fadeIn();
		}break;
		case "-1" : {
			$("#mainTable").fadeOut("slow",function(){$("#mainTable").hide();});
			$("#" + t).fadeIn();
		}break;
		case "0-0" : {
			$("#" + CurrentPage).fadeOut();
			$("#" + t).fadeIn();
		}break;
		case "0-1" : {
			$("#mainTable").fadeOut("slow",function(){$("#mainTable").hide();});
			$("#" + CurrentPage).hide();
			$("#" + t).fadeIn();
		}break;
	}
	CurrentPage = t
	
}

function loadC(url,layer){
	$("#" + layer).load(url);	
}


function sl(itemID){
	if(CurrentHID != itemID){
		if(itemID > 0){
			switch(itemID){
				case '1' : {genNavi('PC_Exposities');}break;
				case '3' : {genNavi('PC_Biografie'); }break;
				case '4' : {genNavi('PC_Schilderijen');}break;
				case '5' : {genNavi('PC_Contact');}break;
			}
		}
	}
}

function closePainting(){
	if(paintingShown == true){
		$("#PhotoHolder").fadeOut();
		$("#subMainTable").stop().animate({ opacity: 1.00 }, 500);
		paintingShown = false;
	}
}
function openImage(imgid,imgtxt){
	paintingShown = true;
	$("#subMainTable").stop().animate({ opacity: 0.15 }, 500,"swing",function(){
		$("#PhotoHolder_Content").hide();
		
		$("#txtSchilderijnaam").html(imgtxt);
		$("#PhotoHolder_Load").show();
		$("#PhotoHolder").show();
		
		$("#PhotoHolder_Content_Img").load(function(){
			
			$("#PhotoHolder_Content_Text").load("SchilderijData.php?ID=" + imgid,function(){

				$("#PhotoHolder_Load").hide();
				$("#PhotoHolder_Content").show();
				$("#PhotoHolder_Content_Text").css("top",parseInt($("#PhotoHolder_Content_Img").css("top").replace("px","")) + parseInt($("#PhotoHolder_Content_Img").height()) + "px");
				$("#PhotoHolder_Content_Img").css("left",(404-$("#PhotoHolder_Content_Img").width())/2);

			});
		});
		$("#PhotoHolder_Content_Img").attr("src","PaintingImg.php?Id=" + imgid + "&Size=3");
		
	});
}

function sendMail(){
	$.post("sendmail.php",$("#mailForm").serialize(), function(data){
		$("#PC_Email").html(data);
	});

	return false;
}
