// JavaScript Document

// Populate with splash-body format
function populateWithSplashBodyFormat () {
	$('content').innerHTML = '<div id="index">\
				<div id="splash">\
					<div id="welcome">About Me</div>\
					<div id="splash-body">\
					</div>	<!-- splash-body -->\
				</div>	<!-- splash -->\
			</div>	<!-- index -->';
}

function showAjaxWeather () {
	$('content').innerHTML = '<div id="core-module">\
				<div class="head">\
					<div class="padding">\
						<h1>AJAX Weather</h1>\
					</div>\
				</div>\
				<div class="body">\
					<p>Supply a country and a location and we will return the current weather.</p>\
					<div class="br"></div>\
					<table border="0" cellpadding="10" cellspacing="10">\
						<tr>\
							<td>Country</td>\
							<td><span id="divCountries">country list</span></td>\
						</tr>\
						<tr>\
							<td>Location</td>\
							<td><span id="spanCountryLocations">location list</span></td>\
						</tr>\
					</table>\
				</div>\
				<div class="body">\
					<div id="divWeatherResults" style="height:300px;">No weather found.</div>\
				</div>\
				<div class="base"></div>\
			</div>\
			<div id="support-modules">\
				<div class="support-module">\
					<div class="head">\
						On the Side:\
					</div>\
					<div class="body">\
						<div id="divWeather">\
							<p>The weather example on the left uses AJAX to request the countries, locations and the weatherreport. They are generated on the server and passed back to the browser without forcing a page refresh.</p>\
							<p><br />\
								The example also uses <a href="http://phpweather.sourceforge.net/">PHPWeather</a>, an indespensible tool in building this page.</p>\
						</div>\
						<div c\lass="br"></div>\
					</div>\
				</div>\
			</div>';
	getCountries ();
}
			
// Show the Resume information
function showResume () {
	if ($('splash-body') == null)		// first seed the fromework
		populateWithSplashBodyFormat ();
	$('splash-body').toggle();
	$("welcome").innerHTML = "Resume";
	$('splash-body').innerHTML = '<div id="leftColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
									<h2>Download</h2>\
							</div>\
							<div class="body">\
								<div class="itemDescription">\
									<p>&nbsp;</p>\
									<p>Download my resume in pdf or Microsoft Word format.</p>\
									<p>&nbsp;</p>\
									<p><a href="resumes/SoftwareDevelopment.pdf" target="_blank">download</a> pdf format</p>\
									<p><a href="resumes/SoftwareDevelopment.doc" target="_blank">download</a> Microsoft Word</p>\
								</div>\
							</div>\
							<!-- body -->\
						</div>	<!-- leftColumn -->\
						<div class="divider"></div>\
						<div id="rightColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
								<h2>Expertise</h2>\
							</div>\
							<div class="body">\
								<div class="itemDescription">\
									<p>During the course of my career, I have written a lot of software. I thoroughly enjoy the process of software development.</p>\
									<p>Over the course of 30 plus years, platforms and languages have matured, but the process of software development still remains the same.</p>\
								</div>\
								<div class="itemDetails">\
								</div> <!-- itemDetails -->\
							</div> <!-- body -->\
						</div> <!-- rightColumn -->';
	Effect.toggle('splash-body','appear');
}

// Show the Remote Assistance information
function showRemoteAssistance () {
	if ($('splash-body') == null)		// first seed the fromework
		populateWithSplashBodyFormat ();
	$('splash-body').toggle();
	$("welcome").innerHTML = "Remote Assistance";
	$('splash-body').innerHTML = '<div id="index">\
				<div id="splash">\
					<div id="leftColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
									<h2>&nbsp;</h2>\
							</div>\
							<div class="body">\
								<div class="itemDescription">\
									<h4>PC</h4>\
									<p>1. Call us first to set up a time for remote assistance.</p>\
									<p>2. <a href="http://www.gotoassist.com/ph/igcsf.com" target="_blank">Click here</a> to begin the session.</p>\
									<p>&nbsp;</p>\
									<h3>Mac</h3>\
									<p>1. Call Us.</p>\
								</div>\
								<div class="itemDetails"></div>\
								<!-- itemDetails -->\
							</div>\
							<!-- body -->\
						</div>	<!-- leftColumn -->\
						<div class="divider"></div>\
						<div id="rightColumn">\
							<div class="head"></div>\
							<div class="body">\
								<div class="itemDetails">\
								</div> <!-- itemDetails -->\
							</div> <!-- body -->\
						</div> <!-- rightColumn -->';
	Effect.toggle('splash-body','appear');
}

