var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i = 0; i < words.length; ++i)
		{
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
		}
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}

//Check for Flash compatibility?
var flashFlag = 0;
if ( is_mac ) {
	keystroke = ' Option ';				
} else {
	keystroke = ' Control ';
	if ( is_nav ) {
		//do nothing
	} else {			
		flashFlag = 1;
	}			
}



function businessCard(businessID) {
	window.open('/card.asp?business_id=' + businessID + '&localclassification_id=<%=localclassification_id%>&shirename_id=<%=shirename_id%>', businessID, 'height=400,toolbar=no,scrollbars=yes,resizable=yes,menubar=no,status=no,directories=no,location=no');
}

function changebox(text , propogate_to_flash ) {

	if ( document.form1.search_button.value.indexOf("Please wait") != -1 ) {
		return;
	}

	else{

		//document.form1.suburb.value = ""

		for (j=0; j < document.form1.length; j++) {
			if ( document.form1.elements[j].name.substring(0,12) == "shirename_id" && document.form1.elements[j].type.substring(0,6) == "select" ) {
				for (i = 0; i < document.form1.elements[j].options.length; i++) {
					if ( document.form1.elements[j].options[i].value == text ) {
						document.form1.elements[j].options[i].selected = true;
						break;
					}
				}
			}
		}

		

		//if (flashFlag == 1 && propogate_to_flash == 1 && current_page == "/index.asp" ) {
		if (flashFlag == 1 && propogate_to_flash == 1 && current_page == "/new/index.asp" ) {
			if ( MM_FlashCanPlay ) {
				window.document.map_movie.TGotoFrame('/', document.form1.shirename_id.options[document.form1.shirename_id.selectedIndex].name);
				window.document.map_movie.TGotoFrame('Suburbs', document.form1.shirename_id.options[document.form1.shirename_id.selectedIndex].id);
			}
		}
	}
}


function checkSearch(which_form, buttonName) {


	var fCheck = true;

	var name_str = which_form.search_term.value;
/*
	var id_str = which_form.localclassification_id.value;
	var pos = id_str.indexOf("~") + 1;

	id_str = id_str.substring(pos);

	if (id_str != name_str)	{
		which_form.localclassification_id.value = "";
	}
*/


	if (fCheck) {

		if ( which_form.search_button.value.indexOf("Search") != -1 ) {
			which_form.search_button.value = "Please wait";
			text = "";					
			return true;
		} 

	} else {
		// CATCH HERE AS INDIVIDUAL JS FUNCTIONS DO NOT RETURN TRUE OR FALSE
		return false;
	}

}



function checkBusinessSearch( which_form ) {

	var fCheck = true;

	if (which_form.business_name.value == "")
	{
		fCheck = false;
		alert("Please enter a business name.");
	}

	if (fCheck) {

		if ( which_form.search_business.value.indexOf("Search") != -1 ) {
			which_form.search_business.value = "Please wait";
			text = "";					
			return true;
		} 

	} else {
		// CATCH HERE AS INDIVIDUAL JS FUNCTIONS DO NOT RETURN TRUE OR FALSE
		return false;
	}
}

function goTo(pageName) {

	/*var name_str = document.form1.search_term.value;

	var id_str = document.form1.localclassification_id.value;
	var pos = id_str.indexOf("~") + 1;

	id_str = id_str.substring(pos);

	if (id_str != name_str)	{
		document.form1.localclassification_id.value = "";
	}*/
	/*alert('pageName: ' + pageName);*/
	document.form2.action = pageName;
	document.form2.submit();
}

var orig_suburb = ""
function SwitchSearchType(radio_searchtype)
{	
	/*
	When user is switching between allsydney and suburb search try and remember 
	the search suburb used. 
	*/
	if (radio_searchtype.value == 'allsydney')
	{
		if (radio_searchtype.form.suburb.value != "")
		{
			orig_suburb = radio_searchtype.form.suburb.value;
		}
		radio_searchtype.form.suburb.value = "";
		var elem = document.getElementById('suburb');
		elem.style.backgroundColor='#fed';
	}else{
		radio_searchtype.form.suburb.value = orig_suburb;

		var elem = document.getElementById('suburb');
		elem.style.backgroundColor='#FFFFFF';
		elem.focus();
	}
}

function CheckStreetSearch(which_form) {


	var fCheck = true;
	var errMsg = "";

	if ( which_form.street_region.options[which_form.street_region.selectedIndex].value == "0" ) {
		fCheck = false;
		errMsg += "- Please select a region\n";
	}


	if ( which_form.street_name.value == "") {
		fCheck = false;
		errMsg += "- Please enter a street name\n";
	}

	if (fCheck) {
		//alert('hello');
		if ( which_form.street_button.value.toLowerCase().indexOf("search") != -1 ) {
			
			which_form.street_button.value = "Please wait";
			text = '';					
			which_form.submit();
		} 

	} else {
		alert( errMsg );
	}
}

function CheckStreetSuburbSearch(which_form) {


	var fCheck = true;
	var errMsg = "";

	if (which_form.street_name.value == "")
	{
		fCheck = false;
		errMsg += "- Please enter a street name\n";
	}

	//if (which_form.suburb.value == "")
	//{
	//	fCheck = false;
	//	errMsg += "- Please enter a suburb\n";
	//}

	if (fCheck) {

		if ( which_form.street_button.value.toLowerCase().indexOf("search") != -1 ) {
			//which_form.street_button.value = "Please wait";
			text = '';
			which_form.submit();
		} 

	} else {
		alert( errMsg );
	}
}

		


