var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0
var tempY = 0
function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
	tempX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    tempY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  return true
}


function urlencode (str) {
    var hexStr = function (dec) {
        return '%' + dec.toString(16).toUpperCase();
    };
 
    var ret = '',
    unreserved = /[\w.-]/; // A-Za-z0-9_.- // Tilde is not here for historical reasons; to preserve it, use rawurlencode instead
    str = (str+'').toString();
 
    for (var i = 0, dl = str.length; i < dl; i++) {
        var ch = str.charAt(i);
        if (unreserved.test(ch)) {
            ret += ch;
        }
        else {
            var code = str.charCodeAt(i);
            // Reserved assumed to be in UTF-8, as in PHP
            if (code === 32) {
                ret += '+'; // %20 in rawurlencode
            }
            else if (code < 128) { // 1 byte
                ret += hexStr(code);
            }
            else if (code >= 128 && code < 2048) { // 2 bytes
                ret += hexStr((code >> 6) | 0xC0);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 2048 && code < 65536) { // 3 bytes
                ret += hexStr((code >> 12) | 0xE0);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 65536) { // 4 bytes
                ret += hexStr((code >> 18) | 0xF0);
                ret += hexStr(((code >> 12) & 0x3F) | 0x80);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
        }
    }
    return ret;
}
function show_all_icons () {
	linkbox = document.getElementById('sp_soclink_box');
	wbox = document.getElementById('sp_soclink_widget');
	wbox.style.visibility = 'hidden';
	ww = GetWidth();
	
	if (ww && (tempX>(ww/2))) {
		linkbox.style.left = (tempX-250)+'px';
	} else {
		linkbox.style.left = (tempX-20)+'px';
	}
	linkbox.style.top = (tempY-10)+'px';
	linkbox.style.visibility = 'visible';
}
function email_success () {
	ef = document.getElementById('sp_soc_email_form_span');
	ef.innerHTML = '<br /><br />Thank you!<br /><br />Your message has been sent<br /><br /><br />';
	sp_soclink_click_track('email');
	setTimeout('hide_widget()',2000);
}
function hide_widget () {
	wbox = document.getElementById('sp_soclink_widget');
	wbox.style.visibility = 'hidden';
}

function hide_soc_box () {
	wbox = document.getElementById('sp_soclink_box');
	wbox.style.visibility = 'hidden';
}
function email_error (errormsg) {
	ef = document.getElementById('sp_soc_email_form_err');
	ef.innerHTML = errormsg;
}
function check_fields_submit (f1,f2) {
	e1 = echeck (f1);
	e2 = echeck (f2);
	
	if (!e1 && !e2){
		email_error ("Both email addresses are invalid");
		return false;
	} else if (!e1 && e2) {
		email_error ("<strong>From</strong> email address is invalid");
		return false;
	} else if (e1 && !e2) {
		email_error ("<strong>To</strong> email address is invalid");
		return false;
	} else if (e1 && e2) {
		return true;
	}
	return false;
}
function GetWidth()
{
        var x = 0;
        if (self.innerHeight) {
                x = self.innerWidth;
        } else if (document.documentElement && document.documentElement.clientHeight) {
                x = document.documentElement.clientWidth;
        } else if (document.body) {
                x = document.body.clientWidth;
        }
		return x;
}

function show_widget (wname,url,title) {
	linkbox = document.getElementById('sp_soclink_box');
	linkbox.style.visibility = 'hidden';
	wcnt = document.getElementById('sp_soclink_widget');
	wbox = document.getElementById('sp_soclink_widget_content');
	
	if (wname == 'email') {
		wboxcode = "<span id=\"sp_soc_email_form_span\"><form action=\"http://www.superpages.com/inc/social/soc_email.php\" method=\"post\" name=\"sp_soclink_wemail\" target=\"sp_soc_widget_iframe\" id=\"sp_soclink_wemail\"><span id=\"sp_soc_email_form_err\"></span><p>From:&nbsp;<input name=\"sp_soc_wemail_from\" type=\"text\" id=\"sp_soc_wemail_from\" onblur=\"field_check(this.value,this)\" /><br />  <br />To:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"sp_soc_wemail_to\" type=\"text\" id=\"sp_soc_wemail_to\" onblur=\"field_check(this.value,this)\" /><br /><br />Message:<br /><textarea wrap=\"soft\" name=\"sp_soc_wemail_msg\" id=\"sp_soc_wemail_msg\">I thought you might like this: "+ title +" - "+ url +"</textarea><br /><br /><input name=\"Send message\" type=\"submit\" id=\"Send Message\" value=\"Send Message\" onclick=\"if (check_fields_submit(this.form.sp_soc_wemail_from.value, this.form.sp_soc_wemail_to.value)) { setTimeout('email_success()',200); } else { return false; }\" /><br /></p></form></span><iframe src=\"soc_blank.php\" name=\"sp_soc_widget_iframe\" scrolling=\"auto\" frameborder=\"no\" height=\"1\" width=\"1\" style=\"height:1px; width:1px; border:none;\"></iframe>";
	} 
	wbox.innerHTML = wboxcode;
	ww = GetWidth();
	
	if (ww && (tempX>(ww/2))) {
		wcnt.style.left = (tempX-250)+'px';
	} else {
		wcnt.style.left = (tempX-20)+'px';
	}
	wcnt.style.top = (tempY-10)+'px';
	wcnt.style.visibility = 'visible';
}
function mouseLeaves (element, evt) {
	if (typeof evt.toElement != 'undefined' && typeof element.contains !=
	'undefined') {
	return !element.contains(evt.toElement);
	}
	else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
	return !contains(element, evt.relatedTarget);
	}
}