// Show the Credits information
function showCredits () {
	if ($('splash-body') == null)		// first seed the fromework
		populateWithSplashBodyFormat ();
	$('splash-body').toggle();
	$("welcome").innerHTML = "With Thanks to:";
	$('splash-body').innerHTML = '<div id="leftColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
									With	a	little	help	from	my	friends...	</div>\
							<div class="body">\
								<div class="itemDescription">\
									<p>Like much of the work I have produced over my career, this site would not be possible without the help of others. I know some of these people and many more I have never met. Neverthess, I am indebted to them for their contributions to this site.</p>\
									<p>&nbsp;</p>\
									<p>Click on any item below and more information will appear on the right.</p>\
									<p>&nbsp;</p>\
								</div>\
								<div class="itemDetails">\
									<div class="full">\
										<ul>\
											<li><a href="javascript:explain_prototype()">prototype.js</a></li>\
											<li><a href="javascript:explain_prototype()">Scriptaculous</a></li>\
											<li><a href="javascript:explain_project7()">Project Seven</a></li>\
											<li><a href="javascript:explain_mysql()">MySQL</a></li>\
											<li><a href="javascript:explain_opensource()">Open Source</a></li>\
											<li><a href="javascript:explain_niftycorners()">Alessandro Fulciniti</a></li>\
										</ul>\
									</div>\
								</div>\
								<!-- itemDetails -->\
							</div>\
							<!-- body -->\
						</div>	<!-- leftColumn -->\
						<div class="divider"></div>\
						<div id="rightColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
								<h2>Explanation</h2>\
							</div>\
							<div class="body">\
								<div class="itemDescription">\
								</div>\
								<div id="explanation" class="itemDetails"></div> \
								<!-- itemDetails -->\
							</div> <!-- body -->\
						</div> <!-- rightColumn -->';
	Effect.toggle('splash-body','appear');
}

// Show the About Us information
function showAboutUs () {
	if ($('splash-body') == null)		// first seed the fromework
		populateWithSplashBodyFormat ();
	$('splash-body').toggle();
	$("welcome").innerHTML = "About Me";
	$('splash-body').innerHTML = '<div id="leftColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
									<h2>Experience</h2>\
							</div>\
							<div class="body">\
								<div class="itemDescription">\
									<p><img src="images/iStock_000004390034.jpg" alt="Software Development" width="240" class="floatRight" /> </p>\
									<p>Since 1976, I have been writing software and have been the technical lead on numberous projects.</p>\
									<p>&nbsp;</p>\
									<p>Over the course of 30 years, platforms and software tools have changed, but the essence of writing good software has remained the same.</p>\
									<p>&nbsp;</p>\
									<p>I have intimate knowledge of a number of languages and a number of platforms, but like most hardware and software, their lifespan is short lived. Today, my area of expertise and interest is LAMP (Linux + Apache + MySQL + PHP)</p>\
								</div>\
							</div>\
							<!-- body -->\
						</div>	<!-- leftColumn -->\
						<div class="divider"></div>\
						<div id="rightColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
								<h2>Expertise</h2>\
							</div>\
							<div class="body">\
								<div class="itemDescription">\
									<div class="itemDescription">\
										<p><strong>With over 30 years of software development</strong>, the list of operating systems and languages would fill this column and more. Here is a list relevant to the technologies of today:</p>\
									</div>\
									<p>&nbsp;</p>\
								</div>\
								<div class="itemDetails">\
									<ul>\
										<li>PHP</li>\
										<li>MySQL</li>\
										<li>C++</li>\
										<li>AJAX</li>\
										<li>Technical Leadership</li>\
									</ul>\
								</div> <!-- itemDetails -->\
							</div> <!-- body -->\
						</div> <!-- rightColumn -->\
	';
	Effect.toggle('splash-body','appear');
}

