
function mailTag( userName, domainName)
{
var EmailId;
var atSign = "&#64;"
var fullStop = "&#46";

EmailId = userName;
EmailId = "" + EmailId + atSign; 
EmailId = EmailId + domainName;

document.write( "<a href='mail" + "to:" + EmailId + "'>" + EmailId
+"</A>" );
}

/* example

<script language="JavaScript" >mailTag("John.Smith", "ourowndomain.com");</script>

*/



function hideWarning(){
	$(".warningMaster").hide();
	// now set a cookie, saying in effect: I do get it
	$.cookie('browserWarning', 'true', { expires:365});
};

function isBrowserBad(){
	return !jQuery.support.opacity;
 //return ret;
};




function loadDownload(path){
	// the goal of this function is to add a check on the download side in the legal page, kim set the specs such that the files need to be visible.
	// so instead of password protecting them upfront, we'll go to security after the user clicks on the file. It ain't secure
	
	if($.cookie('ifcaLogIn') == 'user' || $.cookie('ifcaLogIn') == 'admin' ){
		document.location.href = path;
	}else{ 
		//show security.
		$(".securityPanelLegal").fadeIn('fast');
	}

	
	
	//window.location.replace(path);
}








function loadAlbums(){
	
	galleryPath = "z_photoBookGalleries/";
	ajaxObj = getAjaxObj();
	ajaxObj.onreadystatechange=function()	// this catches the change in the object's stat
	 {
	  if (ajaxObj.readyState==4 && ajaxObj.status==200)	// here we check to see if the object is DONE.
	    {
	   	// replace the content of the thumb div with our results.
	   		$(".pageBody").html(ajaxObj.responseText);
	   		$('.pageBody').jScrollPane({hideFocus : true});
	    }
	  }
	 //ajaxReq.open("GET","php/bdForm.php?q="+theN,true); // (type of command,file to get, asynchronous);
	 ajaxObj.open("GET","utility_php/loadAlbums.php?q="+galleryPath,true);
	 ajaxObj.send(); // runs command.

}


function loadEvents(){
	
	var textRet ='(';
	
	if($('#filterOne').prop('checked') == true){
		textRet += "1";
	}
	if($('#filterTwo').prop('checked') == true){
		if(textRet.length > 1){
			textRet += ", 2";
		}else{textRet += "2";}
		
	}
	if($('#filterThree').prop('checked') == true){
		if(textRet.length > 1){
			textRet += ",";
		}
		textRet += "3";
	}
	if($('#filterFour').prop('checked') == true){
		if(textRet.length > 1){
			textRet += ",";
		}
		textRet += "4";
	}
	if($('#filterFive').prop('checked') == true){
		if(textRet.length > 1){
			textRet += ",";
		}
		textRet += "5";
	}

		
	textRet +=")";
	
	
	// get the filter:
	var filter = '';
	
	if(textRet == "()"){
		filter = '';
	}else{
		filter = textRet;
	}
	
	$('#scrollingBox').fadeOut('fast');
	
	ajaxObj = getAjaxObj();
	ajaxObj.onreadystatechange=function()	// this catches the change in the object's stat
	 {
	  if (ajaxObj.readyState==4 && ajaxObj.status==200)	// here we check to see if the object is DONE.
	    {
	   	// replace the content of the thumb div with our results.
	   		$("#events").html(ajaxObj.responseText);
	   		//$('.pageBody').jScrollPane({hideFocus : true});
	   		
	   		$('#scrollingBox').fadeIn('fast', function(){$('#scrollingBox').jScrollPane({hideFocus : true});} );
	   		
	    }
	  }
	 //ajaxReq.open("GET","php/bdForm.php?q="+theN,true); // (type of command,file to get, asynchronous);
	 ajaxObj.open("GET","utility_php/loadEvent.php?q="+filter,true);
	 ajaxObj.send(); // runs command.

}









// populates the thumb objects and shows the gallery.
function runGalleryFor(galleryPath){
	//if(loadGalleryThumbs(galleryPath) == true){
		//if(loadGalleryImages(galleryPath)  == true){
		loadGalleryTitle(galleryPath);
		//loadGalleryThumbs(galleryPath);
		
			
			
		//}
	//}
}

function dismissGallery(){
	$('.gallery').fadeOut('fast', function(){
		$("#galleryThumbs").html(" ");
		$("#galleryView").html(" ");
	});
	
}


