var
   zoom1=new Image(281,217),
   zoom2=new Image(281,217),
   zoom3=new Image(281,217),
   zoom4=new Image(281,217),
   zoom5=new Image(281,217),
   zoom6=new Image(281,217),
   zoom7=new Image(281,217),
   zoom8=new Image(281,217),
   zoom9=new Image(281,217),
   zoom10=new Image(281,217),
   zoom11=new Image(281,217),
   zoom12=new Image(281,217),
   abaoriginal='http://www.artbyallan.com/shared/aba-main.css',
   abaminimal='http://www.artbyallan.com/shared/aba-minimal.css',
   clicked=false,
   whichclicked=0,
   thumbref='',
   zoomref='',
   detailspanref='',
   cookie='',
   frontid=20,
   cleanalt='',
   tempalt='';
   
initStyle();
   
function initStyle(){
	cookie = readCookie("stylePref");
	
	if (cookie){
		applyStyle(cookie);	
	}
}
   
function init(){
	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") == "aba_external"){
			_anchor.target = "_blank";
		}
	}

   zoom1.src='images/artbyallan/zoom1.jpg';
   zoom2.src='images/artbyallan/zoom2.jpg';
   zoom3.src='images/artbyallan/zoom3.jpg';
   zoom4.src='images/artbyallan/zoom4.jpg';
   zoom5.src='images/artbyallan/zoom5.jpg';
   zoom6.src='images/artbyallan/zoom6.jpg';
   zoom7.src='images/artbyallan/zoom7.jpg';
   zoom8.src='images/artbyallan/zoom8.jpg';
   zoom9.src='images/artbyallan/zoom9.jpg';
   zoom10.src='images/artbyallan/zoom10.jpg';
   zoom11.src='images/artbyallan/zoom11.jpg';
   zoom12.src='images/artbyallan/zoom12.jpg';
}

function zoom(id){
	var
		detailref = document.getElementById('detail'),
		closeref = document.getElementById('closebtn'),
		closeglowref=document.getElementById('closeglow'),
		zoomtitleref=document.getElementById('zoomtitle'),
		zoomdivref=document.getElementById('zoom'),
		zoomtitletextref=document.getElementById('zoomtitletext');

	zoomref = document.getElementById('zoomimg');
	if(!clicked){
		if (id!='nil'){
			thumbref = document.getElementById('thumb'+id);
			cleanalt=thumbref.alt;
			zoomref.alt=cleanalt;
			tempalt=thumbref.alt+' :: click to lock';
			thumbref.alt=tempalt;
			detailspanref = document.getElementById('detail'+id);
			zoomref.src=eval('zoom'+id).src;
			zoomtitletextref.innerHTML='» ' + zoomref.alt;
			zoomdivref.style.visibility='visible';
			zoomref.style.visibility='visible';
			zoomtitleref.style.visibility='visible';
			thumbref.style.border='1px ridge #FFCC99';
			detailspanref.style.visibility='visible';
		}else{
			thumbref.style.border='1px solid #050006';
			zoomref.style.visibility='hidden';
			zoomtitleref.style.visibility='hidden';
			closeref.style.visibility='hidden';
			closeglowref.style.visibility='hidden';
			zoomref.src='images/artbyallan/blank.gif';
			zoomref.alt='';
			detailspanref.style.visibility='hidden';
			thumbref.alt=cleanalt;
		}
		bringToFront('zoom');
	}
}

function lockZoom(id){
	var closeglowref=document.getElementById('closeglow');
	if (!clicked){
		if (id!=whichclicked){
			closeglowref.style.visibility='visible';
		}
		closeref = document.getElementById('closebtn');
		closeglowref.style.visibility='hidden';
		closeref.style.visibility='visible';
		clicked=true;
		whichclicked=id;
	}else{
		if(id!=whichclicked){
			closeGlowBlink('on');
		}
	}
}

var
	groupCount=2;
	group=1;

function showTGroup(id){
	var
		hidegroup=document.getElementById('thumbnails'+group),
		showgroup=document.getElementById('thumbnails'+id);
	hidegroup.style.left='-321px';
	showgroup.style.left='0px';
	group=id;
}