// Show the Contact Us information
function showContactUs () {
	if ($('splash-body') == null)		// first seed the fromework
		populateWithSplashBodyFormat ();
	$('splash-body').toggle();
	$("welcome").innerHTML = "Contact Info";
	$('splash-body').innerHTML =
						'<div id="leftColumn">\
							<div class="head"></div>\
							<div class="body">\
								<div class="itemDescription">\
								<p>Irving Greisman Consulting</p>\
								<p>1363 29th Ave</p>\
								<p>San Francisco, CA 94122</p>\
								<p>&nbsp;</p>\
								<p>Voice: (415) 504-6640</p>\
								<p>FAX: (501) 640-4205</p>\
								<p>&nbsp;</p>\
								<p>Email: info@igcsf.com</p>\
								</div>\
								<div class="itemDetails">\
									<div class="left">\
									</div>\
									<div class="right">\
									</div>\
								</div>\
								<!-- itemDetails -->\
							</div>\
							<!-- body -->\
						</div>	<!-- leftColumn -->\
						<div class="divider"></div>\
						<div id="rightColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
								<h2>eFax</h2>\
							</div>\
							<div class="body">\
								<div class="itemDescription">\
									<p>Did you notice the 501 area code for our FAX? FYI: 501 is an Arkansas number.</p>\
									<p>&nbsp;</p>\
									<p>We use eFax for our FAX service. All faxes come in via eFax to our email. This allows us to store the FAX on our computer as a PDF. The other advantage is that we get no spam faxes with this service.</p>\
									<p>&nbsp;</p>\
									<p><a href="http://www.efax.com" target="_blank">Click here</a> to go to the eFax site.</p>\
								</div>\
								<div class="itemDetails">\
								</div> <!-- itemDetails -->\
							</div> <!-- body -->\
						</div> <!-- rightColumn -->\
	';
	Effect.toggle('splash-body','appear');
}


// Show the Registration page
function showRegister () {
	if ($('splash-body') == null)		// first seed the fromework
		populateWithSplashBodyFormat ();
	$('splash-body').toggle();
	$("welcome").innerHTML = "Register for Emails";
	$('splash-body').innerHTML =
						'<div id="leftColumn">\
							<div class="head"></div>\
							<div class="body">\
								<div class="itemDescription">\
								<p>\
<form method=post action="http://app.icontact.com/icp/signup.php" name="icpsignup" accept-charset="UTF-8" onsubmit="return verifyRequired();" >\
<input type=hidden name=redirect value="http://www.icontact.com/www/signup/thanks.html" />\
<input type=hidden name=errorredirect value="http://www.icontact.com/www/signup/error.html" />\
<script type="text/javascript">\
function verifyRequired() {\
  if (document.icpsignup["fields_email"].value == "") {\
    document.icpsignup["fields_email"].focus();\
    alert("The Email field is required.");\
    return false;\
  }\
  if (document.icpsignup["fields_fname"].value == "") {\
    document.icpsignup["fields_fname"].focus();\
    alert("The First Name field is required.");\
    return false;\
  }\
  return true;\
}\
</script>\
<div id="SignUp">\
<table width="260" class="signupframe" border="0" cellspacing="0" cellpadding="5">\
    <tr>\
      <td valign=top align=right>\
        <font size="1" face="Arial,Helvetica, sans-serif">*</font> <font size="2">Email</font>\
      </td>\
      <td align=left>\
        <input type=text name="fields_email">\
      </td>\
    </tr>\
    <tr>\
      <td valign=top align=right>\
        <font size="1" face="Arial,Helvetica, sans-serif">*</font> <font size="2">First Name</font>\
      </td>\
      <td align=left>\
        <input type=text name="fields_fname">\
      </td>\
    </tr>\
    <tr>\
      <td valign=top align=right>\
         <font size="2">Last Name</font>\
      </td>\
      <td align=left>\
        <input type=text name="fields_lname">\
      </td>\
    </tr>\
    <TR>\
      <TD>\
		<input type=hidden name="listid" value="9851110">\
		<input type=hidden name="specialid:9851110" value="PAOI">\
		<input type=hidden name=clientid value="389686">\
		<input type=hidden name=formid value="988">\
		<input type=hidden name=reallistid value="1">\
		<input type=hidden name=doubleopt value="0">\
	  </TD>\
      <TD><font size="1">*</font><font size="2"> = Required Field</FONT></TD>\
    </TR>\
    <tr>\
      <td> </td>\
      <td><input type="submit" name="Submit" value="Submit"></td>\
    </tr>\
	<tr>\
      <td> </td>\
      <td><font size="2"><a href="http://www.icontact.com">Email Marketing by iContact</a></font></td>\
    </tr>\
    </table>\
</div>\
</form>\
								</p>\
								</div>\
								<!-- itemDescription -->\
								<div class="itemDetails">\
									<div class="left">\
									</div>\
									<div class="right">\
									</div>\
								</div>\
								<!-- itemDetails -->\
							</div>\
							<!-- body -->\
						</div>	<!-- leftColumn -->\
						<div class="divider"></div>\
						<div id="rightColumn">\
							<div class="head"><img src="images/icon-home-splash-plus.gif" style="border: 0; padding: 0 0 2px 0;" alt="" />\
								<h2>What to Expect</h2>\
							</div>\
							<div class="body">\
								<div class="itemDescription">\
									<p>Twice a month, I will send you an email with a tech tip or product product review.  Fill in your name and email and you will receive these emails.</p>\
									<p>&nbsp;</p>\
									<p>Technology advances at a rapid pace and it is very hard to keep on top of all the latest developments.  I want to help by sharing with you products that will make your life more productive and tips to help you make the most of technology.</p>\
								</div>\
								<div class="itemDetails">\
								</div> <!-- itemDetails -->\
							</div> <!-- body -->\
						</div> <!-- rightColumn -->\
	';
	Effect.toggle('splash-body','appear');
}


