// JavaScript Document

var photoDir='/wp-content/themes/cairn/images/mast/';

function slidePhotos(n) {
	goPhotos(n);	
}

function goPhotos(n) {
	// create slideshow on pages
	// take array element 1 till final element
	if(typeof(mast=='object')) {
		//
		  for(var i=0; i<mast.length; i++) {
			  	var newImage=mast[i];
				document.newImage = new Image; 
				document.newImage.src = photoDir+newImage+'.jpg';
		  }
		  //
		clearTimeout(timer);
		var msecs=4000;
			if(n<mast.length) {	var timer = setTimeout("fadephoto('out','"+mast[n]+"',"+n+")",msecs);	} 
	}	
}

function fadephoto(type,photo,n) {
	if(type=='out') {
		$("#masthead").fadeOut("slow", function () { fadephoto('in',photo,n) });
	} else if(type=='in') {
		$("#masthead").attr('src',photoDir+photo+'.jpg');
		$("#masthead").fadeIn("slow");
		goPhotos(n+1);
	}
}


function toggle(n) {
	// toggle expandable html snippets
	var atag='#atg'+n;
	var tdiv='#tg'+n;
	$(tdiv).toggle("normal");
	var isHidden=($(tdiv).css("height")=='1px')? true : false;
	$(atag).text(  (isHidden)? "[ - ]" : "[+]"  );		
}

mc=new Array()
mc[0]='575255322723243255275636345232245924625630305660593952556033573039';

function mc2(e) {
op='';chars='st2-n74opr.uyqz9m:0vwk_5x16hjab3igcdel8@f'; m='39525560243040';
inp=m+mc[e];for(i=0; i<inp.length; i+=2) {id=parseInt(inp.substr(i,2));op+=chars.charAt(id-23);}
window.location.href= op;
}