
// adapted from the "sleight.js" http://www.youngpup.net 
// by Eric Jacobsen eric@sleeplessnight.net

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	window.attachEvent("onload", turnGrey);
}

function turnGrey() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
	for (i=0; i<document.all.length; i++){
		if (itsAllGood ){
				//document.all[i].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayScale=1)";
		}
	}
}

function checkComments() {
	var strTemp = "Please fix the following errors ::\n\n"
	
	var strGuestName = document.getElementById('form_comments').strGuestName.value != "" ;
	var intUserID = document.getElementById('form_comments').intUserID.value != "0" ;
	var strSubject = document.getElementById('form_comments').strSubject.value != "" ;
	var strComments = document.getElementById('form_comments').strComments.value != "" ;
	
	if ( (strGuestName || intUserID) && strSubject && strComments ) {
		return true;
	} else {
		if (!strGuestName && !intUserID) { strTemp = strTemp + "A guest name is required\n" ; }
		if (!strSubject) { strTemp = strTemp + "A subject is required\n" ; }
		if (!strComments) { strTemp = strTemp + "A comment is required\n" ; }
		
		alert( strTemp );
		return false;
	}
}

// Join tastypopsicle.com validation
function checkJoin() {
	var strTemp = "Please fix the following errors ::\n\n"
	
	var strFirstName = document.join.strFirstName.value != "" ;
	var strLastName = document.join.strLastName.value != "" ;
	var strUserID = document.join.strUserID.value != "" ;
	var strEmail = document.join.strEmail.value != "" ;
	var strFrom = document.join.strFrom.value != "" ;
	var strWhy = document.join.strWhy.value != "" ;
	
	
	if ( strFirstName && strLastName && strUserID && strEmail && strFrom && strWhy ) {
		return true;
	} else {
		if (!strFirstName) { strTemp = strTemp + "A first name is required\n" ; }
		if (!strLastName) { strTemp = strTemp + "A last name is required\n" ; }
		if (!strUserID) { strTemp = strTemp + "A userid is required\n" ; }
		if (!strEmail) { strTemp = strTemp + "A valid email address is required\n" ; }
		if (!strFrom) { strTemp = strTemp + "Please let me know where you're from\n" ; }
		if (!strWhy) { strTemp = strTemp + "Please let me know why I should let you join\n" ; }
		
		alert( strTemp );
		return false;
	}
}

// POPSICLE trademark legal validation
function checkLegal() {
	var strTemp = "Please fix the following errors ::\n\n"
	
	var strName = document.legal.strName.value != "" ;
	var strEmail = document.legal.strEmail.value != "" ;
	var strInfo = document.legal.strInfo.value != "" ;
	
	if ( strName && strEmail && strInfo ) {
		return true;
	} else {
		if (!strName) { strTemp = strTemp + "A name is required\n" ; }
		if (!strEmail) { strTemp = strTemp + "A valid email address is required\n" ; }
		if (!strInfo) { strTemp = strTemp + "Information would be helpful\n" ; }
		
		alert( strTemp );
		return false;
	}
}

function imgOpener(i,c,w,h) {
	window.open('http://www.tastypopsicle.com/image.asp?i=' + i + '&c=' + c + '&x=','image','width=' + w + ',height=' + h);
}

function streamOpener(e) {
	window.open('http://www.tastypopsicle.com/stream.asp?eps=' + e + '&x=','stream','width=355,height=350');
}

function openIt(url,name,width,height,left,top,scroll,loc,menu,resize,tools,status) {
	window.open(url,name,'width='+width+',height='+height+',scrollbars='+scroll+',location='+loc+',left='+left+',top='+top+',menubar='+menu+',resizable='+resize+',toolbar='+tools+',status='+status);
}

function doSearch(strSearch){
	tf = document.mainform;
	tf.action = "results.asp?search=" + strSearch
	tf.submit();
}

function openWin(URL) {
	// center the image on the screen
	var width = 550;
	var height = 200;
	var left = (screen.width/2) - (width/2);
	var top = (screen.height/2) - (height/2);
	window.open(URL,"cms",'width='+width+',height='+height+',left='+left+',top='+top+',location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no');
	return false;
}

LoginOn = new Image();
LoginOn.src = "asp/images/buttonLoginOn.gif";
LoginOff = new Image();
LoginOff.src = "<asp/images/buttonLoginOff.gif";

LogoutOn = new Image();
LogoutOn.src = "asp/images/buttonLogoutOn.gif";
LogoutOff = new Image();
LogoutOff.src = "asp/images/buttonLogoutOff.gif";

// begin rollover
function imgAct(imgName) {
	document[imgName].src = eval(imgName + "On.src");
}

function imgInact(imgName) {
	document[imgName].src = eval(imgName + "Off.src");
}
// end rollover

function swapPic(sID,sImage,sStatus) {
	document.getElementById(sID).src = sImage;
	//window.status = sStatus;
	return false;
}

var myImages = new Array()
function preloadImages() {
	for (i=0;i<preloadImages.arguments.length;i++) {
		myImages[i] = new Image();
		myImages[i].src = preloadImages.arguments[i];
	}
}

function playMovie(sMovie) {
	window.open(sMovie,'movie','width=240,height=192,menubar=no,resizable=no,toolbar=no,status=no');
}

function goWeather() {
	zip = document.weather.weatherCity.value ;
	window.location.href="default.asp?go=" + zip ;
}

function getMSN() {
	var email = 'ed' + '@' + 'tastypopsicle' + '.com' ;
	document.write ('<' + 'a href="http://www.msn.com" onmouseover="(window.status=\'Use MSN Messenger to chat with me\'); return true;" onmouseout="(window.status=\'\');" title="MSN : ' + email + '"><img src="images/msnm.gif" alt="msn" /></a>');
}

function getEmail() {
	var email = 'edd' + 'ie' + '@' + 'tastypopsicle' + '.com' ;
	document.write ('<' + 'a href="mailto:' + email + '" onmouseover="(window.status=\'Send email to me\'); return true;" onmouseout="(window.status=\'\');" title="Send email to ' + email + '"><img src="images/email.gif" alt="email" /></a>');
}

function deleteComment(ID) {
	if (confirm("Are you sure you want to delete this comment?")) location.href="comments.asp?action=delete&ID=" + ID;
}

function deletePost(ID) {
	if (confirm("Are you sure you want to delete this post?")) location.href="comments.asp?action=deletePost&ID=" + ID;
}
