// JavaScript Document
// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

function fnExpandNavigation(id){
		if (document.getElementById(id).style.display == "block" || document.getElementById(id).style.visibility == "visible"){
			document.getElementById(id).style.display = "none";
			document.getElementById(id).style.visibility = "hidden";
			var tempHTML = "";
			tempHTML = "<img src='" + backPath + "/PNG/more_16.png' width='12' height='12' alt='temp button' align='bottom' hspace='1' vspace='1' border='0' />"
			document.getElementById('img'+id).innerHTML = "";
			document.getElementById('img'+id).innerHTML = tempHTML;
		} else {
			document.getElementById(id).style.display = "block";
			document.getElementById(id).style.visibility = "visible";
			var tempHTML = "";
			tempHTML = "<img src='" + backPath + "/PNG/minimize_16.png' width='12' height='12' alt='temp button' align='bottom' hspace='1' vspace='1' border='0' />"
			document.getElementById('img'+id).innerHTML = "";
			document.getElementById('img'+id).innerHTML = tempHTML;
		}
	}

// FUNCTION TO EXPAND AND COLLAPSE CATEGORY LIST
function fncPopInCatID(ID,strDesc){
	document.getElementById('strCatDesc').value = strDesc;
	document.getElementById('strCategory').value = ID;
}

// NIFTY CORNERS //
/*window.onload=function(){
	Nifty("div#message","big top");
	Nifty("div#leftInner,div#rightInner","same height");
	Nifty("div#left,div#right","big bottom same-height");
}   */
// FUNCTION TO TURN ON POP UP BANNERS //
function turnOnPopUp(){
	document.getElementById("banner").style.visibility = "visible";
}
// FUNCTION TO TURN OFF POP UP BANNERS //
function turnOffPopUp(){
	document.getElementById("banner").style.visibility = "hidden";
}
// FUNCTION TO SWAP IMAGES //
var toDo = "IN";
function swapImages(idValue,imgIn,InOrOut,backPath){
	if(InOrOut == "OUT" && toDo == "OUT"){
		swapMe = true;
		toDo = "IN";
	} else if (InOrOut == "IN" && toDo == "IN"){
		swapMe = true;
		toDo = "OUT";
	} else {
		swapMe = false;
	}
	if(swapMe == true){
		var tempHTML = "";
		tempHTML = "<img src='" + backPath + "images/" + imgIn + "' width='65' height='65' alt='temp button' align='left' hspace='1' vspace='1' border='0' />"
		document.getElementById(idValue).innerHTML = "";
		document.getElementById(idValue).innerHTML = tempHTML;
	}
}
// FUNCTION TO CHECK FORM SUBMISSION
function checkform(of,required,errName,emailField)
{	

	// alert("CHECK FORM!");

	var reqfields,em,i,f,ty,cl,result;
	result = true;
	/* Changes from form example  */
	// reading all the labels and placing them in an associative 
	// array
	var labels,fieldnames;
	fieldnames=new Array();
	if(document.getElementsByTagName('label').length>0)
	{
		labels=document.getElementsByTagName('label');
		for(i=0;i<labels.length;i++)
		{
			fieldnames[labels[i].getAttribute('htmlFor')]=labels[i].firstChild.nodeValue;
		}
	}
	/*  end Changes from form example  */
	if(document.getElementById(required))
	{
		reqfields=document.getElementById(required).value.split(',');
		for(i=0;i<reqfields.length;i++)
		{
			f=document.getElementById(reqfields[i]);
			if(f.previousSibling && /img/i.test(f.previousSibling.nodeName)){
				f.parentNode.removeChild(f.previousSibling);
			}
			f.style.background='#FFFFFF';
			if(reqfields[i]==String(emailField)){
				var test = String(of[String(emailField)].value);
				if (test.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)){
					of['email'].value=of[String(emailField)].value;
				}
				else{
					adderr(String(emailField),fieldnames[String(emailField)],of,emailField)
				}
			}
			if(f){
				ty=f.type.toLowerCase();
				switch(ty)
				{
					case 'text':
						if(f.value==''&&reqfields[i]!=String(emailField)){
							result = false;
							adderr(f.id,fieldnames[f.id],of),emailField
						}							
					break;
					case 'textarea':
						if(f.value==''){
							result = false;
							adderr(f.id,fieldnames[f.id],of,emailField)
						}							
					break;
					case 'checkbox':
						if(!f.checked){
							result = false;
							adderr(f.id,fieldnames[f.id],of,emailField)
						}							
					break;
				}
			}
		}
	}
	if(result == false){
		return false;
	}else{
		return true;
	}
}
function adderr(id,name,of,emailField)
{
	var se,i,nli,na,newli;
	i=document.createElement('img');
	i.src= backPath + 'PNG/del_16.png';
	i.alt='Error';
	i.title='This field has an error!';
	i.width='16'
	i.height='16'
	i.align='left'
	if(id!=String(emailField)){
		se=document.getElementById(id);
	}else{
		se=document.getElementById(String(emailField));
	}
	se.parentNode.insertBefore(i,se)
	se.style.background='#fcc';
	if(document.getElementById('errormsg')){
		em=document.getElementById('errormsg');
		em.parentNode.removeChild(em);
	}	
	em=document.createElement('p');
	em.id='errormsg';
	em.appendChild(document.createTextNode('Please complete all fields highlighted in red.'))
/*  Changes from form example  */
	ul=document.createElement('ul');
	ul.id='errorlist';
	em.appendChild(ul);
/*  end Changes from form example  */
	for(var i=0;i<of.getElementsByTagName('input').length;i++)
	{
		if(/submit/i.test(of.getElementsByTagName('input')[i].getAttribute('type')))
		{
			var sb=of.getElementsByTagName('input')[i];
			break;
		}
	}
	em.style.backgroundColor='#CC0000';
	em.style.color='#FFFFFF'
	em.style.padding='5px';
	em.style.width='90%';
	em.style.styleFloat='none';
	em.style.textAlign='center';
	em.style.clear='both';
	em.style.marginLeft='auto';
	em.style.marginRight='auto';
	sb.parentNode.insertBefore(em,sb);
}
