
if (document.images){
 about_off = new Image; about_off.src = '/assets/img/nabout_off.gif';
 about_on = new Image; about_on.src = '/assets/img/nabout_on.gif';
 galleries_off = new Image; galleries_off.src = '/assets/img/ngalleries_off.gif';
 galleries_on = new Image; galleries_on.src = '/assets/img/ngalleries_on.gif';
 books_off = new Image; books_off.src = '/assets/img/nbooks_off.gif';
 books_on = new Image; books_on.src = '/assets/img/nbooks_on.gif';
 contact_off = new Image; contact_off.src = '/assets/img/ncontact_off.gif';
 contact_on = new Image; contact_on.src = '/assets/img/ncontact_on.gif';
 press_off = new Image; press_off.src = '/assets/img/npress_off.gif';
 press_on = new Image; press_on.src = '/assets/img/npress_on.gif';
 catalog_off = new Image; catalog_off.src = '/assets/img/ncatalog_off.gif';
 catalog_on = new Image; catalog_on.src = '/assets/img/ncatalog_on.gif';

}

function swap(name, state){

	document.images[name].src = eval (name + '_' + state + '.src');

}

function cat(name){

	document.cata.src=eval (name + '.src');
}

function nospam(user,domain) {

	status="mailto:" + user + "@" + domain;
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}
function pop(url){
	newWin = window.open(url,'zonwin','width=700,height=400,screenX=150,screenY=150,top=150,left=150,scrollbars=yes,toolbar=yes,statusbar=yes,menubar=yes,location=yes');
}
function pop2020(){
	theWin = window.open('press_2020.html','2020win','width=520,height=310,screenX=200,screenY=200,top=200,left=200,toolbar=no,statusbar=no,menubar=no,scrollbars=yes');
} 
function popUp(img, w, h){
	newWin = window.open('','windowname','width=' + w + ',height=' + h + ',screenX=150,screenY=150,top=150,left=150,toolbar=no,statusbar=no,menubar=no');
	newWin.document.write('<html><head><title>Image Style Detail - click to close</title></head>');
	newWin.document.write('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#000000">');
	newWin.document.write('<a href="javascript:window.close()" style="cursor:pointer;"><img src="/assets/img/' + img + '" border="0" alt="" title="Click to close window"></a></body></html>');
	newWin.document.close();
}

function catalog(current){

	console.log(current)

}

// tells links with rel="external" to open in a new window
function externalLinks () { 
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank"; 
		}
	}
}

$(document).ready(function(){
	
	if ($('#catalog').length > 0){
		$('#catalogLinks a').click(function(e){
			toShow = this.name;
			e.preventDefault();
			var triggers = $('#catalogImages div');
			//console.log(triggers);
			triggers.each(function(name,index){
				if (toShow == this.id){
					$(this).show();
				}else{
					$(this).hide();
				}
			});
			
		});
	}
	if ($('#gallery').length > 0){
		cats_off = new Image; cats_off.src='/assets/img/mg_cats_off.gif';
		cats_on = new Image; cats_on.src='/assets/img/mg_cats_on.gif';
		dogs_off = new Image; dogs_off.src='/assets/img/mg_dogs_off.gif';
		dogs_on = new Image; dogs_on.src='/assets/img/mg_dogs_on.gif';
		horses_off = new Image; horses_off.src='/assets/img/mg_horses_off.gif';
		horses_on = new Image; horses_on.src='/assets/img/mg_horses_on.gif';
		kids_off = new Image; kids_off.src='/assets/img/mg_kids_off.gif';
		kids_on = new Image; kids_on.src='/assets/img/mg_kids_on.gif';
		families_off = new Image; families_off.src='/assets/img/mg_families_off.gif';
		families_on = new Image; families_on.src='/assets/img/mg_families_on.gif';
		other_off = new Image; other_off.src='/assets/img/mg_other_off.gif';
		other_on = new Image; other_on.src='/assets/img/mg_other_on.gif';
		gallerycaption_off = new Image; gallerycaption_off.src='/assets/img/gallerycaption_off.gif';
		gallerycaption_on = new Image; gallerycaption_on.src='/assets/img/gallerycaption_on.gif';
		fineart_off = new Image; fineart_off.src='/assets/img/mg_fineart_off.gif';
		fineart_on = new Image; fineart_on.src='/assets/img/mg_fineart_on.gif';
	}
	if($('#index').length > 0){
		$('.slideshow').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
	}
});

function pressQuotes(args){
	$('#quotes div').each(function(index) {
		if (args == "2020" || args == "theView") { 
			args = "defaultText";
		}
		if (this.id == args ){
			$(this).show();
		}else{
			$(this).hide();
		}
	});
}
function pressLinks(){
	$('#pressLinksContainer a').each(function(index) {
		var link = $(this);
		link.click(function(e) { 
			e.preventDefault();
			src = this.id;
			targ = src.split("_");
			target = targ[1];
			pressQuotes(target);
			if(src == "tt_2020"){
				newWin = window.open('/assets/videos/pet1_small.mov',"2020vid","menubar=1,resizable=1,width=350,height=300");
			}else if (src == "t_theView"){
				newWin = window.open('/assets/videos/the_view_small.mov',"theViewVid","menubar=1,resizable=1,width=350,height=300");
			}
		});
	});
}
$(document).ready(function(){
	externalLinks();
	if ($('#press')){
		pressQuotes("defaultText");
		pressLinks();
	}
});