﻿var ie5; var ns6;

function g(v) {
	return document.getElementById(v);
}
function p(v) {
	return parseInt(v); 
}

function rxpos(v) {
	var obj = g(v);
	var cx = 0;
	if (obj.offsetParent) {
		cx = obj.offsetLeft
		while (obj = obj.offsetParent) {
			cx += obj.offsetLeft
		}
	}
	return cx;
}

function rypos(v) {
	var obj = g(v);
	var cy = 0;
	if (obj.offsetParent) {
		cy = obj.offsetTop
		while (obj = obj.offsetParent) {
			cy += obj.offsetTop
		}
	}
	return cy;
}

function rxposObj(v) {
	var obj = v;
	var cx = 0;
	if (obj.offsetParent) {
		cx = obj.offsetLeft
		while (obj = obj.offsetParent) {
			cx += obj.offsetLeft
		}
	}
	return cx;
}

function ryposObj(v) {
	var obj = v;
	var cy = 0;
	if (obj.offsetParent) {
		cy = obj.offsetTop
		while (obj = obj.offsetParent) {
			cy += obj.offsetTop
		}
	}
	return cy;
}

function startup() {
	ie5=document.all&&document.getElementById;
	ns6=document.getElementById&&!document.all;
}

function positionThings() {
	g('GD_photo').style.left = rxpos('rightTD') + g('rightTD').offsetWidth - g('GD_photo').offsetWidth - 1 + "px";
	g('GD_photo').style.top = rypos('rightTD') + g('rightTD').offsetHeight - g('GD_photo').offsetHeight - 1 + "px";
	
	g('GD_text').style.left = rxpos('rightTD') + g('rightTD').offsetWidth - g('GD_text').offsetWidth - p(crf*10) + "px";
	g('GD_text').style.top = p(crf*220) + "px";
	
	g('GD_name').style.top = rypos('GD_photo') - g('GD_name').offsetHeight + "px";
	g('GD_name').style.left = rxpos('GD_photo') + "px";
	g('GD_name').style.width = g('GD_photo').offsetWidth + "px";
	
	if(blnIsFront) {
		g('contactLinkDiv').style.width = g('rightTD').offsetWidth - g('GD_photo').offsetWidth + "px";
		g('contactLinkDiv').style.left = rxpos('rightTD') + "px";
		g('contactLinkDiv').style.top = rypos('GD_photo') + g('GD_photo').offsetHeight - g('contactLinkDiv').offsetHeight + "px";
		g('iDiv').style.top = g('GD_name').style.top;
		g('iDiv').style.left = p(g('GD_name').style.left) - g('iDiv').offsetWidth - p(crf*5) + "px";
		
		
	g('ny_logo').style.left = rxpos('rightTD') + p(crf*0) + "px";
	g('ny_logo').style.top = rypos('rightTD') + p(crf*0) + "px";		
		
	}
	else {
		g('GD_photo').style.display = "none";
		g('GD_text').style.display = "none";
		g('GD_name').style.display = "none";
		g('bigI').style.left = rxpos('contTD') + g('contTD').offsetWidth - g('bigI').offsetWidth - p(crf*10) + "px";
		g('bigI').style.top = rypos('contTD') + g('contTD').offsetHeight - g('bigI').offsetHeight + "px";
		
		if(g('masterContainer').innerHTML == "") {
			g('bigI').style.display = "none";
		}
		
		if(g('thumbTable').rows[0].cells.length>0) {
			g('thumbsMainContainer').style.left = rxpos('thumbTD') + "px";
			g('thumbsMainContainer').style.top = p(crf*180) + "px";
			//g('thumbArrows').style.left = rxpos('thumbTable') + p(crf*260) - g('thumbArrows').offsetWidth - p(crf*10) + "px";
			//g('thumbArrows').style.top = rypos('thumbTable') + g('thumbTable').offsetHeight + p(crf*3) + "px";
			g('thumbArrows').style.left = rxpos('mainTable') + p(crf*220) + "px";
			g('thumbArrows').style.top = rypos('mainTable') + p(crf*300) + "px";
		}
		
		g('printhome').style.left = rxpos('rightGFX') + p(crf*15) + "px";
		g('printhome').style.top = rypos('rightGFX') + "px";
		
		g('masterBG').style.left = rxpos('contTD') + p(crf*10) + "px";
		g('masterBG').style.height = g('masterContainer').offsetHeight + p(crf*40) + "px";
		g('masterBG').style.top = rypos('contTD') + g('contTD').offsetHeight - g('masterBG').offsetHeight + "px";

		g('masterContainer').style.left = rxpos('masterBG') + p(crf*20) + "px";
		g('masterContainer').style.top = rypos('masterBG') + p(crf*20) + "px";	
		g('masterContainer').style.width = p(g('masterBG').style.width) - p(crf*60) + "px";
		
		g('detailThumbnail').style.left = rxpos('rightTD') + p(crf*20) + "px";
		g('detailThumbnail').style.top = rypos('rightTD') + p(crf*75) + "px";
		
		g('fabricThumbnail').style.left = rxpos('rightTD') + p(crf*20) + "px";
		g('fabricThumbnail').style.top = rypos('rightTD') + p(crf*325) + "px";
		
		if(typeof(intActiveItem)!="undefined") {
			if(intActiveItem>0) {
				g('thumbTable').rows[0].cells[intActiveItem - 1].childNodes[0].childNodes[0].style.border = "#9C1E36 1px solid";
				if(intActiveItem>3) {
					g('thumbsContainer').style.left = ((intActiveItem - 3) * p(crf*86)) * -1 + "px";
				}
			}
			changeTopRightImage(true);
		}
	
		if(arrDetailSmall.length > 0) {
			prepareDetailAndFabricImages();
			g('detailThumbnailArrows').style.left = rxpos('detailThumbnail') + "px";
			g('detailThumbnailArrows').style.top = rypos('detailThumbnail') + g('detailThumbnail').offsetHeight + p(crf*5) + "px";
			g('fabricThumbnailArrows').style.left = rxpos('fabricThumbnail') + "px";
			g('fabricThumbnailArrows').style.top = rypos('fabricThumbnail') + g('fabricThumbnail').offsetHeight + p(crf*5) + "px";
		}
		else {
			g('detailThumbnail').style.display = "none";
			g('fabricThumbnail').style.display = "none";
		}
	
		if(blnIsTextPage) {
			g('bigI').style.display = "none";
			g('masterBG').style.filter = "alpha(opacity=100)"; 
			g('masterBG').style.MozOpacity = 1;
			g('masterBG').style.left = rxpos('contTD') + 1 + "px";
			g('masterBG').style.top = rypos('contTD') + 1 + "px";
			g('masterBG').style.width = g('contTD').offsetWidth - 2 + "px";
			g('masterBG').style.height = g('contTD').offsetHeight - 2 + "px";
			
			g('masterBG').style.display = "block";
			
			g('masterContainer').style.left = p(g('masterBG').style.left) + p(crf*10) + "px";
			g('masterContainer').style.top = p(g('masterBG').style.top) + p(crf*10) + "px";
			g('masterContainer').style.width = g('masterBG').offsetWidth - p(crf*20) + "px";
			g('masterContainer').style.height = g('masterBG').offsetHeight - p(crf*20) + "px";
			
			g('masterContainer').style.display = "block";
			
		}
	}
	changeTopRightImage(false);
	if(g('contTD').innerHTML == "") {
		g('contTD').innerHTML = "&nbsp;";
	}
	
	if(typeof(strSpeImage1) != "undefined") {
		if(strSpeImage1!="") {
			g('detailThumbnail').src = strSpeImage1;
			g('detailThumbnail').style.display = "block";
		
			if(strSpeImage2!="") {
				g('fabricThumbnail').style.left = rxpos('rightTD') + p(crf*20) + "px";
				g('fabricThumbnail').style.top = rypos('rightTD') + p(crf*300) + "px";
				g('fabricThumbnail').style.width = g('detailThumbnail').offsetWidth + "px";
				g('fabricThumbnail').style.height = g('detailThumbnail').offsetHeight + "px";
				g('fabricThumbnail').src = strSpeImage2;
				g('fabricThumbnail').style.display = "block";
			}
		}
	}
}

