//******************************************************************************************
//
//  Common JavaScript functions for technofundo.com site
//  Author: Manish Hatwalne
//
//******************************************************************************************  		
		 // Common absolute URLs
   var urlBase = "http://www.technofundo.com/";
   //var urlBase = "http://www.geocities.com/technofundo/";
   //var szMoURL = "http://technofundo.com/m/i.wml";
       
   //var szDomain = "technofundo.com";
   var szMail = "technofundo@gmx.net";
   
   var urlHome 	 	= urlBase + "home.html";
   var urlLastest 	= urlBase + "latestblog.html";
   var urlTech 	 	= urlBase + "tech.html";
   var urlFun 	 	= urlBase + "fun.html";
   var urlHigh	 	= urlBase + "high.html";
   var urlAbout	 	= urlBase + "about.html";

   	   //Common image URLs
   var imgBase	 = urlBase + "images/";
   
   	   // site main link
   var lnkMain	 = '<a class="nav" href="' + urlBase + '" title="Welcome to technofundo site." target="_top"><b>&sect;</b></a>';
      	   //general...
   var szSpacer  = "&nbsp;|&nbsp;";
   var szSpacer1  = "&nbsp;&nbsp;";

//===========================================================================================

function putCounter(bJS)
{
	document.write('<!--WEBBOT bot="HTMLMarkup" startspan ALT="Site Meter" -->');
	if(1 == bJS)
	{
	    document.write('<scr' + 'ipt type="text/javascript" language="JavaScript">var site="sm9technofundo"</scr' + 'ipt>');
	    document.write('<scr' + 'ipt type="text/javascript" language="JavaScript1.2" src="http://sm9.sitemeter.com/js/counter.js?site=sm9technofundo"></scr' + 'ipt>');
	    document.write('<!-- Copyright (c)2000 Site Meter -->');
	 }
	 else
	 {
	    document.write('<a href="http://sm9.sitemeter.com/stats.asp?site=sm9technofundo" target="_top">');
	    document.write('<img src="http://sm9.sitemeter.com/meter.asp?site=sm9technofundo" alt="Site Meter" border=0></a>');
	 }
	 document.write('<!--WEBBOT bot="HTMLMarkup" Endspan -->');
}

function putCommentsScript(){
	document.write('<scr' + 'ipt src="http://js-kit.com/comments.js"></scr' + 'ipt>');
}

function addFooter(){
   var szText = "";
   
   	//put comments div
   szText += '<div class="js-kit-comments" label="Add Comments" paginate="10"></div>';
   
   szText += '<div class="navbar" align="center">';
   szText += '<center>';
   	
   szText += lnkMain;
   szText += szSpacer1;
   szText += '<a class="nav" href="' + urlHome + '">Home</a>';
   szText += szSpacer;
   szText += '<a class="nav" href="' + urlLastest + '">Latest</a>';
   szText += szSpacer;
   szText += '<a class="nav" href="' + urlTech + '">Technology</a>';
   szText += szSpacer;
   szText += '<a class="nav" href="' + urlFun + '">Fun/Leisure</a>';
   szText += szSpacer;    
   szText += '<a class="nav" href="' + urlAbout + '">About</a>';
   szText += szSpacer1;
   szText += lnkMain;
   
   szText += '</center>';
   szText += '</div>';
   szText += '<div align="center" style="font-size:10pt; font-family:verdana; color:#AAAAAA;"><center>';
   
   szText += 'Copyright &copy; 2001 - 2008, <a class="cpy" href="'+ urlAbout + '">Manish Hatwalne</a>.';
   szText += ' (Last Updated On - 7<sup> th</sup> Feb 2008)<br>';  
   szText += 'All trademarks are registered property of their respective owners.<br>';
   szText += 'This site is also hosted at <a href="http://www.technofundo.com" style="color:#0000ff">http://www.technofundo.com</a>.<br>';
   

   document.write(szText);
   szText = '</center></div>'
   	
   	//request comments script now
   putCommentsScript();
   	//put counter here
   putCounter(1);
   document.write(szText);
}

