/*************************************************************** 
 * Plugin Name: DM Albums									
 * Plugin URI: http://www.dutchmonkey.com/wp-plugins/
 * Description: In-Line Version of DM PhotoAlbums.
 * Author: Frank D. Strack
 * Author Email: frank@dutchmonkey.com
 * Author URI: http://www.dutchmokney.com
 ***************************************************************/

function Browser()
{
	this.ns40 			= ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4));
	this.ns50 			= ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 5));
	this.ie50 			= (navigator.appVersion.indexOf("MSIE 5") != -1);
	this.Exploiter		= ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4));
	this.platform 		= navigator.platform;
	this.UserAgent  	= navigator.userAgent;
	
	this.browser 		= (this.ns40 || this.ns50 || this.ie50 || this.Exploiter);
	
	this.netscape 		= this.ns40 || this.ns50;
	this.explorer 		= this.ie05 || this.Exploiter;
	this.Safari 		= (navigator.appVersion.indexOf("Safari") != -1);
	
	this.name 			= (navigator.appName == "Netscape" ? "Mozilla" : "Microsoft Internet Explorer");
	this.version 		= navigator.appVersion.indexOf("MSIE 5") != -1 ? 5 : parseInt(navigator.appVersion)

	this.macie5 		= ((this.platform == "MacPPC") && (this.version == 5) && (this.explorer));
	
	this.dhtml 			= (this.ns40 || this.macie5) ? false : (this.ns50 || this.ie50 || this.Exploiter || this.Safari);
	this.rollovers 		= this.browser || this.version >= 3;
	
	this.Width 			= function() { return ((navigator.appName == "Microsoft Internet Explorer" ? document.body.offsetWidth : window.innerWidth));}
	this.Height 		= function() { return ((navigator.appName == "Microsoft Internet Explorer" ? document.body.offsetHeight : window.innerHeight));}
	
	this.toString 		= _toString;
	
	this.setCookie 		= _WriteCookie;
	this.getCookie 		= _ReadCookie;
	
	this.Encode 		= _Encode;
	this.Decode 		= _Decode;
	
	this.GetPosition 	= _GetAbsolutePosition
	
	this.DOM			= _DOM;
	
	this.getCommonName 	= _GetCommonName;
	
	this.Report			= _Report;
	
	this.Clean			= _Clean;
		
	return true;
}

function _Decode(html)
{
	html = html.replace(/&amp;/g, "&");
	html = html.replace(/&quot;/g, "\"");
	html = html.replace(/&apos;/g, "\'");
	html = html.replace(/&lt;/g, "<");
	html = html.replace(/&gt;/g, ">");
	
	return html;
}

function _Encode(html)
{
	html = html.replace(/&/g, "&amp;");
	html = html.replace(/\"/g, "&quot;");
	html = html.replace(/\'/g, "&apos;");
	html = html.replace(/</g, "&lt;");
	html = html.replace(/>/g, "&gt;");
	
	return html;
}

function _Clean(s)
{
	s = s.replace(/[^\w\.-]+/g, "_")
	
	return s;
}

function _GetAbsolutePosition(obj) 
{ 
	var curleft = curtop = 0; 
	
	if (obj.offsetParent) 
	{ 
		curleft = obj.offsetLeft; 
		curtop = obj.offsetTop; 
		
		while (obj = obj.offsetParent) 
		{ 
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	} 
	
	return [curleft,curtop]; 
}

function _toString()
{
	var browser = String("");
	browser 	+= "this.browser = " + this.browser + "\n";
	browser 	+= "this.netscape = " + this.netscape + "\n";
	browser 	+= "this.explorer = " + this.explorer + "\n";
	browser 	+= "this.name = " + this.name + "\n";
	browser 	+= "this.version = " + this.version + "\n";
	browser     += "this.platform = " + this.platform + "\n";
	browser 	+= "this.ns40 = " + this.ns40 + "\n";
	browser 	+= "this.ns50 = " + this.ns50 + "\n";
	browser 	+= "this.ie50 = " + this.ie50 + "\n";
	browser 	+= "this.macie5 = " + this.macie5 + "\n";
	browser 	+= "this.Exploiter = " + this.Exploiter + "\n";
	browser 	+= "this.dhtml = " + this.dhtml + "\n";
	browser 	+= "this.rollovers = " + this.rollovers + "\n";
	
	return browser;
}	

function _GetCommonName()
{
	if(navigator.userAgent.indexOf("MSIE 7.0") != -1)
		return "Microsoft Internet Explorer 7.0 (supported).";
	else if(navigator.userAgent.indexOf("Firefox/2") != -1)
		return "Mozilla Firefox 2.0 (supported).";
	else if(navigator.userAgent.indexOf("Safari") != -1)
		return "Apple Safari 2.0 (supported).";
	else if(navigator.userAgent.indexOf("Firefox") != -1)
		return "Mozilla Firefox 1.0 (limmited support).";
	else
		return navigator.appName + " version " + parseInt(navigator.appVersion) + " (limited support).";
		
}

function _DOM()
{
	if(navigator.userAgent.indexOf("Safari") != -1)
		return false;
	else
		return true;
		
}

function _Report(id)
{
	//var browser = navigator.appName + " version " + parseInt(navigator.appVersion);
	document.getElementById(id).innerHTML = "You are using " + _GetCommonName();
}

function _WriteCookie(key, value, expires)
{
	if(!expires)	expires = new Date();
	
	document.cookie  = key + "=" + value + "; expires=" + expires.toGMTString() + "; path=/";
}

function _ReadCookie(key) 
{
	 var theCookie = "" + document.cookie;
	 
	 var ind = theCookie.indexOf(key);
	 
	 if(ind == -1 || key == "") return ""; 
	 
	 var ind1=theCookie.indexOf(';',ind);
	 
	 if(ind1 == -1) ind1=theCookie.length;
	  
	 return unescape(theCookie.substring(ind + key.length + 1,ind1));
}
