// Funciton to close/hide a box
function toggleBox(objDiv)
{
	var objBox = document.getElementById(objDiv);

	if (objBox.style.display == "none")
		objBox.style.display = "";
	else
		objBox.style.display = "none";

}

//Function to jump to another forum
function ForumJump(URL) {

	if (URL.options[URL.selectedIndex].value != "") self.location.href = URL.options[URL.selectedIndex].value;
	return true;
}

//Function to open pop up window
function openWin(theURL,winName,features) {
  	window.open(theURL,winName,features);
}



//Function to open preview post window
function OpenPreviewWindow(targetPage, formName){

	now = new Date

	//Open the window first
   	openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400')

   	//Now submit form to the new window
   	formName.action = targetPage + "?ID=" + now.getTime();
	formName.target = "preview";
	formName.submit();
}

//Function to hide and show menu sub links
function menushowhide(objImage, id) {

	var objBox = document.getElementById(id)

	if (document.getElementById(id).style.display == "") {
		objBox.style.display = "none";
		objImage.style.filter = "gray()";

		SaveCookie(id, 'Hide');
	}
	else {
		objBox.style.display = "";
		objImage.style.filter = "";

		SaveCookie(id, 'Show');
	}
}

//Function show and hide column boxes
function showhide(id, imgPath) {

	var objBox = document.getElementById(id + '_full');
	var objContent = document.getElementById(id);
	var objImage = document.getElementById(id + '_image');

	if (document.getElementById(id).style.display == "") {
		objContent.style.display = "none";
		objImage.src = imgPath + "module-max-arrow.gif";
		objBox.style.filter = "gray()";

		SaveCookie(id, 'Hide');
	} else {
		objContent.style.display = "";
		objImage.src = imgPath + "module-min-arrow.gif";
		objBox.style.filter = "";

		SaveCookie(id, 'Show');
	}
}

function disableModule(id) {

	var closeModule = confirm('Are you sure you want to disable this box and not have it shown in the future?\n\nTo re-enable you have to click \' Reset Disabled Modules \' at the bottom of the Navigation Menu.');

	if (closeModule) {
		alert('The changes will take effect when you refresh your browser.');
		SaveCookie(id, 'Close');
	}

	return false;

}

function enableModule(id) {
	SaveCookie(id, 'Show');
}

//Function save cookie
function SaveCookie(name, value)
{
	var expiry = new Date();
	expiry.setTime (expiry.getTime() + (24 * 60 * 60 * 1000*365));

	document.cookie=name + "=" + escape(value) + "; expires=" + expiry;
}

//Function to check avatar image
function AvatarImage(objImage, newSize) {

	imgWidth = objImage.width;
	imgHeight = objImage.height;

	if (imgWidth > newSize) {
		objImage.width = newSize;
	}

	if (imgHeight > newSize) {
		objImage.height = newSize;
	}
}
 
 function addToFavorites() {
 if (window.external) { 
window.external.AddFavorite("http://www.mycodekb.com","My Code & KB") 
} 
else { alert("Sorry! Your browser doesn't support this function."); 
} } 

