// JavaScript Document

function OverCode( obj, cls ) {

	obj.className = cls;
}
			
function OutCode( obj, cls ) {

	obj.className = cls;
}

function Flip( iPicTotal, strDirection ) {

	var iPic, strPic

	strPic = document.images["gallery"].src.substr( 51 )
	strPic = ( strPic.length == 5 ) ? strPic.substr( 0, 1 ) : strPic.substr( 0, 2 )

	iPic = strPic.valueOf( )

	if ( strDirection == "N" )
		iPic = iPic == iPicTotal ? 1 : ++ iPic 
	else
		iPic = iPic == 1 ? iPicTotal : -- iPic

	document.images["gallery"].src = "/Images/Photos/Pic" + iPic.toString( ) + ".jpg"
}

function FlipNext( iPicTotal ) {
			
	var iPic, strPic
				
	strPic = document.images["calendar"].src.substr( 60 )
//	window.alert( strPic )
	if ( strPic.length == 5 )
		strPic = strPic.substr( 0, 1 )
	else
		strPic = strPic.substr( 0, 2 )
				
	iPic = strPic.valueOf( )
		
	if ( iPic == iPicTotal )
		iPic = 1
	else
		iPic ++
				
	document.images["calendar"].src = "/Images/CalendarWinners/Pic" + iPic.toString( ) + ".jpg"
}

function FlipPrevious( iPicTotal ) {
			
	var iPic, strPic
	
	strPic = document.images["calendar"].src.substr( 60 )
//	window.alert( strPic )
	if ( strPic.length == 5 )
		strPic = strPic.substr( 0, 1 )
	else
		strPic = strPic.substr( 0, 2 )
				
		iPic = strPic.valueOf( )
				
	if ( iPic == 1 )
		iPic = iPicTotal
	else
		iPic --
				
	document.images["calendar"].src = "/Images/CalendarWinners/Pic" + iPic.toString( ) + ".jpg"
}

function CheckFields( ) {

	var strCtrl, iCtr, retVal
	
	retVal = true
	for ( iCtr = 1; iCtr <= 12; iCtr ++ ) {
		strCtrl = "Q" + iCtr.toString( )
		if ( document.getElementById( strCtrl ).value == "" ) {
			window.alert( "You Must Answer Question " + iCtr.toString( ) )
			retVal = false
			break
		}
	}
	return retVal
}

function UpdateOther( ) {

	if ( document.MembershipForm.cb12.checked ) {
		window.alert( "Please Specify Other Sector" )
		document.MembershipForm.txtOtherSector.disabled = false
	} else {
		document.MembershipForm.txtOtherSector.disabled = true
		document.MembershipForm.txtOtherSector.value = ""
	}
}

function CheckFieldsMembership( ) {

	var strCtrl, iCtr, retVal
	
	retVal = false
	if ( document.MembershipForm.txtName.value == "" ) {
		window.alert( "Your Name Must Be Entered" )
		return false
	}
	if ( document.MembershipForm.txtOrganization.value == "" ) {
		window.alert( "Your Organization Must Be Entered" )
		return false
	}
	if ( document.MembershipForm.txtPhone.value == "" ) {
		window.alert( "Your Phone Must Be Entered" )
		return false
	}
	if ( document.MembershipForm.txtAddress.value == "" ) {
		window.alert( "Your Address Must Be Entered" )
		return false
	}
	if ( document.MembershipForm.txtEmail.value == "" ) {
		window.alert( "Your Email Must Be Entered" )
		return false
	}
	
	for ( iCtr = 1; iCtr <= 12; iCtr ++ )
		if ( document.getElementById( "cb" + iCtr.toString( ) ).checked ) {
			retVal = true
			break
		}
	
	if ( !retVal )
		window.alert( "You Must Select A Sector" )

	return retVal
}

function CheckRequired( ) {
			
	var retVal = false;
				
	if ( document.SendEmail.txtName.value == "" )
		window.alert( "Your Name is Required" );
	else
		if ( document.SendEmail.txtEmail.value == "" )
			window.alert( "Your Email is Required" );
		else
			if ( document.SendEmail.txtEmail.value.indexOf( "." ) != document.SendEmail.txtEmail.value.length - 4  || document.SendEmail.txtEmail.value.indexOf( "@" )  == -1  || document.SendEmail.txtEmail.value.indexOf( "." ) < document.SendEmail.txtEmail.value.indexOf( "@" ) || document.SendEmail.txtEmail.value.indexOf( "." ) + 1 == document.SendEmail.txtEmail.value.indexOf( "@" ) || document.SendEmail.txtEmail.value.indexOf( "@" ) + 1 == document.SendEmail.txtEmail.value.indexOf( "." ) )
				window.alert( "Invalid Email Entered Try Again" );
			else
				if ( document.SendEmail.txtComment.value == "" )
					window.alert( "The Comment is Required" );
				else
					retVal = true
				
	return retVal
}

