function changeAction()
{
	var issue_action = "index.php?id=58&no_cache=1";
	var news_action = "index.php?id=59&no_cache=1";
	var wga_action = "index.php?id=48&no_cache=1";
	var issue_keyword_name = "tx_cortlandtmagissue_pi1[keyword]";
	var news_keyword_name = "tx_ttnews[swords]";
	
	var section = document['searchForm']['tx_gotanswers_pi1[section]'].value;
	
	/*var bname = navigator.appName;
	if ( bname == "Netscape" ) {
		//section = document.searchForm["tx_gotanswers_pi1[section]"].options.value;
		//alert(document[searchForm]['tx_gotanswers_pi1[section]'].value);
		//alert(bname+' '+section);
	}*/
	
	if ( section == "issue_archive" ) {
		document.searchForm.action = issue_action;
		document.getElementById('keyword').name = issue_keyword_name;
		
	}
	else if ( section == "news" ) {
		document.searchForm.action = news_action;
		document.getElementById('keyword').name = news_keyword_name;
	}
	else {
		document.searchForm.action = wga_action;
	}
}

function validateQuestionForm()
{
	var name = document['questionForm']['tx_gotanswers_pi1[name]'].value;
	var email = document['questionForm']['tx_gotanswers_pi1[email]'].value;
	var question_title = document['questionForm']['tx_gotanswers_pi1[question_title]'].value;
	var question_description = document['questionForm']['tx_gotanswers_pi1[question_description]'].value;
	
	// validating name
	if ( isEmpty(name) ) {
		alert( "Enter your name please." );
		return(false);
	}
	// validating email
	if ( !validEmail( email ) ) {
		alert( "Enter correct email address please." );
		return(false);
	}
	// validating question
	if ( isEmpty(question_title) ) {
		alert( "Enter question title please." );
		return(false);
	}
	
	if ( isEmpty(question_description) ) {
		alert( "Enter question description please." );
		return(false);
	}
	
	return (true);
}

// function checks if string is empty
function isEmpty( str ) 
{
	if ( str == "" ) return (true);
	return(false);
}

// validate email
function validEmail( str ) {
    //Validating the email field
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    if (!str.match(re)) {
        return (false);
    }
    return(true);
}

function homePageSelectChanged( dropdown_name ) 
{
	var keyword = "";//document['homeDropDowns']['tx_gotanswers_pi1[keyword]'].value;
	var section = "";//document['homeDropDowns']['tx_gotanswers_pi1[section]'].value;
	
	if ( dropdown_name == 'categories' ) {
		keyword = document['homeDropDowns']['tx_gotanswers_pi1[cat]'].options[document['homeDropDowns']['tx_gotanswers_pi1[cat]'].selectedIndex].text;
		section = "category";
	}
	if ( dropdown_name == 'areas' ) {
		keyword = document['homeDropDowns']['tx_gotanswers_pi1[ar]'].options[document['homeDropDowns']['tx_gotanswers_pi1[ar]'].selectedIndex].text;
		section = "area";
	}
	if ( dropdown_name == 'specialties' ) {
		keyword = document['homeDropDowns']['tx_gotanswers_pi1[sp]'].options[document['homeDropDowns']['tx_gotanswers_pi1[sp]'].selectedIndex].text;
		section = "specialism";
	}
	
	// setting variables
	document['homeDropDowns']['tx_gotanswers_pi1[keyword]'].value = keyword;
	document['homeDropDowns']['tx_gotanswers_pi1[section]'].value = section;
	
	// submitting the form
	document['homeDropDowns'].submit();
}
    
function gup( name )
    {
        name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var regexS = "[\\?&]"+name+"=([^&#]*)";
        var regex = new RegExp( regexS );
        var results = regex.exec( window.location.href );
        if( results == null )
            return "";
        else
            return results[1];
    }
    
