

///////////////////////////////////////////////////////
// background image
////////////////////////////////////////////////////////

function backgroundImage(id,url)
{	
document.getElementById(id).style.backgroundImage=url;
}

///////////////////////////////////////////////////////
/////////// browserType ////////////////

function browserType()
{
	var browser=navigator.appName;
	return browser;
}

 ///////////////////////////////////////////////////////
// checkForm() is used to determine if a radio button has been checked before submit()
////////////////////////////////////////////////////////

function checkForm()
{

   if (document.getElementById("Radio1").checked == false) 
		{
     	 alert("INSERT YOUR ALERT' " );
		}
		else
		{ 
		document.getElementById("formx").submit();
		}
}

///////////////////////////////////////////////////////
// Controls CSS font-color element
////////////////////////////////////////////////////////

function fontColor(id,acolor)
{	
document.getElementById(id).style.color=acolor;
}

///////////////////////////////////////////////////////
// Controls CSS display element
////////////////////////////////////////////////////////

function controlDisplay(id,status)
{	
document.getElementById(id).style.display=status;
}


///////////////////////////////////////////////////////
// curry() 
////////////////////////////////////////////////////////
function curry() {
	
	// set func to the first parameter to this function.
	var funcName = arguments[0];

	// set argsArray to the remaining parameters to this function.
	var argsArray = [];
	for (var i = 1; i < arguments.length; ++i) {
		argsArray.push(arguments[i]);
	}

	return function() {
		funcName.apply(window, argsArray);
	}
}

///////////////////////////////////////////////////////
// changeBGcolor() sets CSS value"
////////////////////////////////////////////////////////

function changeBGcolor(id,acolor) 
{
	document.getElementById(id).style.backgroundColor = acolor;
}

///////////////////////////////////////////////////////
// changeBorderColor() 
////////////////////////////////////////////////////////

function changeBorderColor(id,acolor) 
{
	document.getElementById(id).style.borderColor = acolor;
}


///////////////////////////////////////////////////////
// clearComments() 
////////////////////////////////////////////////////////

function clearComments(formName,id)//id is the for item name e.g.<input=text name="somename">
{
	eval('document.'+formName+'.'+id+'.value="" ');
}



///////////////////////////////////////////////////////
// changeDisplay() 
////////////////////////////////////////////////////////

function changeDisplay(id,aview)
{
	document.getElementById(id).style.display=aview;
}

///////////////////////////////////////////////////////
// changeColor() 
////////////////////////////////////////////////////////

function changeColor(id,acolor)
{
	document.getElementById(id).style.color=acolor;
}

///////////////////////////////////////////////////////
// changePosition() 
////////////////////////////////////////////////////////

function changePosition(id,bottomPos,rightPos)
{
	document.getElementById(id).style.bottom=bottomPos;
	document.getElementById(id).style.left=rightPos;
}


///////////////////////////////////////////////////////
// changeVisibility
////////////////////////////////////////////////////////
function changeVisibility(id,astatus) 
{
	document.getElementById(id).style.visibility = astatus; 
}




//////FUNCTION checkFormInfo()///////////
///This function is used to verify that all form text blocks are filled in//
var manager='';
function checkFormInfo(manager)
{
	var warning='';
	var index;
   
	if (!document.newReg.email.value) 
		{
     	 warning="* Email Address \n";
		 index=1;
		}

	if (!document.newReg.firstname.value) 
		{
     	 warning=warning+"* Fisrt Name \n";
		 index=1;
		}

	if (!document.newReg.lastname.value)  
		{
     	 warning=warning+ "* Last Name \n";
		  index=1;
		}
	if(manager=='manager')
	{
	if (!document.newReg.status.value)  
		{
     	 warning=warning+ "* Status \n";
		  index=1;
		}
	if (!document.newReg.apassword.value)  
		{
     	 warning=warning+ "* Password \n";
		  index=1;
		}
	}
	
	if(!index)
	{
			var str=document.newReg.email.value;
			var emailTest=emailCheck(str);
			if(emailTest)
		{

			document.newReg.submit();
		}
	}
	else
	{
		alert('Please enter the following information and \n press the submit button \n' + warning);
	}
}

///////////////////////////////////////////////////////
/////////// go to prior page (history) This is a back key simulation ////////////////
function goToPriorPage()
{

	history.go(-1)
		// -1 can be a variable describing how many page to go back in history
}


///////////////////////////////////////////////////////
// time delay
////////////////////////////////////////////////////////

function timeDelay(afunction,timeDelay)
{
var timer1=setTimeout(afunction,timeDelay);
}

//////FUNCTION emailcheck()///////////
///This function is used  to verify that the email addressed type in is in the correct format/
function emailCheck() 
	{
		var str=document.emailform.emailaddress.value;
		var at='@';
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
			if (str.indexOf(at)==-1)
			{
				alert("Invalid E-mail ID1");
				return false;
			}

			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
			{
			   alert("Invalid E-mail ID2");
			   return false;
			}

			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
			{
				alert("Invalid E-mail ID3");
				return false;
			}

			 if (str.indexOf(at,(lat+1))!=-1)
			{
				alert("Invalid E-mail ID4");
				return false;
			}

			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
			{
				alert("Invalid E-mail ID5");
				return false;
			}

			 if (str.indexOf(dot,(lat+2))==-1)
			{
				alert("Invalid E-mail ID6");
				return false;
			}
			
			 if (str.indexOf(" ")!=-1)
			{
				alert("Invalid E-mail ID7");
				return false;
			}

 		 return true					
	}