function getToday()
{
    var szToday="";
	var szMonths=new Array(12);  //for 12 months
    var szDays=new Array(7);	//for 7 weekdays
    var szDateSuffix="";

    szMonths[0]="January";
    szMonths[1]="February";
    szMonths[2]="March";
    szMonths[3]="April";
    szMonths[4]="May";
    szMonths[5]="June";
    szMonths[6]="July";
    szMonths[7]="August";
    szMonths[8]="September";
    szMonths[9]="October";
    szMonths[10]="November";
    szMonths[11]="December";

    szDays[0] = "Sunday";
    szDays[1] = "Monday";
    szDays[2] = "Tuesday";
    szDays[3] = "Wednesday";
    szDays[4] = "Thursday";
    szDays[5] = "Friday";
    szDays[6] = "Saturday";

    var time=new Date();

    var day=szDays[time.getDay()];
    var lmonth=szMonths[time.getMonth()];
    var date=time.getDate();
    var year=time.getYear();
	if (year<100)
	    year= "19" + time.getYear();
    else if(year >= 100 && year < 1000)
		 year= 1900 + time.getYear();  //needed for netscape
    else
		 year = time.getYear();
        
    szToday = day + ", " + lmonth + " " + date + ", " + year;
    return szToday;
}

function bookmarkSite()
{
	if (document.all)
	{
	  //alert(document.URL);
	  window.external.addFavorite(document.URL, "Manish's TechnoFunDo Site - " + document.title);
	}
	else
	{
	  alert("Please click Bookmarks, and choose \"Add Bookmark\" OR press CTRL + D for " + navigator.appName + ".");
	  //window.addCurrentPage(window.parent.location.href, "Manish's TechnoFunDo Site");
	}
}

function mailTF(szContact)
{
   document.write('<a href="mai'+ 'lto:'+ szContact + '<' + szMail + '>?subject=[' + szContact  + '] ">' + szContact + '</a>');
}

function mailTFDisp(szContact, szDisp)
{
   document.write('<a href="mai'+ 'lto:'+ szContact + '<' + szMail + '>?subject=[' + szContact  + '] ">' + szDisp + '</a>');
}

function mailTFSub(szContact, szDisp, szSub)
{
   document.write('<a href="mai'+ 'lto:'+ szContact + '<' + szMail + '>' + '?subject=' + szSub + '">' + szDisp + '</a>');
}

function getParam(szParam,szDocURL)
{
   var szString = szDocURL
   var szValueArray;
   var szValue = "";
   szParam = szParam + "=";
   szValueArray = szString.split(szParam);

   if(szValueArray.length > 1)
   {
	szValueArray1 = szValueArray[1].split("&");
	szValue = unescape(szValueArray1[0]);
	//alert(szValue);
   }
   return szValue;
}

function putBooksText()
{
   var szText = '<div style="font-family:verdana; font-size:14px;">Clicking on any one of these links will open a new window. You can purchase that particular title at Amazon.com ';
   szText +=    '(<a href="javascript:bookAlert();" title="Want to know more?"><b>?<\/b><\/a>).';
   szText += 	'<br><small>If you buy any of these books at Amazon.com by clicking these links, this site will get a small commission which helps covering the site expenses.<\/small><\/div>'
   document.write(szText);
}

function bookAlert()
{
    var szMessage = ' These books are presented in association with Amazon.com.\n All the books related transactions are taken care of by Amazon.com.';
    alert(szMessage);
}

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+ opera5
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

