var tgb_resizeCurrentWindow = false;
var tgb_fullDisplay = 'false';
var tgb_default_open = false;

function tgbMoreBlogsOnload () {
	tgb_resizeCurrentWindow = true;
	tgbResizeWindow ();
}

function tgbCreateCookie(name,value,days) {
    var expires = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires="; expires="+date.toGMTString();
	}
	cookieString = name+"="+value+expires+"; path=/";
	document.cookie = cookieString;
}

function tgbReadCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function tgbCheckFullDisplay () {
   var refresh = true
   var value = tgbReadCookie ('tgb_fullDisplay')
   var tgb_toggleIt = false;
   var skipCookie = false;
   
   if (value != null) {
		if (value != tgb_fullDisplay) {
			tgb_toggleIt = true;
		}
   }
   else if (tgb_default_open) {
			tgb_toggleIt = true;
			skipCookie = true;
   }

         
   if (tgb_toggleIt) {
	   tgb_toggleDisplay (skipCookie)
	   refresh = false
   }
   
   if (refresh && tgb_resizeCurrentWindow) tgbResizeWindow ()
}   

function tgbResizeWindow() {
  var tgb_obj=document.all? document.all["tgb"] : document.getElementById? document.getElementById("tgb") : ""
  if( !tgb_obj) { return false; }

  var oH = tgb_obj.clip ? tgb_obj.clip.height : tgb_obj.offsetHeight; if( !oH ) { return false; }
  var oW = 520;
  
  window.resizeTo( oW , oH );
  var winwidth=tgb_ie&&!window.opera? tgb_ietruebody().clientWidth : window.innerWidth 
  var winheight=tgb_ie&&!window.opera? tgb_ietruebody().clientHeight : window.innerHeight
  var extra;
  
  if (tgb_ie) extra = 46;
  else extra = 20;
  window.resizeTo( oW +( ( oW ) - winwidth ), oH  + ( (oH) - winheight ) + extra );
  if( window.focus ) { window.focus(); }
  return false;
}

function tgb_newwindow (url, target) {
	window.open (url, target, "resizable=1, scrollbars=1, status=1,toolbar=1,titlebar=1, menubar=1, location=1")
} 

function tgb_moreblogs (url, target, height) {
	window.open (url, target, "width=215, height=" + height + ", resizable=1, scrollbars=0, status=0,toolbar=0,titlebar=0")
}

function tgb_profile (url, target, height) {
	window.open (url, target, "width=530, height=" + height + ", resizable=1, scrollbars=1, status=0, toolbar=1,titlebar=0")
}

/***********************************************
* Cool tgb_ tooltip script II- © Dynamic Drive tgb_ code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var tgb_offsetfromcursorX=14 //Customize x offset of tooltip
var tgb_offsetfromcursorY=20 //Customize y offset of tooltip

var tgb_offsetdivfrompointerX=14 //Customize x offset of tooltip DIV relative to pointer image
var tgb_offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

var tgb_ie=document.all
var tgb_ns6=document.getElementById && !document.all
var tgb_enabletip=false
if (tgb_ie||tgb_ns6)
var tgb_tipobj=document.all? document.all["tgb_tooltip"] : document.getElementById? document.getElementById("tgb_tooltip") : ""

var tgb_pointerobj1=document.all? document.all["tgb_pointer1"] : document.getElementById? document.getElementById("tgb_pointer1") : ""
var tgb_pointerobj2=document.all? document.all["tgb_pointer2"] : document.getElementById? document.getElementById("tgb_pointer2") : ""
var tgb_pointerobj3=document.all? document.all["tgb_pointer3"] : document.getElementById? document.getElementById("tgb_pointer3") : ""
var tgb_pointerobj4=document.all? document.all["tgb_pointer4"] : document.getElementById? document.getElementById("tgb_pointer4") : ""
var tgb_toolsobj=document.all? document.all["tgb_tools"] : document.getElementById? document.getElementById("tgb_tools") : ""
var tgb_tools_obj_pos = null

function tgb_findPos(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 tgb_ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function tgb_ddrivetip(thetext, thewidth, thecolor){
	return tgb_ddrivetip_ex(thetext, thewidth, thecolor);
}

function tgb_ddrivetip_ex(thetext, thewidth, thecolor){
	start  = thetext.indexOf ("<img src");
	
	if (start != -1) {
		start = thetext.indexOf ("><br>")
		statusText = thetext.substr (start + 5);
	}
	else {
		statusText = thetext;
	}
	statusText = statusText.replace ("<div class=\'tgb_date\'></div>", "");
    statusText = statusText.replace ("<div class=\'tgb_date\'>", ", updated:")
    statusText = statusText.replace ("<div class=\'tgb_tooltiptext\'>", " : ")
    statusText = statusText.replace ("<div class=\'tgb_hover_community\'>", " ( ")
    statusText = statusText.replace ("</div>", "")
    statusText = statusText.replace ("</div>", " )")
	self.status = statusText
	tgb_tools_obj_pos = tgb_findPos (tgb_toolsobj)	
	if (tgb_ns6||tgb_ie){
		if (typeof thewidth!="undefined") tgb_tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tgb_tipobj.style.backgroundColor=thecolor
		

		thetext2 = thetext;
		
		/*if (tgb_fullDisplay == 'true') {
			start  = thetext.indexOf ("<div class=\'tgb_date");
			
			if (start != -1)	{
				thetext2 = thetext.substr (start);
				thetext2 = thetext2.replace ("<div class=\'tgb_date\'>", "Last updated: <div class=\'tgb_date\'>")
			}
		}*/

		tgb_tipobj.innerHTML=thetext2
		tgb_enabletip=true
		document.onmousemove=tgb_positiontip
		return true
	}
	else
	    return false
}