function closeGlowBlink(state){
	var
		closeglowref=document.getElementById('closebtn'),
		glowTimeout='';
	if (state=='on'){
		closeglowref.style.border='1px inset #dedede';
		glowTimeout=setTimeout("closeGlowBlink('off')", 250);
	}else if(state=='off'){
		closeglowref.style.border='1px outset #dedede';
		glowTimeout=setTimeout("closeGlowBlink('done')", 250);
	}else if(state=='done'){
		closeglowref.style.border='1px inset #dedede';
		glowTimeout=setTimeout("closeGlowBlink()", 250);
	}else{
		closeglowref.style.border='1px outset #dedede';
	}
}


function closeZoom(){
	var
		zoomdiv=document.getElementById('zoom'),
		zoomimg=document.getElementById('zoomimg'),
		zoomtitleref=document.getElementById('zoomtitle'),
		closebtn=document.getElementById('closebtn'),
		closeglowref=document.getElementById('closeglow');
		
	zoomdiv.style.visibility='hidden';
	zoomimg.style.visibility='hidden';
	closebtn.style.visibility='hidden';
	zoomtitleref.style.visibility='hidden';
	closeglowref.style.visibility='hidden';
	thumbref.style.border='1px solid #050006';
	zoomref.src='images/artbyallan/blank.gif';
	zoomref.alt='';
	detailspanref.style.visibility='hidden';
	thumbref.alt=cleanalt;
	clicked=false;
}

var raquospanid = '';
function doraquo(id){
	var raquospan = document.getElementById('raquo'+id);
	if (id != null){
		raquospanid = id;
		raquospan.style.visibility = 'visible';
	}else{
		document.getElementById('raquo'+raquospanid).style.visibility = 'hidden';
	}
}

function infoAction(id, action){
	var
		infodiv=document.getElementById(id);
		
	if(action=='open'){
		infodiv.style.visibility='visible';
		if (id=='ifeatured'){
			infodiv.style.backgroundImage='url(http://www.artbyallan.com/images/artbyallan/featured.jpg)';
		}
		bringToFront(id);
	}else{
		infodiv.style.visibility='hidden';
	}
}

function bringToFront(id){
	var infodiv=document.getElementById(id);
	infodiv.style.zIndex=frontid;
	++frontid;
}

//begin google variables
var
	google_ad_client = "pub-3081924371457939",
	google_ad_width = 728,
	google_ad_height = 90,
	google_ad_format = "728x90_as",
	google_ad_channel ="4889344502",
	google_ad_type = "text",
	google_color_border = "050006",
	google_color_bg = "685A6A",
	google_color_link = "B69EB9",
	google_color_url = "F6F0FF",
	google_color_text = "F6F0FF";
//end google variables

var
	outSlide=1,
	inSlide='',
	i=0;
	
function slide(show){
	if(show){
		var
			outDiv = document.getElementById('thumbnails'+outSlide);
		inSlide=show;
		if (i<360){
			i=i+30;
			outDiv.style.left=i+'px';
			outTimeout=window.setTimeout("slide(inSlide)",15);
		}else{
			outSlide=inSlide;
			i=360;
			inTimeout=window.setTimeout("slide()",150);
			window.clearTimeout(outTimeout);
		}
	}else{
		var
			inDiv=document.getElementById('thumbnails'+inSlide);
		if(i>0){
			i=i-30;
			inDiv.style.left=i+'px';
			inTimeout=window.setTimeout("slide()",15);
		}else{
			window.clearTimeout(inTimeout);
		}
	}
}

function applyStyle(id){
	var stylesheetref = document.getElementById('mainstyle');
	if (document.getElementById('istyles')){
		var
			styledivref=document.getElementById('istyles');
		styledivref.style.visibility='hidden';
	}
	stylesheetref.href=id;
	writeCookie('stylePref', id, 365);
}

function writeCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/***********************************************
* Drag and Drop Script: © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0}
},
drag:function(e){
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (this.targetobj.className=="drag"){
this.dragapproved=1
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
return false
}
}
}

dragobject.initialize()
