
function displayDate(){

var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()

var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");


month = monthNames[month -1];

document.write(month + " " + day + ", " + year)

}


function displayTime(){

var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()

if(hours > 12){
var hours12 = hours - 12;
}
else {
hours12 = hours;
}

if(hours12 == 0){
 hours12 = 12;
}
if (minutes < 10)
minutes = "0" + minutes
document.write(hours12 + ":" + minutes + " ")
if(hours > 11){
document.write("PM")
} else {
document.write("AM")
}

}

function createEmail(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
	}

//FORM VALIDATIONS
//DIGIT VALIDATION
function digitvalidation(entered, min, max, alertbox, datatype) {
	// Digit Validation by Henrik Petersen / NetKontoret
	// Explained at www.echoecho.com/jsforms.htm
	// Please do not remove this line and the two lines above.
	with (entered) {
		checkvalue=parseFloat(value);
		if (datatype) {
			smalldatatype=datatype.toLowerCase();
			if (smalldatatype.charAt(0)=="i") {
				checkvalue=parseInt(value); 
				if (value.indexOf(".")!=-1) {
					checkvalue=checkvalue+1
				}
			};
		}
		if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue) {
			if (alertbox!="") {
				alert(alertbox);
			} 
			return false;
		}
		else {return true;}
	}
} //END DIGIT VALIDATION

//VALUE VALIDATION
function valuevalidation(entered, min, max, alertbox, datatype)
{
// Value Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} //END VALUE VALIDATION


function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} 


function dropdownvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value =="#")
 {alert(alertbox);
 return false;}
else {return true;}
}
} 

//EMAIL VALIDATION


function emailcheck(email,alertbox) {
		var str = email.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(alertbox)
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(alertbox)
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(alertbox)
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(alertbox)
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(alertbox)
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(alertbox)
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert(alertbox)
		    return false
		 }

 		 return true					
	}

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
 }
//END EMAIL VALIDATION


//AUTO TAB FUNCTION
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

function checkBooks(book1,book2,alertbox){

if(checkboxvalidation(book1) || checkboxvalidation(book2))

{return true;}


else 
alert(alertbox);
{return false;}
}

function checkboxvalidation(entered)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.


if (!entered.checked) {return false;}

else {return true;}

}




//expand collapse
function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}


indent=5;//set here the left indent in pixels
iup='images/blueup.gif'//set here the up arrow relative location
idrop='images/bluedrop.gif'//set here the drop arrow relative location

//No need to modify below
function coll(){
var dd=document.getElementById('questions').getElementsByTagName('div');
var aa=document.getElementById('questions').getElementsByTagName('img');
for (var i=1;i<dd.length;i=i+2){



if(dd[i].style.display!='none')
{
	dd[i].style.position='relative';
	dd[i].style.display='none';
	dd[i].style.left=indent+'px';
}


}
for (var j=0;j<aa.length;j++){
im=aa[j].getAttribute('src');
if(im==idrop){
aa[j].setAttribute('src',iup);break
}
}
}
function activ(w){
var d=w.parentNode.getElementsByTagName('div')[0];
var a=w.firstChild;
if(d.style.display=='none'){
coll();
d.style.display='inline';
a.setAttribute('src',idrop);
}
else{
d.style.display='none';
a.setAttribute('src',iup);
}
}

/* insert into page
function onPageLoad(){
coll();

}

*/