 /*JavaScript Document*/
/*$(document).ready(
				  function(){alert("hi");
							}
					);
*/

function addit_index()
{
	
addthis_pub             = 'hoyes'; 
addthis_logo            = 'http://search.nautalex.com/hoyes_site/asset/images/addit.gif';
addthis_logo_background = 'EFEFFF';
addthis_logo_color      = '666699';
addthis_brand           = 'Hoyes.com';
addthis_options         = 'favorites, email, myspace, facebook, google, live,delicious, digg,technorati,myweb,ask,twitter,more';

document.write("<a href='http://www.addthis.com/bookmark.php' onmouseover=\"return addthis_open(this, '', '[URL]', '[TITLE]')\" onmouseout='addthis_close()' onclick='return addthis_sendto()' class='tool1'>share</a>");

}


//removes leading and trailing spaces in the string passed in.
function trim( string_to_trim )
{ 
  while (string_to_trim.charAt(0) == " ")
  { 
    // remove leading spaces 
    string_to_trim = string_to_trim.substring(1); 
  } 
  
  while (string_to_trim.charAt(string_to_trim.length - 1) == " ")
  { 
    // remove trailing spaces 
    string_to_trim = string_to_trim.substring(0,string_to_trim.length - 1); 
  } 
  
  return string_to_trim; 
} 



//brings up the "email page to a friend" window
function emailToFriend( )
{
	var url=document.URL; 
	var popupwindowurl = "functions/email-to-friend.php?url="+url; 
	window.open(popupwindowurl,'','scrollbars=no,resizable=no,width=440,height=340');
}

//Add to Favourites window
function bookmarkPage( ) 
{
	var url=document.URL;
	var title=document.title;
	
	if (window.sidebar) // firefox
	{ 
		window.sidebar.addPanel(title, url,"");
    }
	else if (document.all)  // IE
	{
		window.external.AddFavorite(url, title);
    }
	else
	{
    	return true;
	}
	
}

//Opens an html page in a printer friendly version and pops up the print window at the same time
function openForPrinting()
{ 
	var display_setting="toolbar=yes, location=no, directories=no, menubar=yes,"; 
    	display_setting+="scrollbars=yes, width=800, height=600, left=50, top=5"; 
  
	var print_content=document.getElementById("print-content").innerHTML; 
	//var print_content="123";
  	var new_page_title=document.title;
  
  	var popup_window=window.open("","",display_setting); 
   	popup_window.document.open(); 
   	popup_window.document.write('<html><head>');
   	popup_window.document.title=new_page_title;
   	popup_window.document.write('<link href="css/print.css" type="text/css" rel="stylesheet" />');
 

   	//popup_window.document.write('<link href="http://www.hoyes.com/blog_styles.css" type="text/css" rel="stylesheet" />');
	popup_window.document.write('</head><body onload="self.print()">');          
   	popup_window.document.write('<p class="print-window-comment">Make a Plan: Call <i>Hoyes Michalos &amp; Associates Inc.</i> at <b>310-PLAN</b> today and arrange for a free initial consultation.</p>');
   	popup_window.document.write(print_content);
   	popup_window.document.write('</body></html>'); 
   	popup_window.document.close(); 		//closes the document for writing
   	popup_window.focus(); 

}

function popupDirections(windowName)
{
	var display_setting="toolbar=yes, location=yes, directories=yes, menubar=yes,"; 
    	display_setting+="resizable=yes, scrollbars=yes, width=900, height=700, left=100, top=0"; 
	
	window.open("", windowName, display_setting);
}

// delaying the print pop-up window to give time Google maps to load first
var timer;

function loopTillPrintAnchorShows() {
	//alert("test before if and before print");
	if (document.getElementById("end")) {
		//alert("test after if, before print");
		window.print();
		clearInterval(timer);
	}    
}

function delayPrint()
{
	timer = setInterval('loopTillPrintAnchorShows()', 2000);
}

//show div passed in
function showControl(controlId)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		document.getElementById(controlId).style.visibility = "visible";
		document.getElementById(controlId).style.display = "block"; 
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		document.all[controlId].style.visibility = "visible";
		document.getElementById(controlId).style.display = "block"; 
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		document.layers[controlId].visibility = "visible";
		document.getElementById(controlId).style.display = "block"; 
	}
}

//hide div passed in
function hideControl(controlId)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		document.getElementById(controlId).style.visibility = "hidden";
		document.getElementById(controlId).style.display = "none"; 
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		document.all[controlId].style.visibility = "hidden";
		document.getElementById(controlId).style.display = "none"; 
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		document.layers[controlId].visibility = "hidden";
		document.getElementById(controlId).style.display = "none"; 
	}
}


function addslashes (str) {
    // Escapes single quote, double quotes and backslash characters in a string with backslashes  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/addslashes
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +   improved by: marrtins
    // +   improved by: Nate
    // +   improved by: Onno Marsman
    // +   input by: Denny Wardhana
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: addslashes("kevin's birthday");
    // *     returns 1: 'kevin\'s birthday'
 
    return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\u0000/g, "\\0");
}