function addHeader(szTitle)
{
 		 //preload images
	var img1 = new Image();
	img1.src	  = imgBase + "tf.jpg"; 
	var img2 = new Image();
	img2.src	  = imgBase + "tf1.jpg";
	
				 // no frames
	//if(top != self)
	//{ top.location.replace(document.URL); }
	
	
	if(-1 != (szTitle.toLowerCase()).indexOf("technofundo : "))
	{ szTitle = szTitle.substr((szTitle.toLowerCase()).indexOf("technofundo : ") + 14); }
	
	var szText = '';
		
	szText += '<table border="0" width="100%" cellspacing="1" cellpadding="1"><tr><td bgcolor="#000000">';
	
	szText += '<table border="0" width="100%" cellspacing="0" cellpadding="0"><tr>';
	szText += '<td bgcolor="#000000" background="' + imgBase + "binary.gif" + '" height="40px" colspan="2" align="center">';
	szText += '<img border="0" src=\''+ img1.src +'\' width="260" height="32" hspace="5px" align="left" onMouseOver="this.src=\'' + img2.src + '\'; toggleBox(\'LinkBookmark\',1)" onMouseOut="this.src=\'' + img1.src +'\'; toggleBox(\'LinkBookmark\',0)" onClick="bookmarkSite();">';
	szText += '<div class="heading1">&nbsp;' + szTitle + '</div>';
	szText += '</td></tr><tr><td bgcolor="#eeeeee" height="16px">';
	
	szText += '<a class="menu" href="' + urlHome + '" onMouseOver="toggleBox(\'LinkHome\',1)" onMouseOut="toggleBox(\'LinkHome\',0)">&nbsp;Home&nbsp;</a>';
	
	szText += '<a class="menu" href="' + urlLastest + '" onMouseOver="toggleBox(\'LinkLatest\',1)" onMouseOut="toggleBox(\'LinkLatest\',0)">&nbsp;Latest&nbsp;</a>';
	
	szText += '<a class="menu" href="' + urlTech + '" onMouseOver="toggleBox(\'LinkTech\',1)" onMouseOut="toggleBox(\'LinkTech\',0)">&nbsp;Technology&nbsp</a>';
	szText += '<a class="menu" href="' + urlFun + '" onMouseOver="toggleBox(\'LinkFun\',1)" onMouseOut="toggleBox(\'LinkFun\',0)">&nbsp;Fun/Leisure&nbsp</a>';
	//szText += '<a class="menu" href="' + urlHigh + '" onMouseOver="toggleBox(\'LinkHigh\',1)" onMouseOut="toggleBox(\'LinkHigh\',0)">&nbsp;Highlights&nbsp;</a>';
	szText += '<a class="menu" href="' + urlAbout + '" onMouseOver="toggleBox(\'LinkAbout\',1)" onMouseOut="toggleBox(\'LinkAbout\',0)">&nbsp;About&nbsp;</a>';
	szText += '</td><td bgcolor="#eeeeee" height="16px" align="right"><div class="dat">' + getToday() + '&nbsp;</div></td></tr>'
	szText += '<tr><td bgcolor="#ffffff" height="18px" colspan="2"><div style="height:18px; font-size:12px; borde:none;">&nbsp;</div></td></tr></table>';
	
	szText += '</td></tr></table>';

	szText += '<div class="menudesc" id="LinkBookmark"><b>Bookmark</b> - Click on the image to bookmark technofundo site. (Add it to your favorites)</div>';
	szText += '<div class="menudesc" id="LinkHome">Home - Back to technofundo home! For site search, latest updates and much more.</div>';
	szText += '<div class="menudesc" id="LinkTech">Technology - Section for <i>techies</i>. Articles, tips, downloads, resources and more.</div>';
	szText += '<div class="menudesc" id="LinkFun">Fun &amp; Leisure - The lighter side of technofundo. e-greetings, daily cartoon and lots of fun.</div>';
	szText += '<div class="menudesc" id="LinkHigh">Highlights - Most interesting stuff from both the sections.</div>';
	szText += '<div class="menudesc" id="LinkAbout">Know more about the technofundo site and its human interface. ;)</div>'
	szText += '<div class="menudesc" id="LinkLatest">Latest - Some interesting stuff from technology, leisure and some excerpts from my blogs</div>'
	
	document.writeln(szText);
}