function contains (container, containee) {
	while (containee) {
	if (container == containee) {
	return true;
	}
	containee = containee.parentNode;
	}
	return false;
	}
	function hideElement (element) {
	if (element.style) {
	element.style.visibility = 'hidden';
	}
}

function showElement (element) {
	if (element.style) {
	element.style.visibility = 'visible';
	}
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true					
	}

function field_check (txt,field) {
	if (txt) {
		if (echeck (txt)) {
			field.style.border = '1px solid #009933';
			field.style.backgroundColor = '#DCFFE5';
		} else {
			field.style.border = '1px solid #CC0000';
			field.style.backgroundColor = '#FFD0D0';
		}
	} else {
		field.style.border = '1px solid #666666';
		field.style.backgroundColor = '#FFFFFF';
	}
}

var s_account = '';
if (window.location.hostname == 'spdev.superpages.com' || window.location.hostname == 'sptest.superpages.com') {
	s_account = 'superpagesdev';
} else {
	s_account = 'superpagescom';
}

function sp_soclink_click_track(itemname) {
	var s=s_gi(s_account);
	
	s.linkTrackVars='eVar13,events';
	s.linkTrackEvents='event26';
	s.events='event26'; 	s.eVar13='BP:Action:Share:'+itemname; 
	s.tl(this,'o','Link Name');
}