// set focus to element on page
function focusIt(ele) {
	$(ele).focus();
}

// ***********************************************************
// Name: formatNumberWithCommas
// Description: Format a string with a sepearator (i.e. 1,234,5678) 
// Arguments: num - The number that is to be formatted.
//		 dp - The number of decimal points in the number
//		 sepString - The seperator to use in the formatted string.
// Return: The number as a formatted string.
// ***********************************************************
function formatNumberWithCommas(num,dp,sepString) {
	var str = "";

	if (!dp)
		dp = 2;
	if (!sepString)
		sepString=",."
	if (dp)
		num=Math.round(num*Math.pow(10,dp))
	try {
		if (num == 0) {
			str = sepString.charAt(1)
			while (dp-- > 0)
				str += "0";
		} else {
			num=num.toString()
			str=sepString.charAt(1)+num.substr(num.length-dp)
			num=num.substr(0,num.length-dp)
			while (num.length>3) {
				str=sepString.charAt(0)+num.substr(num.length-3)+str
				num=num.substr(0,num.length-3)
			}
			str=num+str
		}
	} catch (e) {
		str = "";
	}
	return str;
}


// ***********************************************************
// Name: getXMLDocument
// Description: Get the xml document.  This will handle
//				IE and other browsers.
// Arguments: none
// Return: The xml document.
// ***********************************************************
function getXMLDocument () {
	try {
		var xmlDocument = new ActiveXObject('Microsoft.XMLDOM'); 
		xmlDocument.appendChild(xmlDocument.createElement('root'));
		return (xmlDocument);
	} catch (e) {
		// not IE
		return  (document.implementation.createDocument('', 'root', null)); 
	}
}

// ***********************************************************
// Name: getSerializedData
// Description: Convert DOM subtree or DOM document into text
// Arguments: The xml documednt
// Return: The xml code as text.
// ***********************************************************
function getSerializedData (xmlDocument) {
	var szRet = "";
	if (String(xmlDocument.xml) != "undefined")
		szRet = xmlDocument.xml;
	else {
		  // create serializer object
		var xmlSerializer = new XMLSerializer();
		// serialize
		szRet = xmlSerializer.serializeToString(xmlDocument);
	}
	return (szRet);
}


// ***********************************************************
// Name: createXMLCdataNode
// Description: Create a CDATA node
// Arguments: xmlNode - The xml node
//				szNodeName - The name of the xml node
//				szNodeValue - The value to put into the node
// Return: none
// ***********************************************************
function createXMLCdataNode (xmlDocument, szNodeName, szNodeValue) {
	var el = xmlDocument.createElement(szNodeName);
	var newCDATA = xmlDocument.createCDATASection (szNodeValue);
	el.appendChild (newCDATA);
	xmlDocument.documentElement.appendChild (el);
}



// ***********************************************************
// Name: createSubXMLCdataNode
// Description: Create a CDATA node
// Arguments: xmlDocument - The xml document
//				xmlNode - The xml node
//				szNodeName - The name of the xml node
//				szNodeValue - The value to put into the node
// Return: none
// ***********************************************************
function createSubXMLCdataNode (xmlDocument, xmlNode, szNodeName, szNodeValue) {
	var el = xmlDocument.createElement(szNodeName);
	var newCDATA = xmlDocument.createCDATASection (szNodeValue);
	el.appendChild (newCDATA);
	xmlNode.appendChild (el);
}

function html2entities(){
	var re=/[(<>"'&]/g
	for (i=0; i<arguments.length; i++)
		arguments[i].value=arguments[i].value.replace(re, function(m){return replacechar(m)})
}

function replacechar(match){
	if (match=="<")
		return "&lt;"
	else if (match==">")
		return "&gt;"
	else if (match=="\"")
		return "&quot;"
	else if (match=="'")
		return "&#039;"
	else if (match=="&")
		return "&amp;"
}