function tgb_positiontip(e){
	if (tgb_enabletip){
		var leftpos = false
		var rightpos = false
		var toppos = false
		var bottompos = false
		var curX=(tgb_ns6)?e.pageX : event.clientX+tgb_ietruebody().scrollLeft;
		var curY=(tgb_ns6)?e.pageY : event.clientY+tgb_ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var winwidth=tgb_ie&&!window.opera? tgb_ietruebody().clientWidth : window.innerWidth-20
		var winheight=tgb_ie&&!window.opera? tgb_ietruebody().clientHeight : window.innerHeight-20
		
		var rightedge=tgb_ie&&!window.opera? winwidth-event.clientX-tgb_offsetfromcursorX : winwidth-e.clientX-tgb_offsetfromcursorX
		var bottomedge=tgb_ie&&!window.opera? winheight-event.clientY-tgb_offsetfromcursorY : winheight-e.clientY-tgb_offsetfromcursorY
		
		var leftedge=(tgb_offsetfromcursorX<0)? tgb_offsetfromcursorX*(-1) : -1000
		
		var tipoffset
		var pointeroffset
		
		if (!tgb_tools_obj_pos) tgb_tools_obj_pos = tgb_findPos (tgb_toolsobj)
		if (tgb_tools_obj_pos) {
			curX = curX - tgb_tools_obj_pos[0]
			curY = curY - tgb_tools_obj_pos[1]
		}

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge + 20 <tgb_tipobj.offsetWidth){
			//move the horizontal position of the menu to the left by it's width
			tipoffset = curX+tgb_offsetfromcursorX+tgb_offsetdivfrompointerX-tgb_tipobj.offsetWidth+rightedge-20
			pointeroffset = curX-tgb_offsetfromcursorX
			
			tgb_tipobj.style.left=tipoffset+"px"
			
			if (curX - tipoffset < tgb_tipobj.offsetWidth / 2) {
				tgb_pointerobj2.style.left= pointeroffset + 2*tgb_offsetfromcursorX + "px"
				tgb_pointerobj4.style.left= pointeroffset + 2*tgb_offsetfromcursorX + "px"
				leftpos=true
			}
			else {
			
			    if (tipoffset + tgb_tipobj.offsetWidth - 5< pointeroffset + tgb_offsetdivfrompointerX) {
					tipoffset = pointeroffset - tgb_tipobj.offsetWidth + tgb_offsetdivfrompointerX + 5;
					tgb_tipobj.style.left=tipoffset+"px"
			    }
				tgb_pointerobj1.style.left= pointeroffset+"px"
				tgb_pointerobj3.style.left= pointeroffset+"px"
			    rightpos = true
			}
		}
		else if (curX<leftedge) {
			tgb_tipobj.style.left="5px"
			tgb_pointerobj2.style.left=tgb_tipobj.style.left + tgb_offsetfromcursorX+"px"
			tgb_pointerobj4.style.left=tgb_tipobj.style.left + tgb_offsetfromcursorX+"px"
			leftpos=true;
		}
		else{
			//position the horizontal position of the menu where the mouse is positioned
			
			tipoffset = curX+tgb_offsetfromcursorX-tgb_offsetdivfrompointerX
			pointeroffset = curX+tgb_offsetfromcursorX

			tgb_tipobj.style.left= tipoffset+"px"
			tgb_pointerobj2.style.left=pointeroffset+"px"
			tgb_pointerobj4.style.left=pointeroffset+"px"
			leftpos=true;
		}
		
		//same concept with the vertical position
		if (bottomedge<tgb_tipobj.offsetHeight){
			tgb_tipobj.style.top=curY-tgb_tipobj.offsetHeight-tgb_offsetfromcursorY + "px"
			pointeroffset = curY-tgb_offsetfromcursorY - 1
			tgb_pointerobj3.style.top=pointeroffset+"px"
			tgb_pointerobj4.style.top=pointeroffset+"px"
			toppos = true
		}
		else{
			tgb_tipobj.style.top=curY+tgb_offsetfromcursorY+tgb_offsetdivfrompointerY + "px"
			pointeroffset = curY+tgb_offsetfromcursorY
			tgb_pointerobj2.style.top=pointeroffset+"px"
			tgb_pointerobj1.style.top=pointeroffset+"px"
			bottompos = true;
		}
		
		tgb_tipobj.style.visibility="visible"
		
		if (leftpos) {
		    if (bottompos) {
				tgb_pointerobj2.style.visibility="visible"
				tgb_pointerobj1.style.visibility="hidden"
				tgb_pointerobj3.style.visibility="hidden"
				tgb_pointerobj4.style.visibility="hidden"
			}
			else {
				tgb_pointerobj4.style.visibility="visible"
				tgb_pointerobj1.style.visibility="hidden"
				tgb_pointerobj2.style.visibility="hidden"
				tgb_pointerobj3.style.visibility="hidden"
			}
		}
		
		if (rightpos) {
		    if (bottompos) {
				tgb_pointerobj1.style.visibility="visible"
				tgb_pointerobj2.style.visibility="hidden"
				tgb_pointerobj3.style.visibility="hidden"
				tgb_pointerobj4.style.visibility="hidden"
			}
			else {
				tgb_pointerobj3.style.visibility="visible"
				tgb_pointerobj1.style.visibility="hidden"
				tgb_pointerobj2.style.visibility="hidden"
				tgb_pointerobj4.style.visibility="hidden"
			}
		}
	}
}

