//_____[ SMS ]_____\\

var sms = 
{
	build: function(title,callnumber,location,status)
	{
		var a = document.createElement('a');
		var im = document.createElement('img');
		im.setAttribute('src','http://library.bloomu.edu/voyager-sms/text.png');
		im.setAttribute('alt','sms icon');
		im.setAttribute('width','24');
		im.setAttribute('height','24');
		im.setAttribute('border','0');
                im.setAttribute('align','absmiddle');
		im.setAttribute('hspace','5');
		a.appendChild(im);
		
		var t = document.createTextNode('Text me this call number');
		a.appendChild(t);
		a.setAttribute('href','http://library.bloomu.edu/voyager-sms/eku-opac-sms.php?title='+title+'&callnumber='+callnumber+'&location='+location+'');
		//a.className = 'sms_opac';
               a.setAttribute('class','noborder');
	a.setAttribute('style','font-size: 85%; padding: 2px 0 2px 4px; text-decoration: none;');
		if(isIE())
		{
			a.setAttribute('target','_blank');
		}
		else
		{
			a.onclick = function()
			{
				window.open(this.getAttribute('href'),'','width=800,height=600,menubar=1,scrollbars=1,toolbar=1,resizable=yes');
				return false;
			};
		}
		return a;
	},
	
	set: function(i,title,callnumber,location,status)
	{
		if(!document.getElementById('call_number' + i)) return false;
		var sms_link = sms.build(record.encode(title),record.encode(callnumber),record.encode(location),record.encode(status));
		var sms_container = document.getElementById('call_number' + i);
		sms_container.appendChild(document.createTextNode(' \u2192'));
		sms_container.appendChild(sms_link);
	},
	
	init: function()
	{
		if(record.index.length == 0)
		{
			sms.set(0,record.title_short,record.callnumber[0],record.location[0],record.status[0]);
		}
		else
		{
			for(var j = 0; j < record.index.length; j++)
			{
				var x = record.index[j];
				sms.set(x,record.title_short,record.callnumber[x],record.location[x],record.status[x]);
			}
		}	
	}
}
// requires voyager-record.js
// requires record.init()
addLoadEvent(sms.init);

//_____[ STACK GUIDE ]_____\\

var stacks = 
{
	ranges: 
	{
		A : '3rd Floor',
		B : '3rd Floor',
		C : '3rd Floor',
		D : '3rd Floor',
		E : '3rd Floor',
		F : '3rd Floor',
		G : '3rd Floor',
		H : '3rd Floor',
		J : '3rd Floor',
		K : '3rd Floor',
		L : '3rd Floor',
		M : '3rd Floor',
		N : '3rd Floor',
		P : '4th Floor',
		PR : '4th Floor',
		PS : '4th Floor',
		PT : '4th Floor',
		PZ : '4th Floor',
		Q : '4th Floor',
		R : '4th Floor',
		S : '4th Floor',
		T : '4th Floor',
		U : '4th Floor',
		V : '4th Floor',
		Z : '4th Floor'
	},
	
	whichFloor: function(callnumber,location)
	{
		var letters, letter;
		if(location.indexOf('General Collection') != -1)
		{
			letters = callnumber.substr(0,2);
			letter = callnumber.substr(0,1);
			return (stacks.ranges[letters]) ? stacks.ranges[letters] : stacks.ranges[letter];
		}
		return location;
	}
}

// unfortunately...
//_____[ IE detection ]_____\\

function isIE()
{
	var agent = navigator.userAgent.toLowerCase();
	return (agent.indexOf('msie') != -1) ? true : false;
}
