// JavaScript file for Wedding Pages
// ==============================================================
// POP A WINDOW
// ==============================================================
function popWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function onNav(){
}


// ======= Some Other Stuff to Sort Through for Relevance ======================

//   Xtra Pixelator
//   
//   Copyright (c) January 2002 Xtra Limited

var timeOutRef = new Array();
function isIE() {
    //detect if browser is IE5.5 or higher (these browsers support transitions)
	var isIE55Plus = false;
	var n = navigator;
    var ua = ' ' + n.userAgent.toLowerCase();
    if(ua.indexOf('msie') > 0) {
	    //is ie but what version
		var version = parseFloat(ua.substr(ua.indexOf('msie')+5,3));
		isIE55Plus = version != 'NaN' && version >= 5.5;
	}
	return isIE55Plus;
}
function swap(prefix, container, direction, autoplaySetting) {
    var thisImageIndex = eval(prefix + '_imageIndex');
    var length = eval(prefix + "_images.length");
    oldImageIndex = thisImageIndex;         
    imageIndex = thisImageIndex + direction;
    if (imageIndex > length-1) {
        imageIndex = 0;
    } else if (imageIndex < 0) {
        imageIndex = length-1;
    }
    if (!autoplaySetting) {
       eval(prefix + 'doAutoplay = false');
       //eval(prefix + '_autoplayCheckbox.checked = false');
	   var objx = document.getElementById(prefix + '_autoplayCheckbox');
	   objx.checked = false
	   if (timeOutRef[prefix]!=null) {
		   clearTimeout(timeOutRef[prefix]);
	   }
    }
    if (isIE()) {
        if(direction==1) {
            container.style.filter = eval( prefix + "_forwardsTransition");
        } else {
            container.style.filter = eval( prefix + "_backwardsTransition");
        }
        container.filters[0].apply();

        eval( prefix + '_theImage_' + oldImageIndex + '.style.visibility="hidden"');
        eval( prefix + '_theImage_' + oldImageIndex + '.style.position="absolute"');
        eval( prefix + '_theImage_' + imageIndex + '.style.position="static"');
        eval( prefix + '_theImage_' + imageIndex + '.style.visibility="visible"');

        container.filters[0].play();

    } else {
        container.innerHTML=  eval(prefix + "_images[imageIndex]");
    }
    updateText(prefix, "credit", imageIndex);
    updateText(prefix, "caption", imageIndex);
    updateText(prefix, "introduction", imageIndex);
    eval(prefix + '_imageIndex=imageIndex');
}

function autoplay(prefix, containerId, delay) {
	if (eval(prefix + '_doAutoplay')) {
		swap(prefix, document.getElementById(containerId), 1, true);
		func = 'autoplay(\'' + prefix + '\',\'' + containerId + '\',' + delay + ')';
		if (timeOutRef[prefix]!=null) {
		   clearTimeout(timeOutRef[prefix]);
		}
		timeOutRef[prefix]=setTimeout(func, delay);
    }
}
function processAutoplay(isChecked, prefix, containerId, delay) {
    if (isChecked) {
        autoplay(prefix, containerId, delay);
    } else {
        eval(prefix + '_doAutoplay = false');
    }
}
function updateText(prefix, spanName, index) {
    if (eval(prefix + '_do' + spanName + 's')) {
        document.getElementById(prefix + '_' + spanName).innerHTML=eval(prefix + '_' + spanName + 's[' +index + ']');
    }
}

// ======= Some Other Stuff to Sort Through for Relevance ======================

// ======= And More things to look into ===============================
//onload handler

var onLoads=new Array();
function addOnLoad(onLoad) {
	onLoads[onLoads.length]=onLoad;
}
function executeOnLoads() {
	for(i=0; i<onLoads.length; i++) {
		eval(onLoads[i]);
	}
}

//browser redirect
function browserRedirect(userAgent, version, relation, url, newWindow, windowFeatures) {
	//redirects or pops window for particular browser types and versions
	//userAgent is a string with value of ns, ie or all
	//   ns encompases: mozilla, spoofer, compatible, webtv, hotjava
	//   ie encompases: ie opera
	//version is release number
	//relational is string equals, greaterThan or lessThan
	//url url to redirect or pop
	//newWindow boolean, if true pops new window, else redirect
	//windowFeatures string of window to use if new window poped

	var thisAgent=navigator.userAgent.toLowerCase();
	var thisIsNS  = ((thisAgent.indexOf('mozilla')!=-1) && (thisAgent.indexOf('spoofer')==-1) && (thisAgent.indexOf('compatible') == -1) && (thisAgent.indexOf('webtv')==-1) && (thisAgent.indexOf('hotjava')==-1));
	var thisIsIE  = ((thisAgent.indexOf("msie") != -1) || (thisAgent.indexOf("opera") != -1));
	var thisVersion = parseFloat(navigator.appVersion);

	var userAgentTest = false;
	if(thisIsNS && (userAgent=='ns' || userAgent=='all')) {
		userAgentTest = true;
	} else if(thisIsIE && (userAgent=='ie' || userAgent=='all')) {
		userAgentTest = true;
	}
	var versionTest = false;
	if (userAgentTest) {
		if (relation=="equals" && thisVersion==version) {
			versionTest = true;
		} else if (relation=="lessThan" && thisVersion < version) {
			versionTest = true;
		} else if (relation=="greaterThan" && thisVersion > version) {
			versionTest = true;
		}
	}
	if(userAgentTest && versionTest) {
		if (newWindow) {
			window.open(url,'',windowFeatures);
		} else {
			document.location=url;
		}
		return true;
	}
	return false;
}



function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images) {
		if(!d.MM_p)
			d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
	}
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0; i<(a.length-2); i+=3)
		if ((x=MM_findObj(a[i]))!=null) {
			document.MM_sr[j++]=x;
			if(!x.oSrc)
				x.oSrc=x.src;
			x.src=a[i+2];
		}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;
	for(i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++)
		x.src=x.oSrc;
}
// ========================================================================================