///////////////////////////////////////////////////////
// validate form
////////////////////////////////////////////////////////
function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
//////eraseCookie()///////////
function eraseCookie(name) 
{
	createCookie(name,"",-1);
}


///////////////////////////////////////////////////////
// fontcolor()
////////////////////////////////////////////////////////

function fontColor(id,acolor) 
{
	document.getElementById(id).style.color = acolor;
}



////// ReadCookie()///////////
function ReadCookie(cookieName) 
{
	 var theCookie=""+document.cookie;
	 var ind=theCookie.indexOf(cookieName);
	 if (ind==-1 || cookieName=="") return ""; 
	 var ind1=theCookie.indexOf(';',ind);
	 if (ind1==-1) ind1=theCookie.length; 
	 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

////// SetCookie()///////////
function SetCookie(cookieName,cookieValue,nDays) 
{
	 var today = new Date();
	 var expire = new Date();
	 if (nDays==null || nDays==0) nDays=1;
	 expire.setTime(today.getTime() + 3600000*24*nDays);
	 document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}


////// setFocus()///////////

function setFocus()
{
	
	if(browserType()=='netscape'||'moxilla')
	{
	document.filterName.fName.focus();
	}
}

////// stopTimeOut ///////////
function stopTimeOut(t)
{
clearTimeout(t);
}


///////////////////////////////////////////////////////
// submitForm().
////////////////////////////////////////////////////////

function submitForm()
{
var x=document.mapForm.submit();
}

///////////////////////////////////////////////////////
// swap contents using innerHTML
////////////////////////////////////////////////////////
function swap(currentContent, newContent)
{
document.getElementById(currentContent).innerHTML=document.getElementById(newContent).innerHTML
}


////////////									///////////////////////////
////////////									///////////////////////////
////////////  THIS SECTION (BELOW) CREATES A ROLLING BANNER  ///////////////////////////
////////////									///////////////////////////
////////////									///////////////////////////
var gImageCount;
var myimages=new Array();

////////////////////STARTROLLING BANNER type 1 ///////////////////////
var showtime = null;
var pictureSpeed = 4.0;

var gImages = new Array();
var imageFolder;
function startRollingBanner(imageFolder,numberOfImages)
{
	gImageCount=numberOfImages;
	var imgs=document.getElementById('posting').src;
		for(var i = 0; i < gImageCount; ++i)
		{	
			
			gImages[i] = imageFolder+"/"+(i) +  ".jpg";
		}


		if( showtime == null )
			showtime = setInterval("nextpostings()",pictureSpeed * 1000);
}

var showtime = null;
gImageCapableBrowser = canManipulateImages();
function canManipulateImages() 
{	
	if (document.images)
		return true;
	else	
		return false;
}


//////////////////LOADPOSTINGS ////////////////////////////////////////
function loadpostings(imageURL) 
{		
		
		document.getElementById('posting').src=imageURL;
		document.getElementById('sequenceNumber').innerHTML='&nbsp &nbsp Picture:  '+ (gCurrentImage+1) +" of " + gImageCount+'&nbsp &nbsp ';
		return false;
		show('sequenceNumber');
}

/////////////////////NEXTPOSTINGS/////////////////////////////////////
var gCurrentImage=0;
function nextpostings() 
{
	loadpostings(gImages[gCurrentImage]);	
	gCurrentImage = (gCurrentImage + 1) % gImageCount;		
}

	///////////////////////////////////////////////////////
///////// Null Test Block Element function nullTexBlock//////////////
var tagName;
var formName;
function nullTextBlock(formName,tagName) 
{
	eval('var x=document.'+formName+'.'+tagName+'.value=""');
}



//////////////////////////////////////////////////////
///////////////stepRow////////////////////////////
// stepRow manually sequences the "News" items
var aindex=0;
function stepRow(step)
    {
     stopRollingBanner();
      alength=(gImages.length);

    aindex=(aindex+ step);

    if(aindex>alength)
		{
		aindex=1;
		}
     if(aindex==0)
		{
		aindex=alength;
		}
     document.getElementById('sequenceNumber').innerHTML='&nbsp &nbsp Picture: '+(aindex) +" of  " + alength+'&nbsp &nbsp ';	 
	document.getElementById('posting').src=gImages[aindex-1];
	}





///////////////////////////////////////////////////////
// stopRollingBanner() stops skideshow. 

function stopRollingBanner()
	{
		clearInterval(showtime);
		showtime = null;
	}


	//////////////////////////////////////////////////////
// windowSize()
winW='';
function windowSize()
{

 if (navigator.appName=="Netscape") 
	 {
		winW = window.innerWidth;
		 winH = window.innerHeight;
	}
 if (navigator.appName==("Microsoft Internet Explorer")) 
	{
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
	}
}




