﻿var expDays = 1000;
var site_dom = '';

// cookie functions
function SetCookie( name, value, expires, path, domain, secure )
{
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) expires = expires * 1000 * 60 * 60 * 24;
	var expires_date = new Date( today.getTime() + ( expires ) );
	document.cookie = name + "=" + escape( value ) + 
										( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
										( ( path ) ? ";path=" + path : "" ) + 
										( ( domain ) ? ";domain=" + domain : "" ) + 
										( ( secure ) ? ";secure" : "" );
}
function GetCookie( name )
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( !start && name != document.cookie.substring( 0, name.length ) ) {
		return null;
	}
	if( start == -1 ) {
		return null;
	}
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) {
		end=document.cookie.length;
	}
	return unescape( document.cookie.substring( len, end ) );
}
function DeleteCookie( name, path, domain )
{
	var exp = new Date();  
	exp.setTime( exp.getTime() - 1 ); 
	if ( GetCookie( name ) )
	{
		document.cookie = name + "=" + ( path ? ";path=" + path : "" ) +
											( domain ? ";domain=" + domain : "" ) + 
											";expires=" + exp.toGMTString();
	}
}
// end cookie functions

function set_homepage()
{
	style.behavior='url(#default#homepage)';
	setHomePage(self.location.toString());
}

function add_bookmark()
{
	var url = self.location.toString();
	var title = document.title;
	if ( document.all ) {
		window.external.AddFavorite( url, title );
	} else if ( window.sidebar ) {
		window.sidebar.addPanel( title, url, "" );
	}
	return;
}

function fbs_click(u, t)
{
//	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'fbsharer','toolbar=0,status=0,width=626,height=436');
    var options = 'scrollbars=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes,location=yes';    
    options += ',width=' + screen.availWidth + ',height=' + screen.availHeight;    
    options += ',screenX=0,screenY=0,top=0,left=0';    
    var win = window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'fbsharer', options);    
    win.focus();    
    win.moveTo(0, 0); 	
}

function twits_click(u, t)
{
//	window.open('http://twitter.com/home?status='+encodeURIComponent(t)+ ' ' + encodeURIComponent(u),'twittersharer','toolbar=0,status=0,width=626,height=436');
    var linklength= u.length+1
    var slimit
    if (140<=linklength) {
        slimit=0;
    }
    else {
        slimit=140-linklength;
    }
    t=t.substr(0,slimit)
    var options = 'scrollbars=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes,location=yes';    
    options += ',width=' + screen.availWidth + ',height=' + screen.availHeight;    
    options += ',screenX=0,screenY=0,top=0,left=0';    
    var win = window.open('http://twitter.com/home?status='+encodeURIComponent(t)+' '+encodeURIComponent(u),'twittersharer', options);    
    win.focus();    
    win.moveTo(0, 0); 	
}

function lives_click(u, t, d)
{
	window.open('http://spaces.live.com/BlogIt.aspx?Title='+encodeURIComponent(t)+'&SourceURL='+encodeURIComponent(u)+'&description='+encodeURIComponent(d),'livesharer','toolbar=0,status=0,width=626,height=436');
}
