function $(i){return document.getElementById(i);}
function Menu(id){$(id).style.visibility='visible';}
function Hide(id){$(id).style.visibility='hidden';}
function Dog(id,i){$('pic'+id).src='i/dogs/t/'+id+'_'+i+'.jpg';}
function Swap(id1,id2){$(id1).style.display='none';$(id2).style.display='';}//only store
function Close(){
	var obj=document.getElementById('viewer');
	if(obj)obj.parentNode.removeChild(obj);
	document.body.style.overflow='visible';
}
function Full(url,gal){
	document.body.style.overflow='hidden';
	var d=document.createElement('div');
	d.id='viewer';
	d.onclick=Close;
	var code='<div><div>';
	code+='<img onclick="Close()" style="max-width:'+window.innerWidth+'px;max-height:'+(window.innerHeight-20)+'px;" src="'+url.replace(gal?'/t':'/t/',gal?'/':'/p/')+'"/><br/>';
	code+='click anywhere to return</div></div>';
	d.innerHTML = code;
	document.documentElement.appendChild(d);
}
function GuestCheck(max){
	var str=$('message').value.toLowerCase();
	var len=str.length;
	var msg=Math.abs(max-len)+' characters remain';
	var disable=true;
	if(len>max)msg='Your message is too long';
	else if(str.indexOf('http://')!=-1||str.indexOf('href=')!=-1)msg='Links are not permitted';
	else disable=false;
	$('length').innerHTML=msg;
	$('submit').disabled=disable;
}
function AppCheck(){
	var ids=['name','address','home','email'];
	var ret=true;
	for(var i=0;i<ids.length;i++){
		var obj=$(ids[i]);
		if(obj.value.length<1){ret=false;obj.className='error';}
		else obj.className='';
	}
	if(!ret)window.alert('You must complete the questions in red');
	else $('submit').disabled=true;
	return ret;
}
var curr=0;
function Gallery(x){
	curr+=x;
	if(curr<0)curr=pics.length-1;
	else if(curr>=pics.length)curr=0;
	$('img').src=pics[curr];
	$('count').innerHTML=(curr+1);
}
function OE(e,d){
	if(!d)d='nittanygreys.org';
	document.write('<a href="mailto:'+e+'@'+d+'">'+e+'@'+d+'</a>');
}
window.onload=function(){  
	var a=document.getElementsByTagName('a');
	for(var i=0;i<a.length;i++){
		if(a[i].getAttribute('rel')=='external')a[i].target='_blank';
	}
}