function tgb_hideddrivetip(){
	self.status = ''
	if (tgb_ns6||tgb_ie){
		tgb_enabletip=false
		tgb_tipobj.style.visibility="hidden"
		tgb_pointerobj1.style.visibility="hidden"
		tgb_pointerobj2.style.visibility="hidden"
		tgb_pointerobj3.style.visibility="hidden"
		tgb_pointerobj4.style.visibility="hidden"
		tgb_tipobj.style.left="-1000px"
		tgb_tipobj.style.backgroundColor=''
		tgb_tipobj.style.width=''
		document.onmousemove=null
		return true
	}
	else
		return true
}

var tgb_toggle_default1 = 'black'
var tgb_toggle_default2 = '#555'

var tgb_toggle = 'none'
var tgb_toggle_color = tgb_toggle_default1;

function tgb_set_toggle_defaults (default1, default2) {
	tgb_toggle_default1 = default1;
	tgb_toggle_default2 = default2;
	tgb_toggleDisplay ();
	tgb_toggleDisplay ();
}
		
function tgb_toggleDisplay (skipCookie) {
 	var elementArray = new Array();

	if (document.all) {
		elementArray = document.all;
	}
	else {
		elementArray = document.getElementsByTagName("*");
	}

	if (tgb_toggle == 'none') {
	   tgb_toggle = 'inline'
	   tgb_toggle_color = tgb_toggle_default2
	   tgb_fullDisplay = 'true';
	}
	else {
	   tgb_toggle = 'none'
	   tgb_toggle_color = tgb_toggle_default1
       tgb_fullDisplay = 'false'
	}
	
	for (var i = 0; i < elementArray.length; i++) {
		if (elementArray[i].className == 'tgb_blogTitle') {
		    elementArray[i].style.display = tgb_toggle
		}
		else if (elementArray[i].className == 'tgb_title') {
		    elementArray[i].style.color = tgb_toggle_color
		}
		else if (elementArray[i].className == 'tgb_less') {
		    elementArray[i].className = 'tgb_more'
		}
		else if (elementArray[i].className == 'tgb_more') {
		    elementArray[i].className = 'tgb_less'
		}
	}


    if (!skipCookie) {
		tgbCreateCookie ('tgb_fullDisplay', tgb_fullDisplay, 30)
	}
	
	if (tgb_resizeCurrentWindow == true) tgbResizeWindow ();

}

function tgbCheckFullDisplayAgain () {
   if (tgb_fullDisplay == 'true') {
      tgb_refreshTGB ()
   }
}   

function tgb_refreshTGB () {
	var elementArray = new Array();

	if (document.all) {
		elementArray = document.all;
	}
	else {
		elementArray = document.getElementsByTagName("*");
	}

	for (var i = 0; i < elementArray.length; i++) {
		if (elementArray[i].className == 'tgb_blogTitle') {
		    elementArray[i].style.display = tgb_toggle
		}
		else if (elementArray[i].className == 'tgb_title') {
		    elementArray[i].style.color = tgb_toggle_color
		}
		else if ((elementArray[i].className == 'tgb_less') && (tgb_fullDisplay == 'false')) {
		    elementArray[i].className = 'tgb_more'
		}
		else if ((elementArray[i].className == 'tgb_more') && (tgb_fullDisplay == 'true')) {
		    elementArray[i].className = 'tgb_less'
		}
	}
}

tgbCheckFullDisplay ()