function changeTopRightImage(skipVariable) {
	var intVar = 0;
	if(skipVariable == false) {
		if(typeof(intChangeTopRightImage)=="undefined") { return; }
		intVar = intChangeTopRightImage;
	}
	else {
		intVar = intActiveItem;
	}
	
	switch(intVar) {
			case 1:
				g("topmenuRightImage").src = "img/wedding_right_" + jsres + ".jpg";
				break;
			case 2:
				g("topmenuRightImage").src = "img/party_right_" + jsres + ".jpg";
				break;
			case 3:
				g("topmenuRightImage").src = "img/confirmation_right_" + jsres + ".jpg";
				break;
			case 4:
				g("topmenuRightImage").src = "img/babtism_right_" + jsres + ".jpg";
				break;
			}
}

var intCurrentDetailImage = 0;
var intCurrentFabricImage = 0;

function prepareDetailAndFabricImages() {
	g('detailThumbnail').src = arrDetailSmall[intCurrentDetailImage];
	g('fabricThumbnail').src = arrFabric[intCurrentFabricImage];
	
	if(arrDetailSmall.length==1) {
		g("detailThumbnailArrowRight").src = "img/arrow_right_WHITE_" + jsres + ".png";
	}
	if(arrFabric.length==1) {
		g("fabricThumbnailArrowRight").src = "img/arrow_right_WHITE_" + jsres + ".png";
	}
	
}

