//	AddToMethod	= [0=direct,1=popup]

var txtVersion = "0.1";
var addtoInterval = null;
var popupWin = '';

// Add To Bookmarks Layout Style
switch(addtoLayout){
	case 0:		// horizontal, 1 row
document.write('<div class="addToContent"><dl class="addTo"><dd><span title="Learn about Social Bookmarking" class="addToAbout" onclick');
document.write('="addto(0)">ADD TO:</span></dd><dd><span title="Add this page to Blink"  onclick="addto(1)"><img src="../images/addto_blin%27);%0Adocument.write(%27k.gif" width="16" height="16" border="0" />Blink</span></dd><dd><span title="Add this page to Delicious" onclick="addto');
document.write('(2)"><img src="../image-files/addto_delicious.gif" width="16" height="16" border="0" />Del.icio.us</span></dd><dd><span title="');
document.write('Add this page to Digg" onclick="addto(3)"><img src="../image-files/addto_digg.gif" width="16" height="16" border="0" />Digg</spa');
document.write('n></dd><dd><span title="Add this page to Furl" onclick="addto(4)"><img src="../image-files/addto_furl.gif" width="16" height="1');
document.write('6" border="0" />Furl</span></dd><dd><span title="Add this page to Google" onclick="addto(5)"><img src="../images/addto_goo%27);%0Adocument.write(%27gle.gif" width="16" height="16" border="0" />Google</span></dd><dd><span title="Add this page to Simpy" onclick="addto(');
document.write('6)"><img src="../images/addto_simpy.gif" width="16" height="16" border="0" />Simpy</span></dd><dd><span title="Add this pa');
document.write('ge to Spurl" onclick="addto(8)"><img src="../images/addto_spurl.gif" width="16" height="16" border="0" />Spurl</span></dd>');
document.write('<dd><span title="Add this page to Yahoo! MyWeb" onclick="addto(7)"><img src="../image-files/addto_yahoo.gif" width="16" height="');
document.write('16" border="0" />Y! MyWeb</span></dd></dl></div>');	
	break
	default:	
}
function addtoWin(addtoFullURL)
{
	if (!popupWin.closed && popupWin.location){
		popupWin.location.href = addtoFullURL;
		var addtoInterval = setInterval("closeAddTo();",1000);
	}
	else{
		popupWin = window.open(addtoFullURL,'addtoPopUp','width=770px,height=500px,status=0,location=0,resizable=1,scrollbars=1,left=0,top=100');
		var addtoInterval = setInterval("closeAddTo();",1000);
		if (!popupWin.opener) popupWin.opener = self;
	}
	if (window.focus) {popupWin.focus()}
	return false;
}
// closes the popupWin
function closeAddTo() {
	if (!popupWin.closed && popupWin.location){
		if (popupWin.location.href == AddURL)	//if it's the same url as what was bookmarked, close the win
		popupWin.close();
	}
	else {	//if it's closed - clear the timer
		clearInterval(addtoInterval)
		return true
	}
}
//main addto function - sets the variables for each Social Bookmarking site
function addto(addsite){
	switch(addsite){
		case 2:	//	Del.icio.us	ID:2 &v=3&noui=yes&jump=close
			var AddSite = "http://del.icio.us/post?";
			var AddUrlVar = "url";
			var AddTitleVar = "title";
			var AddNoteVar = "";
			var AddReturnVar = "";
			var AddOtherVars = "";		
			break
		case 3:	//	Digg ID:3
			var AddSite = "http://digg.com/submit?";
			var AddUrlVar = "url";
			var AddTitleVar =  "";
			var AddNoteVar =  "";
			var AddReturnVar =  "";
			var AddOtherVars = "&phase=2";
			break
			break
	}
//	Build the URL
	var addtoFullURL = AddSite + AddUrlVar + "=" + AddURL + "&" + AddTitleVar + "=" + AddTitle + AddOtherVars ;
	if (AddNoteVar != "") 
		{var addtoFullURL = addtoFullURL + "&" + AddNoteVar + "=" + AddTitle;}
	if (AddReturnVar != "")
		{var addtoFullURL = addtoFullURL + "&" + AddReturnVar + "=" + AddURL;}
//	Checking AddToMethod, to see if it opens in new window or not
	switch(addtoMethod){
		case 0:	// 0=direct link
			self.location = addtoFullURL
			break
		case 1:	// 1=popup
			addtoWin(addtoFullURL);
			break
		default:	
		}
		return true;
}
//	checking across domains causes errors - this is to supress these
function handleError() {return true;}
window.onerror = handleError;