function loadGalleryThumbs(galleryPath){
		// assuming we have the connection to the Mysql database...
	ajaxObj = getAjaxObj();
	ajaxObj.onreadystatechange=function()	// this catches the change in the object's stat
	 {
	  if (ajaxObj.readyState==4 && ajaxObj.status==200)	// here we check to see if the object is DONE.
	    {
	   	// replace the content of the thumb div with our results.
	   		
	   		$("#galleryThumbs").html(ajaxObj.responseText);
			$(".photoFrame").css('opacity:0');
			//$(".photoFrame").fadeOut();
	   		$('.gallery').fadeIn('fast');
	   		
	   		
	   		var count = $('#galleryThumbs img').length * 116;
	   		$('#galleryThumbs').css({width: count});
	   		$('#galleryThumbsPanel').jScrollPane({hideFocus : true});//{contentWidth: count}
	   		//$('.jspPane').css({width: count});
	   		
	   		
	   		//css({width: count}).
	   		loadGalleryImages(galleryPath);
	   		
	    }
	  }
	 //ajaxReq.open("GET","php/bdForm.php?q="+theN,true); // (type of command,file to get, asynchronous);
	 ajaxObj.open("GET","utility_php/loadGalleryThumbs.php?q="+galleryPath,true);
	 ajaxObj.send(); // runs command.
}	

function loadGalleryTitle(galleryPath){
	ajaxObj = getAjaxObj();
	ajaxObj.onreadystatechange=function()	// this catches the change in the object's stat
	 {
	  if (ajaxObj.readyState==4 && ajaxObj.status==200)	// here we check to see if the object is DONE.
	    {
	   	// replace the content of the thumb div with our results.
	   		$("#albumName").html(ajaxObj.responseText);
	   		//$(".photoFrame").fadeOut();
	   		loadGalleryThumbs(galleryPath);
	   		
	    }
	  }
	 //ajaxReq.open("GET","php/bdForm.php?q="+theN,true); // (type of command,file to get, asynchronous);
	 ajaxObj.open("GET","utility_php/loadGalleryTitle.php?q="+galleryPath,true);
	 ajaxObj.send(); // runs command.
}

function loadGalleryImages(galleryPath){
		// assuming we have the connection to the Mysql database...
	ajaxObj = getAjaxObj();
	ajaxObj.onreadystatechange=function()	// this catches the change in the object's stat
	 {
	  if (ajaxObj.readyState==4 && ajaxObj.status==200)	// here we check to see if the object is DONE.
	    {
	   	// replace the content of the thumb div with our results.
	   		$("#galleryView").html(ajaxObj.responseText);
	   		//$(".photoFrame").fadeOut();
	   		
	   		
	   		galleryShowFirst();
	    }
	  }
	 //ajaxReq.open("GET","php/bdForm.php?q="+theN,true); // (type of command,file to get, asynchronous);
	 ajaxObj.open("GET","utility_php/loadGalleryImages.php?q="+galleryPath,true);
	 ajaxObj.send(); // runs command.
}

function galleryGoToSlide(slideID){
	$(".photoFrame[style*='opacity: 1']").animate({opacity:'0'}, 300, function(){
	//var theTarget = $(slideID);
		$("#"+slideID+".photoFrame").animate({opacity:'1'}, 300);
	});
}

function galleryShowFirst(){
	//$(".photoFrame").fadeOut(function(){$('.gallery').fadeIn('slow');});
	$('.photoFrame').css("opacity","0");
	//$('#galleryThumbsPanel').fadeIn("slow");
	$(".photoFrame").first().animate({opacity:'1'}, 300);
	//{ fontSize: "24px" }, 1500
}

function galleryNext(){
	if( $(".photoFrame[style*='opacity: 1']").next().length == 0){
		$(".photoFrame[style*='opacity: 1']").css("opacity","0");
		$(".photoFrame").first().animate({opacity:'1'}, 300);
	}else{
		var tert = $(".photoFrame[style*='opacity: 1']").next().attr('id');
		galleryGoToSlide(tert);
	}
}

function loadQuickLinks(){
	ajaxObj = getAjaxObj();
	ajaxObj.onreadystatechange=function()	// this catches the change in the object's stat
	 {
	  if (ajaxObj.readyState==4 && ajaxObj.status==200)	// here we check to see if the object is DONE.
	    {
	   	// replace the content of the thumb div with our results.
	   		$(".quickLinks").html(ajaxObj.responseText);
	   		$('.quickLinks .quickLink:first').fadeIn(1000);//, function() {
        	//$('.quickLinks').cycle({fx:'fade', speed:500 });
    		//});
	    }
	  }
	 //ajaxReq.open("GET","php/bdForm.php?q="+theN,true); // (type of command,file to get, asynchronous);
	 ajaxObj.open("GET","utility_php/loadQuickLinks.php",true);
	 ajaxObj.send(); // runs command.

}


function closeFFAViewer(){
	$('#ffa').fadeOut('fast', function(){
		$('#ffaContent').html(' ');
	});
	
}


function openFFAViewer(){

	$('#ffaContent').html("<object width='600' height='345'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=17290960&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=17290960&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='600' height='345'></embed></object>");
	$('#ffa').fadeIn('slow');	
}


// _________________________________________________________________________________________________
	// security Section
// _________________________________________________________________________________________________


/// utilities
// modularized ajax object creation to avoid messy updates in future.
function getAjaxObj(){
	var ajaxReq;
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  ajaxReq=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5... this will be broken  down later but for now we leave it in.
	  ajaxReq=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 return ajaxReq;
}