function moveDetailImage(moveDir) {
	if(moveDir==0) {
		if(intCurrentDetailImage > 0 ) {
			intCurrentDetailImage--;
		}
	}
	else {
		if(intCurrentDetailImage < arrDetailSmall.length - 1) {
			intCurrentDetailImage++;
		}
	}
	g('detailThumbnailArrowLeft').src = "img/arrow_left_BROWN_" + jsres + ".png";
	g('detailThumbnailArrowRight').src = "img/arrow_right_BROWN_" + jsres + ".png";
	if(intCurrentDetailImage==0) {
		g('detailThumbnailArrowLeft').src = "img/arrow_left_WHITE_" + jsres + ".png";
	}
	if(intCurrentDetailImage==arrDetailSmall.length - 1) {
		g('detailThumbnailArrowRight').src = "img/arrow_right_WHITE_" + jsres + ".png";
	}
	prepareDetailAndFabricImages();
}

function moveFabricImage(moveDir) {
	if(moveDir==0) {
		if(intCurrentFabricImage > 0 ) {
			intCurrentFabricImage--;
		}
	}
	else {
		if(intCurrentFabricImage < arrFabric.length - 1) {
			intCurrentFabricImage++;
		}
	}
	g('fabricThumbnailArrowLeft').src = "img/arrow_left_BROWN_" + jsres + ".png";
	g('fabricThumbnailArrowRight').src = "img/arrow_right_BROWN_" + jsres + ".png";
	if(intCurrentFabricImage==0) {
		g('fabricThumbnailArrowLeft').src = "img/arrow_left_WHITE_" + jsres + ".png";
	}
	if(intCurrentFabricImage==arrFabric.length - 1) {
		g('fabricThumbnailArrowRight').src = "img/arrow_right_WHITE_" + jsres + ".png";
	}
	prepareDetailAndFabricImages();
}

function showLargeDetailImage() {
	g('largeBGimage').src = arrDetail[intCurrentDetailImage];
}

function placeObjectBelowLeft(toAlignTo, moveObj, padHori, padVert) {
	alert(moveObj);
	g(moveObj).style.left = parseInt(rxpos(toAlignTo)) + padHori + "px";
	g(moveObj).style.top = parseInt(rypos(toAlignTo)) + g(toAlignTo).offsetHeight + padVert + "px";
}

function placeObjectBelowRight(toAlignTo, moveObj, padHori, padVert) {
	g(moveObj).style.left = parseInt(g(toAlignTo).style.left) + g(toAlignTo).offsetWidth - g(moveObj).offsetWidth + padHori + "px";
	g(moveObj).style.top = parseInt(g(toAlignTo).style.top) + g(toAlignTo).offsetHeight + padVert + "px";
}

function alignElementCentersHori(toAlignTo, moveObj, padding) {
	var toCenterPoint = 0;
	toCenterPoint = parseInt(g(toAlignTo).style.left);
	toCenterPoint = toCenterPoint + parseInt(g(toAlignTo).offsetWidth / 2);
	g(moveObj).style.left = toCenterPoint - parseInt(g(moveObj).offsetWidth / 2) + padding + "px";
}

function alignElementTop(toAlignTo, moveObj, padding) {
	var toTopPoint = 0;
	toTopPoint = parseInt(g(toAlignTo).style.top);
	g(moveObj).style.top = toTopPoint + padding + "px";
}

function alignElementBottoms(toAlignTo, moveObj, padding) {
	var toBottomPoint = 0;
	toBottomPoint = parseInt(g(toAlignTo).style.top);
	toBottomPoint = toBottomPoint + parseInt(g(toAlignTo).offsetHeight);
	g(moveObj).style.top = toBottomPoint - parseInt(g(moveObj).offsetHeight) + padding + "px";
}

function toggleInfo() {
	if(g('masterContainer').style.display != "block") {
		g('masterContainer').style.display = "block";
		g('masterBG').style.display = "block";
	}
	else {
		g('masterContainer').style.display = "none";
		g('masterBG').style.display = "none";
	}
	positionThings();
}

var a1 = 0; var a2 = 0; var a3 = 0;
var activeImgSet = 0;
var firstMove = false
var temp;

function resizeDiv() {
	var obj = document.getElementById("contTable");
	if(parseInt(obj.offsetHeight)>448) {
		document.getElementById("contDiv").style.width = 734 + "px";
	}
}

function printThis(v) { 
	document.forms.printform.printwhat.value = document.getElementById("masterContainer").innerHTML;
	document.forms.printform.submit();
}

function printerfocus() {
	printframe.focus();
	printframe.print();
}

var activeRefImage = 0;

function previousImage() {
	if(activeRefImage>0) {
		activeRefImage -= 1;
		pageImageNoteActually.innerHTML = refImageNotes[activeRefImage];
		pageImage.src = refImages[activeRefImage];
	}
}
function nextImage() {
	if(activeRefImage<refImages.length - 1) {
		activeRefImage += 1;
		pageImageNoteActually.innerHTML = refImageNotes[activeRefImage];
		pageImage.src = refImages[activeRefImage];
	}
}