/*
DevelopersHome.com JavaScript code
(c) 2006 DevelopersHome.com. All rights reserved.
*/

function showAddToFavorites()
{
	if (navigator.appName.toLowerCase()=="microsoft internet explorer" && parseInt(navigator.appVersion)>=4)
		document.write('<a href="javascript: addToFavorites()">Add to Favorites</a> |');
}

function addToFavorites()
{
	window.external.AddFavorite(document.location, document.title);
}

function printPage()
{
	window.print();
}

function showEmailFriendsLink()
{
	var emailSubj = "Found an excellent article that might interest you";
	var emailMsg = "Hi,\n\n";
	emailMsg += "I've found an excellent article and thought you might be interested in it. Here are the details:\n\n";
	emailMsg += "Title: " + document.title + "\n";
	emailMsg += "URL: " + document.location + "\n";
	emailSubj = encodeURIComponent(emailSubj);
	emailMsg = encodeURIComponent(emailMsg);
	document.write('<a href="mailto:?&subject=' + emailSubj + '&body=' + emailMsg + '">Email Your Friends</a>');
}

function expandPageFeedbackForm()
{
	if (document.getElementById("optionalElements").style.display == "none"){
		document.getElementById("expandPageFeedbackFormAnchor").style.display = "none";
		document.getElementById("collapsePageFeedbackFormAnchor").style.display = "inline";
		document.getElementById("optionalElements").style.display = "block";
		document.pageFeedbackForm.details.focus();
	}
}

function collapsePageFeedbackForm()
{
	document.getElementById("expandPageFeedbackFormAnchor").style.display = "inline";
	document.getElementById("collapsePageFeedbackFormAnchor").style.display = "none";
	document.getElementById("optionalElements").style.display = "none";
}

function onSubmitPageFeedbackForm()
{
	var e = document.pageFeedbackForm.elements;
	var opinionValue = "";
	for (var i=0; i<e.length; i++){
		if (e[i].name == "opinion" && e[i].checked){
			opinionValue = e[i].value;
			break;
		}
	}
	document.pageFeedbackForm.topic.value = "commentFeedback";
	document.pageFeedbackForm.subject.value = "Feedback of Web Page";
	document.pageFeedbackForm.message.value = "URL: " + document.location + "\r\n" + "Opinion: " + opinionValue + "\r\n\r\n" + document.pageFeedbackForm.details.value;
}

function outputDisclaimerBrief()
{
	document.write('<p class="disclaimerBfHeading">Disclaimer Notice</p><p>We have made an effort to ensure the accuracy of information available on this web site. However, we do not warrant the correctness of these materials and assume no responsibility for errors or omissions in these materials. Please refer to <a href="/termsAndConditions.asp">Terms of Use</a> for the details before using this web site.</p>');
}

function setCookie2(name, value)
{
	var todays_date = new Date();
	var expires_date = new Date(todays_date.getFullYear()+10, todays_date.getMonth(), todays_date.getDate());
	document.cookie = name + '=' + escape(value) + ';expires=' + expires_date.toGMTString();
}

function getCookie(name)
{
	if (document.cookie.length == 0)
		return "";

	var startIndex = document.cookie.indexOf(name + "=");
	if (startIndex == -1)
		return "";

	var endIndex = document.cookie.indexOf(";", startIndex);
	if (endIndex == -1)
		endIndex = document.cookie.length;

	return unescape(document.cookie.substring(startIndex + name.length + 1, endIndex));
}

function setPrefs()
{
	var e = document.getElementsByName("colorScheme");
	var colorSchemeValue = "";
	for (var i=0; i<e.length; i++){
		if (e[i].checked){
			colorSchemeValue = e[i].value;
			break;
		}
	}

	e = document.getElementsByName("showAds");
	var showAdsValue = "";
	for (var i=0; i<e.length; i++){
		if (e[i].checked){
			showAdsValue = e[i].value;
			break;
		}
	}

	setCookie2("colorScheme", colorSchemeValue);
	setCookie2("showAds", showAdsValue);
	alert("Your preferences are saved.");
	window.location.reload();
}

function getPrefs()
{
	var colorSchemeValue = getCookie("colorScheme");
	if (colorSchemeValue == "")
		colorSchemeValue = 1;
	else
		colorSchemeValue = parseInt(colorSchemeValue);

	if (colorSchemeValue!=1 && colorSchemeValue!=2)
		colorSchemeValue = 1;

	document.getElementsByName("colorScheme")[colorSchemeValue-1].checked = true;

	var showAdsValue = getCookie("showAds");
	if (showAdsValue == "")
		showAdsValue = 1;
	else
		showAdsValue = parseInt(showAdsValue);

	if (showAdsValue!=1 && showAdsValue!=2)
		showAdsValue = 1;

	document.getElementsByName("showAds")[showAdsValue-1].checked = true;
}