document.write("<div id=\"sp_soclink_wrapper\"><ul>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('Facebook')\" href=\"http://www.superpages.com/inc/social/sln.php?n=2&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Share to Facebook\"><img src=\"http://img.superpages.com/social_icons/1/16/facebook.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Share to Facebook\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('Twitter')\" href=\"http://www.superpages.com/inc/social/sln.php?n=3&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Share to Twitter\"><img src=\"http://img.superpages.com/social_icons/1/16/twitter.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Share to Twitter\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('Digg')\" href=\"http://www.superpages.com/inc/social/sln.php?n=4&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Digg This\"><img src=\"http://img.superpages.com/social_icons/1/16/digg.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Digg This\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('Google Bookmarks')\" href=\"http://www.superpages.com/inc/social/sln.php?n=5&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Add to Google Bookmarks\"><img src=\"http://img.superpages.com/social_icons/1/16/google.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Add to Google Bookmarks\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('Yahoo Buzz')\" href=\"http://www.superpages.com/inc/social/sln.php?n=6&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Buzz This\"><img src=\"http://img.superpages.com/social_icons/1/16/buzz.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Buzz This\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('Windows Live')\" href=\"http://www.superpages.com/inc/social/sln.php?n=7&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Bookmark this on Live\"><img src=\"http://img.superpages.com/social_icons/1/16/live.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Bookmark this on Live\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('StumbleUpon')\" href=\"http://www.superpages.com/inc/social/sln.php?n=8&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"StumbleUpon This\"><img src=\"http://img.superpages.com/social_icons/1/16/stumbleupon.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"StumbleUpon This\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('Del.icio.us')\" href=\"http://www.superpages.com/inc/social/sln.php?n=9&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Add to Del.icio.us\"><img src=\"http://img.superpages.com/social_icons/1/16/delicious.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Add to Del.icio.us\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><a target=\"_blank\" onclick=\"sp_soclink_click_track('Reddit')\" href=\"http://www.superpages.com/inc/social/sln.php?n=10&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Add to Reddit\"><img src=\"http://img.superpages.com/social_icons/1/16/reddit.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Add to Reddit\" /></a></li>");
document.write("<li class=\"sp_soclink_ic16\"><img src=\"http://img.superpages.com/social_icons/spacer.gif\" border=\"0\" width=\"1\" height=\"16\" /><a href=\"javascript:;\" onclick=\"show_all_icons(this.event);\">More &gt;</a></li>");
document.write("</ul></div>");
document.write("<div id=\"sp_soclink_widget\" style=\"visibility:hidden;\"><a href=\"javascript:;\" onclick=\"hide_widget()\"><img src=\"http://img.superpages.com/social_icons/x.gif\" height=\"14\" width=\"14\" border=\"0\" align=\"right\" /></a><br /><span id=\"sp_soclink_widget_content\"></span></div>");
document.write("<div id=\"sp_soclink_box\" style=\"visibility:hidden;\" onmouseout=\"if (mouseLeaves(this, event)) { hideElement(this); }\"><a href=\"javascript:;\" onclick=\"hide_soc_box()\"><img src=\"http://img.superpages.com/social_icons/x.gif\" height=\"14\" width=\"14\" border=\"0\" align=\"right\" style=\"margin-bottom:-14px;\" /></a><br /><div><a href=\"javascript:;\" onclick=\"show_widget('email',location.href,document.title)\" title=\"Email This\"><img src=\"http://img.superpages.com/social_icons/1/16/email.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Email This\" /> Email</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('Facebook')\" href=\"http://www.superpages.com/inc/social/sln.php?n=2&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Share to Facebook\"><img src=\"http://img.superpages.com/social_icons/1/16/facebook.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Share to Facebook\" /> Facebook</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('Twitter')\" href=\"http://www.superpages.com/inc/social/sln.php?n=3&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Share to Twitter\"><img src=\"http://img.superpages.com/social_icons/1/16/twitter.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Share to Twitter\" /> Twitter</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('Digg')\" href=\"http://www.superpages.com/inc/social/sln.php?n=4&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Digg This\"><img src=\"http://img.superpages.com/social_icons/1/16/digg.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Digg This\" /> Digg</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('Google Bookmarks')\" href=\"http://www.superpages.com/inc/social/sln.php?n=5&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Add to Google Bookmarks\"><img src=\"http://img.superpages.com/social_icons/1/16/google.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Add to Google Bookmarks\" /> Google Bookmarks</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('Yahoo Buzz')\" href=\"http://www.superpages.com/inc/social/sln.php?n=6&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Buzz This\"><img src=\"http://img.superpages.com/social_icons/1/16/buzz.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Buzz This\" /> Yahoo Buzz</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('Windows Live')\" href=\"http://www.superpages.com/inc/social/sln.php?n=7&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Bookmark this on Live\"><img src=\"http://img.superpages.com/social_icons/1/16/live.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Bookmark this on Live\" /> Windows Live</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('StumbleUpon')\" href=\"http://www.superpages.com/inc/social/sln.php?n=8&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"StumbleUpon This\"><img src=\"http://img.superpages.com/social_icons/1/16/stumbleupon.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"StumbleUpon This\" /> StumbleUpon</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('Del.icio.us')\" href=\"http://www.superpages.com/inc/social/sln.php?n=9&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Add to Del.icio.us\"><img src=\"http://img.superpages.com/social_icons/1/16/delicious.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Add to Del.icio.us\" /> Del.icio.us</a></div><div><a target=\"_blank\" onclick=\"sp_soclink_click_track('Reddit')\" href=\"http://www.superpages.com/inc/social/sln.php?n=10&t="+ urlencode(document.title) +"&u="+ urlencode(location.href) +"&s=1\" title=\"Add to Reddit\"><img src=\"http://img.superpages.com/social_icons/1/16/reddit.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"Add to Reddit\" /> Reddit</a></div></div>");