
var frm		= null;
var reportWin	= null;
var prevType  	= null;
var prevIndex  	= null;
var chPwdwin 	= null;

var emailWin	= null;

function navigateMenu(){
	
	var pSrc = "";
	var bSrc = "";
	
	pSrc = arguments[0];
	
	if( arguments.length > 1){		
		
		bSrc = arguments[1];
	}
	
	document.SearchResultsForm.action 	= "Dcoc.jsp";
	document.SearchResultsForm.PSRC.value 	= pSrc;
	document.SearchResultsForm.BSRC.value 	= bSrc;
	document.SearchResultsForm.submit();
	
}

function backToNormalPage(){
	
	document.DcocForm.action 	= "Dcoc.jsp";
	document.DcocForm.submit();
}

function editThisPage(){
	
	document.DcocForm.PSRC.value = arguments[0];
	document.DcocForm.action 	= "Editor.jsp";
	document.DcocForm.submit();	
}

function contactUs(){
	
	navigateMenu( 'ContactUs.htm' );
}

function serveyParticipants(){
	
	document.SearchResultsForm.action 	= "SurveyParticipants.jsp";
	document.SearchResultsForm.submit();
	
}

function membershipApplicationForm(){
	
	navigateMenu( 'MembershipApplication.jsp' );
}

function dcocSurveyForm(){
	
	navigateMenu( 'CoverLetter.jsp' );
}

function startSurvey(){

	navigateMenu( 'DcocSurvey.jsp' );
}

function backToPrevPage(){
	
	navigateMenu( document.SearchResultsForm.BSRC.value );
	
}

function closeThisWindow(){
	
	toHome( document.SearchResultsForm );
}

function toHome( f ){
	
	f.action = "Index.jsp";
	f.submit();
	
}

function toMyHome( f ){
	
	f.action = "Index.jsp";
	f.submit();
	
}

function onFormSubmit(){	
	
	document.SearchResultsForm.PAGE.value 		= "";
	document.SearchResultsForm.CATEGORY.value	= "";
	return true;
}

function highlitThisRow( row , i ){

	row.style.backgroundColor="#FFFFFF";

	if( i == 1){
		row.style.backgroundColor="#F4F0E9";
	}
}

function searchResults(){
	
	document.SearchResultsForm.PAGE.value 		= "";
	document.SearchResultsForm.CATEGORY.value	= "";
	document.SearchResultsForm.submit();
}

function searchByCategory( categoryId ){
	
	document.SearchResultsForm.PAGE.value 		= "";
	document.SearchResultsForm.SEATCHSTRING.value 	= "";
	document.SearchResultsForm.CATEGORY.value	= categoryId;	
	document.SearchResultsForm.submit();
}

function showNextSearchResults( page ){
		
	document.SearchResultsForm.PAGE.value = page;
	document.SearchResultsForm.submit();
}


function showCompanyWebsite( website ){
	
	website = "http://"+website;
	open(website,null,"toolbar=yes,location=no,resizable=yes,scrollbars=yes,width=500,height=500");
}

function requestForRegistration(){
	
	document.SearchResultsForm.action		= "RegistrationRequest.jsp";
	document.SearchResultsForm.submit();	
	
}

function mapIt( address, city,state,zip){
	
	var url = 'http://www.mapquest.com/maps/map.adp?';
	    url+='city='+city+'&state='+state+'&address='+address+'&zip='+zip
	window.open(url,null,"toolbar=yes,resizable=yes,location=no,scrollbars=yes,width=500,height=500");
}

function emailAddress( address ){
	
	var popW = 605;
	var popH = 423;

	if(document.all) {
	/* the following is only available after onLoad */
		w = document.body.clientWidth;
		h = document.body.clientHeight;
		LeftPosition =(w)?(w-popW)/2:100;
		TopPosition  =(h)?(h-popH)/2:100;

	}
	var url = "SendeMail.jsp?eMail="+address;
	var settings='width='+popW+',height='+popH+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		
	emailWin = window.open(url,'EmailWindow', settings) ;	
	emailWin.focus();
	
	
}
function newRegistrations(){
	
	document.SearchResultsForm.action		= "RegistrationRequestReport.jsp";
	document.SearchResultsForm.submit();	
	

}

function onSubmitCompose(){	
	
	
	var validData 	= true;	
	var frm 	= document.eMailForm;
	var msg		= "";		
	var focusObj	= null;
	
	//name	
	if( trim( frm.name.value ) == '' ){		
		
		validData = false;
		msg += '\n\t*  Name.';	
		focusObj 	=  frm.name;
	}
	
	//phone
	if( trim( frm.phone.value ) == '' ){		
		
		validData = false;
		msg += '\n\t*  Phone.';	
		if( focusObj == null ){
			focusObj 	=  frm.phone;		
		}
	}
	
	//from	
	if( trim( frm.email.value ) == '' ){		
		
		validData = false;
		msg += '\n\t*  Email.';	
		if( focusObj == null ){
			focusObj 	=  frm.email;
		}
		
	}	
		
	
	
	
	if( validData == false ){
		
		alert( "Please enter values  for the following fields: \n" + msg );
		if( focusObj != null ){
			
			focusObj.focus();
		}
	}	
	
	return validData ;
	
}

function trim ( s ){

  return rtrim(ltrim(s));
}



function ltrim ( s ){

	return s.replace( /^\s*/, "" )
}

function rtrim ( s ){

	return s.replace( /\s*$/, "" );
}

function reviewThis( regId ){

	document.RegistrationRequestReport.CID.value = regId ;
	document.RegistrationRequestReport.action="RegRequestedCompanyDetails.jsp";
	document.RegistrationRequestReport.submit();
}

function printRegistrations(){
	window.print();
}

function closeMemReqWindow(){
	
	document.RegistrationRequestReport.action = "Index.jsp";
	document.RegistrationRequestReport.submit();
}
function closeContactUsWindow(){
	
	document.eMailForm.action = "Index.jsp";
	document.eMailForm.submit();
}