
function strdsp() {
	document.getElementById('v01').style.display = "none";
	document.getElementById('v02').style.display = "none";
	document.getElementById('v03').style.display = "none";
	document.getElementById('v04').style.display = "none";
	document.getElementById('mrspch').style.display = "none";
}

function strdsp_n() {
	document.getElementById('v01').style.display = "none";
	document.getElementById('v02').style.display = "none";
	document.getElementById('v03').style.display = "none";
	document.getElementById('v04').style.display = "none";
}

function mrdsp() {
	document.getElementById('mrspch').style.display = "block";
	document.getElementById('mrbtn').style.display = "none";
}

function phtdsp(str) {
		document.getElementById('prvr').style.display = "block";
	if ( str.substring(0,1) == "p" ) {
		document.getElementById('pthmnl01').style.display = "none";
		if ( str == "p1" ) document.getElementById('pthmnl01').style.display = "block";
	}
	if ( str.substring(0,1) == "v" ) {
		document.getElementById('vthmnl01').style.display = "none";
		if ( str == "v1" ) document.getElementById('vthmnl01').style.display = "block";
	}
}

$(document).ready( function() {
	var vwflg = "p";
	var vdvwnm = 1;
	fln = document.URL.split("/");
	if ( fln[3] == "" ) {	var fstfn = "b";}
	if ( fln[3] == "nairobi.html" ) {	var fstfn = "n";}
	if ( fln[3] == "seoul.html" ) {	var fstfn = "";}

	$("#next").click(function(){
		nppvw("next");
		return false;
	});

	$("#prevew").click(function(){
		nppvw("preview");
		return false;
	});

	$("#thumnext").click(function(){
		$("#tdsp01").attr("style","display:none");
		$("#tdsp02").attr("style","display:block");
		$("#thumnext").attr("style","display:none");
		$("#thumprev").attr("style","display:block");
		return false;
	});

	$("#thumprev").click(function(){
		$("#tdsp01").attr("style","display:block");
		$("#tdsp02").attr("style","display:none");
		$("#thumprev").attr("style","display:none");
		$("#thumnext").attr("style","display:block");
		return false;
	});

	$(".tab01").click(function(){
		prvwrnm();
		var prvwsrc = "/photos/"+fstfn+"0001.jpg";
		$(".mnprvw").attr("style","display:block");
		$(".mnprvw").attr("src",prvwsrc);
		vwflg = "p";
		return false;
	});
	$(".tab02").click(function(){
		vpflg = $(".mnprvw").attr("src");
		prvwrnm();
		$("#v01").attr("style","display:block");
		vwflg = $(this).attr("id");
		vdvwnm = 1;
		return false;
	});

	$(".pht").click(function(){
		prvwrnm();
		var prvwsrc = this.src.replace("s.jpg", ".jpg") ;
		$(".mnprvw").attr("style","display:block");
		$(".mnprvw").attr("src",prvwsrc);
		return false;
	});
	$(".vdr01").click(function(){
		prvwrnm();
		$("#v01").attr("style","display:block");
		return false;
	});
	$(".vdr02").click(function(){
		prvwrnm();
		$("#v02").attr("style","display:block");
		return false;
	});
	$(".vdr03").click(function(){
		prvwrnm();
		$("#v03").attr("style","display:block");
		return false;
	});
	$(".vdr04").click(function(){
		prvwrnm();
		$("#v04").attr("style","display:block");
		return false;
	});

	function prvwrnm() {
		$("#v01").attr("style","display:none");
		$("#v02").attr("style","display:none");
		$("#v03").attr("style","display:none");
		$("#v04").attr("style","display:none");
		$(".mnprvw").attr("style","display:none");
	}

	function nppvw(plc) {
		if ( vwflg == "p" ) {
			var select_src = $(".mnprvw").attr("src");
			var mData = select_src.match("photos\/(.*)\.jpg") ;
			var fStr = mData[1].substr(0,1);
			if( isNaN(fStr) ) {	var prvwsrc = mData[1].replace(fStr, "") ;}
			else {	var prvwsrc = mData[1];}
			if ( plc == "next" ) { var nprvwsrc = Number(prvwsrc)+1;}
			else { var nprvwsrc = Number(prvwsrc)-1;}

			if ( fln[3] == "" ) {
				if ( nprvwsrc < 1 || nprvwsrc > 54  ) return false;
				if ( nprvwsrc == 27 ) {
					$("#tdsp01").attr("style","display:block");
					$("#tdsp02").attr("style","display:none");
					$("#thumprev").attr("style","display:none");
					$("#thumnext").attr("style","display:block");
				}else if ( nprvwsrc == 28 ) {
					$("#tdsp01").attr("style","display:none");
					$("#tdsp02").attr("style","display:block");
					$("#thumnext").attr("style","display:none");
					$("#thumprev").attr("style","display:block");
				}
			} else {
				if ( nprvwsrc < 1 || nprvwsrc > 27  ) return false;
			}
			if ( nprvwsrc < 10 ) {	nprvwsrc = "000"+nprvwsrc	}
			else if ( nprvwsrc < 100 ) {	nprvwsrc = "00"+nprvwsrc	}
			select_src = select_src.replace(prvwsrc, nprvwsrc);
			$(".mnprvw").attr("src",select_src);
		} else {
			if ( plc == "next" ) { vdvwnm = Number(vdvwnm)+1;}
			else { vdvwnm = Number(vdvwnm)-1;}
			if ( ( vdvwnm < 1 || vdvwnm > 2 ) && vwflg == "nairobi" || 
			( vdvwnm < 1 || vdvwnm > 4 ) && vwflg == "seoul" || 
			( vdvwnm < 1 || vdvwnm > 4 ) && vwflg == "brussels" ) {
				if ( plc == "next" ) { vdvwnm = Number(vdvwnm)-1;}
				else { vdvwnm = Number(vdvwnm)+1;}
				return false;
			}
			prvwrnm();
			$("#v0"+vdvwnm).attr("style","display:block");
		}
		return false;
	}

});
