var myPicPic;

function setSearchForm(p, l){
	document.searchform.elements['zipcode'].value=p;
	
	var selObj = document.searchform.elements['country'];
	selObj.value =l;
	document.searchform.submit();
	
}
function prevMyPic() {
	if(myPic) {
		if(!myPicPic) {
			myPicPic = document.getElementById("mypic");
		}
		myPicCurrent = myPicCurrent - 1;
		if(myPicCurrent < 0) {
			myPicCurrent = myPic.length - 1;
		}
		setImage(myPicPic, myPic[myPicCurrent], myPicWidth, myPicHeight);
	}
	return false;
}


function loadImage(i) {
	alert(i);	
}
function nextMyPic() {
	if(myPic) {
		if(!myPicPic) {
			myPicPic = document.getElementById("mypic");
		}
		myPicCurrent = myPicCurrent + 1;
		if(myPicCurrent >= myPic.length) {
			myPicCurrent = 0;
		}
		setImage(myPicPic, myPic[myPicCurrent], myPicWidth, myPicHeight);
	}
	return false;
}
function setImage(im, sr, w, h) {
	
	im.src = "http://www.dtp-import.nl/gfx/image.php?image=/" + sr + "&width=" + w + "&height=" + h;
}

function flip(who, sr) {
	who.src = sr;
}
function flipback(who, sr) {
	who.src = sr;
}

function showRoomPic(im, al) {
	document.getElementById("shrmp").src = "/gfx/image.php?image=" + im + "&width=545&height=410";
	document.getElementById("shrmp").alt = al;
	document.getElementById("shrmp").title = al;
}

function prevBgPic() {
	bgIndex = bgIndex - 1;
	if(bgIndex < 0) {
		bgIndex = bgImages.length - 1;
	}
	document.getElementById("vtwonen").style.backgroundImage = "url(" + bgImages[bgIndex] + ")";
}
function nextBgPic() {
	bgIndex = bgIndex + 1;
	if(bgIndex >= bgImages.length) {
		bgIndex = 0;
	}
	document.getElementById("vtwonen").style.backgroundImage = "url(" + bgImages[bgIndex] + ")";
}

$(function() {
	//if($(".collection_controls").length > 0) {
	//	$(".collection_controls").scrollable();
	//}
	if($("#controller1").length > 0) {
		if($("#controller1 .items").children().length > 1) {
			$("#controller1").scrollable();
			if($("#controller1").find(".active")) {
				vapi = $("#controller1").data("scrollable");
				a = $("#controller1").find(".active");
				i = a.parent().index();
				vapi.seekTo(i, 0);
			}
		} else {
			viewer = $("#controller1").parent();
			$(viewer).find(".prev").hide();
			$(viewer).find(".next").hide();
		}
	} 
	if($("#controller2").length > 0) {
		if($("#controller2 .items").children().length > 1) {
			$("#controller2").scrollable();
			if($("#controller2").find(".active")) {
				vapi = $("#controller2").data("scrollable");
				a = $("#controller2").find(".active");
				i = a.parent().index();
				vapi.seekTo(i, 0);
			}
		} else {
			viewer = $("#controller2").parent();
			$(viewer).find(".prev").hide();
			$(viewer).find(".next").hide();
		}
	} 
	
	$(".prev").click(function() {
		return false;
	});
	$(".next").click(function() {
		return false;
	});
	
});
