function indexSearchValidate() {
	
	     var themessage = "Please select the required field(s): \n\n";
        var valid=1;
        if (document.indexsearch.we_cater_to[document.indexsearch.we_cater_to.selectedIndex].value=='') {
                themessage = themessage + " - Weekend Flavour\n";
                valid = 0;
        }

	if (document.indexsearch.state[document.indexsearch.state.selectedIndex].value=='') {
		themessage = themessage + " - State\n";
		valid = 0;
	}        
	
	//if (document.indexsearch.region[document.indexsearch.region.selectedIndex].value=='') {
		//themessage = themessage + " - Region\n";
		//valid = 0;
	//}    	

        if (valid == 1) {
                document.indexsearch.action="search_results.php";
                document.indexsearch.submit();
                return true;
        } else {
                alert(themessage);
                return false;
        }
        return false;
}
function CreatAccountValidate() {
        var themessage = "You are required to complete the following field(s): \n\n";
        var valid=1;
        if (document.createaccount.venue_name.value=="") {
                themessage = themessage + " - Venue Name\n";
                valid=0;
        }

        if (document.createaccount.contact_name.value=="") {
                themessage = themessage + " - Contact Name\n";
                valid=0;
        }

        if (document.createaccount.address1.value=="") {
                themessage = themessage + " - Address\n";
                valid=0;
        }

        if (document.createaccount.suburb.value=="") {
                themessage = themessage + " - Suburb\n";
                valid=0;
        }

        if (document.createaccount.state[document.createaccount.state.selectedIndex].value=='') {
                themessage = themessage + " - State\n";
                valid = 0;
        }

	if (document.createaccount.region[document.createaccount.region.selectedIndex].value=='') {
		themessage = themessage + " - Region\n";
		valid = 0;
	}

        if (document.createaccount.postcode.value=="") {
                themessage = themessage + " - Postcode\n";
                valid = 0;
        }

        if (document.createaccount.abn.value=="") {
                themessage = themessage + " - ABN / ACN\n";
                valid = 0;
        }

        if (document.createaccount.phone_number.value=="") {
                themessage = themessage + " - Phone Number\n";
                valid = 0;
        }

        if (document.createaccount.email.value=="") {
                themessage = themessage + " - Email\n";
                valid = 0;
        }

        if (document.createaccount.password.value=="") {
                themessage = themessage + " - Password\n";
                valid = 0;
        }
		else if (document.createaccount.password.value.length<5) {
                themessage = themessage + " - Password Should Be atleast 5 Characters.\n";
                valid = 0;
        }

        if (document.createaccount.passwordrepeat.value=="") {
                themessage = themessage + " - Confirm Password\n";
                valid = 0;
        }
		
		

	if(!document.createaccount.agree.checked) {
		themessage = themessage + " - Please agree with the terms and conditions\n";
		valid = 0;
	}

        if (valid == 1) {
                document.createaccount.action="paymentdetails.php";
                //document.createaccount.submit();
                return true;
        } else {
                alert(themessage);
                return false;
        }
        return false;
}

function PaymentForm() {
  if(document.paymentdetails.payment[0].checked == true)
  {
    document.paymentdetails.action ="paymentpage.php";
  }
  else
  if(document.paymentdetails.payment[1].checked == true)
  {
    document.paymentdetails.action ="paymentpage-ch.php";
  }
  else
  if(document.paymentdetails.payment[2].checked == true)
  {
    document.paymentdetails.action ="paymentpage-bt.php";
  }

  if ( ( document.paymentdetails.payment[0].checked == false ) && ( document.paymentdetails.payment[1].checked == false ) && ( document.paymentdetails.payment[2].checked == false ) )
  {
    alert ( "Please choose your preffered payment type" );
    return false;
  }
  return true;
}

function adminPaymentForm() {
  if(document.paymentdetails.payment[0].checked == true)
  {
    document.paymentdetails.action ="../admin/adminpaymentpage.php";
  }
  else
  if(document.paymentdetails.payment[1].checked == true)
  {
    document.paymentdetails.action ="../admin/adminpaymentpage-ch.php";
  }
  else
  if(document.paymentdetails.payment[2].checked == true)
  {
    document.paymentdetails.action ="../admin/adminpaymentpage-bt.php";
  }

  if ( ( document.paymentdetails.payment[0].checked == false ) && ( document.paymentdetails.payment[1].checked == false ) && ( document.paymentdetails.payment[2].checked == false ) )
  {
    alert ( "Please choose your preffered payment type" );
    return false;
  }
  return true;
}
function Payment() {
  if(document.paymentdetails.payment[0].checked == true)
  {
    document.paymentdetails.action ="../advertiser/adminpaymentpage.php";
  }
  else
  if(document.paymentdetails.payment[1].checked == true)
  {
    document.paymentdetails.action ="../advertiser/adminpaymentpage-ch.php";
  }
  else
  if(document.paymentdetails.payment[2].checked == true)
  {
    document.paymentdetails.action ="../advertiser/adminpaymentpage-bt.php";
  }

  if ( ( document.paymentdetails.payment[0].checked == false ) && ( document.paymentdetails.payment[1].checked == false ) && ( document.paymentdetails.payment[2].checked == false ) )
  {
    alert ( "Please choose your preffered payment type" );
    return false;
  }
  return true;
}

function adminPaymentForm1() {
  if(document.paymentdetails.payment[0].checked == true)
  {
    document.paymentdetails.action ="../admin/adminpaymentpage.php";
  }
  else
  if(document.paymentdetails.payment[1].checked == true)
  {
    document.paymentdetails.action ="../admin/adminpaymentpage-ch.php";
  }
  else
  if(document.paymentdetails.payment[2].checked == true)
  {
    document.paymentdetails.action ="../admin/adminpaymentpage-bt.php";
  }

  if ( ( document.paymentdetails.payment[0].checked == false ) && ( document.paymentdetails.payment[1].checked == false ) && ( document.paymentdetails.payment[2].checked == false ) )
  {
    alert ( "Please choose your preffered payment type" );
    return false;
  }
  return true;
}

function setOptions(chosen) {
  var selbox = document.indexsearch.region;

  selbox.options.length = 0;
  if (chosen == "") {
    selbox.options[selbox.options.length] = new Option('Select your region ...','');
  }

  if (chosen == "ACT") {
	selbox.options[selbox.options.length] = new Option('Select your region ...','');
    selbox.options[selbox.options.length] = new Option('Canberra and Surrounds','Canberra and Surrounds');
  }
  if (chosen == "NSW") {
	selbox.options[selbox.options.length] = new Option('Select your region ...','');
    selbox.options[selbox.options.length] = new Option('Blue Mountains','Blue Mountains');
    selbox.options[selbox.options.length] = new Option('Capital Country','Capital Country');
    selbox.options[selbox.options.length] = new Option('Central Coast','Central Coast');
    selbox.options[selbox.options.length] = new Option('Central West','Central West');
    selbox.options[selbox.options.length] = new Option('Hawkesbury','Hawkesbury');
    selbox.options[selbox.options.length] = new Option('Hunter Valley & Coast','Hunter Valley & Coast');
    selbox.options[selbox.options.length] = new Option('Illawarra','Illawarra');
    selbox.options[selbox.options.length] = new Option('Mid North Coast','Mid North Coast');
    selbox.options[selbox.options.length] = new Option('New England','New England');
    selbox.options[selbox.options.length] = new Option('North Coast','North Coast');
    selbox.options[selbox.options.length] = new Option('North West','North West');
    selbox.options[selbox.options.length] = new Option('Snowy Mountains','Snowy Mountains');
    selbox.options[selbox.options.length] = new Option('Southern Highlands','Southern Highlands');
    selbox.options[selbox.options.length] = new Option('Sydney','Sydney');
    selbox.options[selbox.options.length] = new Option('The Murray','The Murray');
    selbox.options[selbox.options.length] = new Option('The Outback','The Outback');
    selbox.options[selbox.options.length] = new Option('The Riverina','The Riverina');
    selbox.options[selbox.options.length] = new Option('The South Coast','The South Coast');
  }
  if (chosen == "NT") {
	selbox.options[selbox.options.length] = new Option('Select your region ...','');
    selbox.options[selbox.options.length] = new Option('Darwin Region','Darwin Region');
    selbox.options[selbox.options.length] = new Option('The Red Centre','The Red Centre');
  }
  if (chosen == "QLD") {
    selbox.options[selbox.options.length] = new Option('Select your region ...','');
    selbox.options[selbox.options.length] = new Option('Around Brisbane & Hinterland','Around Brisbane & Hinterland');
    selbox.options[selbox.options.length] = new Option('Brisbane','Brisbane');
    selbox.options[selbox.options.length] = new Option('Brisbane Islands','Brisbane Islands');
    selbox.options[selbox.options.length] = new Option('Capricorn','Capricorn');
    selbox.options[selbox.options.length] = new Option('Darling Downs','Darling Downs');
    selbox.options[selbox.options.length] = new Option('Fraser Island & Coast','Fraser Island & Coast');
    selbox.options[selbox.options.length] = new Option('Gold Coast & Hinterland','Gold Coast & Hinterland');
    selbox.options[selbox.options.length] = new Option('Great Barrier Reef','Great Barrier Reef');
    selbox.options[selbox.options.length] = new Option('Outback & Gulf Country','Outback & Gulf Country');
    selbox.options[selbox.options.length] = new Option('Sunshine Coast & Hinterland','Sunshine Coast & Hinterland');
    selbox.options[selbox.options.length] = new Option('Tropical North','Tropical North');
  }
  if (chosen == "SA") {
	selbox.options[selbox.options.length] = new Option('Select your region ...','');
    selbox.options[selbox.options.length] = new Option('Adelaide','Adelaide');
    selbox.options[selbox.options.length] = new Option('Adelaide Hills','Adelaide Hills');
    selbox.options[selbox.options.length] = new Option('Barossa Valley','Barossa Valley');
    selbox.options[selbox.options.length] = new Option('Clare Valley & Mid North','Clare Valley & Mid North');
    selbox.options[selbox.options.length] = new Option('Eyre Peninsula & Nullarbor','Eyre Peninsula & Nullarbor');
    selbox.options[selbox.options.length] = new Option('Fleurieu Peninsula','Fleurieu Peninsula');
    selbox.options[selbox.options.length] = new Option('Flinders Ranges & Outback','Flinders Ranges & Outback');
    selbox.options[selbox.options.length] = new Option('Kangaroo Island','Kangaroo Island');
    selbox.options[selbox.options.length] = new Option('Murray Region','Murray Region');
    selbox.options[selbox.options.length] = new Option('The South-East','The South-East');
    selbox.options[selbox.options.length] = new Option('Yorke Peninsula','Yorke Peninsula');
  }
  if (chosen == "TAS") {
	selbox.options[selbox.options.length] = new Option('Select your region ...','');
    selbox.options[selbox.options.length] = new Option('Bass Strait Islands','Bass Strait Islands');
    selbox.options[selbox.options.length] = new Option('Hobart','Hobart');
    selbox.options[selbox.options.length] = new Option('The East Coast','The East Coast');
    selbox.options[selbox.options.length] = new Option('The Midlands','The Midlands');
    selbox.options[selbox.options.length] = new Option('The North West','The North West');
    selbox.options[selbox.options.length] = new Option('The South-East','The South-East');
    selbox.options[selbox.options.length] = new Option('The South-West','The South-West');
  }
  if (chosen == "VIC") {
	selbox.options[selbox.options.length] = new Option('Select your region ...','');
    selbox.options[selbox.options.length] = new Option('Bays & Peninsulas','Bays & Peninsulas');
    selbox.options[selbox.options.length] = new Option('East Gippsland','East Gippsland');
    selbox.options[selbox.options.length] = new Option('Goldfields','Goldfields');
    selbox.options[selbox.options.length] = new Option('Goulburn & Murray','Gouldburn & Murray');
    selbox.options[selbox.options.length] = new Option('Grampians & Central West','Grampians & Central West');
    selbox.options[selbox.options.length] = new Option('Mallee Country','Mallee Country');
    selbox.options[selbox.options.length] = new Option('Melbourne','Melbourne');
    selbox.options[selbox.options.length] = new Option('Phillip Island & Gippsland','Phillip Island & Gippsland');
    selbox.options[selbox.options.length] = new Option('South-West Coast','South-West Coast');
    selbox.options[selbox.options.length] = new Option('Spa & Garden Country','Spa & Garden Country');
    selbox.options[selbox.options.length] = new Option('The Legends','The Legends');
    selbox.options[selbox.options.length] = new Option('Yarra Valley & Dandenong Ranges','Yarra Valley & Dandenong Ranges');
  }
  if (chosen == "WA") {
	selbox.options[selbox.options.length] = new Option('Select your region ...','');
    selbox.options[selbox.options.length] = new Option('Darling Range & Swan Valley','Darling Range & Swan Valley');
    selbox.options[selbox.options.length] = new Option('Esperance & Nullarbor','Esperance & Nullarbor');
    selbox.options[selbox.options.length] = new Option('Great Southern','Great Southern');
    selbox.options[selbox.options.length] = new Option('Outback Coast & Mid-West','Outback Coast & Mid-West');
    selbox.options[selbox.options.length] = new Option('Perth','Perth');
    selbox.options[selbox.options.length] = new Option('Rottnest Island','Rottnest Island');
    selbox.options[selbox.options.length] = new Option('The Goldfields','The Goldfields');
    selbox.options[selbox.options.length] = new Option('The Heartlands','The Heartlands');
    selbox.options[selbox.options.length] = new Option('The Kimberley','The Kinberley');
    selbox.options[selbox.options.length] = new Option('The Pilbara','The Pilbara');
    selbox.options[selbox.options.length] = new Option('The South-West','The South-West');
  }
}

function setOptionsCreate(chosen) {
  var selbox = document.createaccount.region;	
  selbox.options.length = 0;
  if (chosen == "") {
    selbox.options[selbox.options.length] = new Option('','');
  }

  if (chosen == "ACT") {
    selbox.options[selbox.options.length] = new Option('Canberra and Surrounds','Canberra and Surrounds');
  }
  if (chosen == "NSW") {
    selbox.options[selbox.options.length] = new Option('Blue Mountains','Blue Mountains');
    selbox.options[selbox.options.length] = new Option('Capital Country','Capital Country');
    selbox.options[selbox.options.length] = new Option('Central Coast','Central Coast');
    selbox.options[selbox.options.length] = new Option('Central West','Central West');
    selbox.options[selbox.options.length] = new Option('Hawkesbury','Hawkesbury');
    selbox.options[selbox.options.length] = new Option('Hunter Valley & Coast','Hunter Valley & Coast');
    selbox.options[selbox.options.length] = new Option('Illawarra','Illawarra');
    selbox.options[selbox.options.length] = new Option('Mid North Coast','Mid North Coast');
    selbox.options[selbox.options.length] = new Option('New England','New England');
    selbox.options[selbox.options.length] = new Option('North Coast','North Coast');
    selbox.options[selbox.options.length] = new Option('North West','North West');
    selbox.options[selbox.options.length] = new Option('Snowy Mountains','Snowy Mountains');
    selbox.options[selbox.options.length] = new Option('Southern Highlands','Southern Highlands');
    selbox.options[selbox.options.length] = new Option('Sydney','Sydney');
    selbox.options[selbox.options.length] = new Option('The Murray','The Murray');
    selbox.options[selbox.options.length] = new Option('The Outback','The Outback');
    selbox.options[selbox.options.length] = new Option('The Riverina','The Riverina');
    selbox.options[selbox.options.length] = new Option('The South Coast','The South Coast');
  }
  if (chosen == "NT") {
    selbox.options[selbox.options.length] = new Option('Darwin Region','Darwin Region');
    selbox.options[selbox.options.length] = new Option('The Red Centre','The Red Centre');
  }
  if (chosen == "QLD") {
    selbox.options[selbox.options.length] = new Option('Around Brisbane & Hinterland','Around Brisbane & Hinterland');
    selbox.options[selbox.options.length] = new Option('Brisbane','Brisbane');
    selbox.options[selbox.options.length] = new Option('Brisbane Islands','Brisbane Islands');
    selbox.options[selbox.options.length] = new Option('Capricorn','Capricorn');
    selbox.options[selbox.options.length] = new Option('Darling Downs','Darling Downs');
    selbox.options[selbox.options.length] = new Option('Fraser Island & Coast','Fraser Island & Coast');
    selbox.options[selbox.options.length] = new Option('Gold Coast & Hinterland','Gold Coast & Hinterland');
    selbox.options[selbox.options.length] = new Option('Great Barrier Reef','Great Barrier Reef');
    selbox.options[selbox.options.length] = new Option('Outback & Gulf Country','Outback & Gulf Country');
    selbox.options[selbox.options.length] = new Option('Sunshine Coast & Hinterland','Sunshine Coast & Hinterland');
    selbox.options[selbox.options.length] = new Option('Tropical North','Tropical North');
  }
  if (chosen == "SA") {
    selbox.options[selbox.options.length] = new Option('Adelaide','Adelaide');
    selbox.options[selbox.options.length] = new Option('Adelaide Hills','Adelaide Hills');
    selbox.options[selbox.options.length] = new Option('Barossa Valley','Barossa Valley');
    selbox.options[selbox.options.length] = new Option('Clare Valley & Mid North','Clare Valley & Mid North');
    selbox.options[selbox.options.length] = new Option('Eyre Peninsula & Nullarbor','Eyre Peninsula & Nullarbor');
    selbox.options[selbox.options.length] = new Option('Fleurieu Peninsula','Fleurieu Peninsula');
    selbox.options[selbox.options.length] = new Option('Flinders Ranges & Outback','Flinders Ranges & Outback');
    selbox.options[selbox.options.length] = new Option('Kangaroo Island','Kangaroo Island');
    selbox.options[selbox.options.length] = new Option('Murray Region','Murray Region');
    selbox.options[selbox.options.length] = new Option('The South-East','The South-East');
    selbox.options[selbox.options.length] = new Option('Yorke Peninsula','Yorke Peninsula');
  }
  if (chosen == "TAS") {
    selbox.options[selbox.options.length] = new Option('Bass Strait Islands','Bass Strait Islands');
    selbox.options[selbox.options.length] = new Option('Hobart','Hobart');
    selbox.options[selbox.options.length] = new Option('The East Coast','The East Coast');
    selbox.options[selbox.options.length] = new Option('The Midlands','The Midlands');
    selbox.options[selbox.options.length] = new Option('The North West','The North West');
    selbox.options[selbox.options.length] = new Option('The South-East','The South-East');
    selbox.options[selbox.options.length] = new Option('The South-West','The South-West');
  }
  if (chosen == "VIC") {
    selbox.options[selbox.options.length] = new Option('Bays & Peninsulas','Bays & Peninsulas');
    selbox.options[selbox.options.length] = new Option('East Gippsland','East Gippsland');
    selbox.options[selbox.options.length] = new Option('Goldfields','Goldfields');
    selbox.options[selbox.options.length] = new Option('Goulburn & Murray','Gouldburn & Murray');
    selbox.options[selbox.options.length] = new Option('Grampians & Central West','Grampians & Central West');
    selbox.options[selbox.options.length] = new Option('Mallee Country','Mallee Country');
    selbox.options[selbox.options.length] = new Option('Melbourne','Melbourne');
    selbox.options[selbox.options.length] = new Option('Phillip Island & Gippsland','Phillip Island & Gippsland');
    selbox.options[selbox.options.length] = new Option('South-West Coast','South-West Coast');
    selbox.options[selbox.options.length] = new Option('Spa & Garden Country','Spa & Garden Country');
    selbox.options[selbox.options.length] = new Option('The Legends','The Legends');
    selbox.options[selbox.options.length] = new Option('Yarra Valley & Dandenong Ranges','Yarra Valley & Dandenong Ranges');
  }
  if (chosen == "WA") {
    selbox.options[selbox.options.length] = new Option('Darling Range & Swan Valley','Darling Range & Swan Valley');
    selbox.options[selbox.options.length] = new Option('Esperance & Nullarbor','Esperance & Nullarbor');
    selbox.options[selbox.options.length] = new Option('Great Southern','Great Southern');
    selbox.options[selbox.options.length] = new Option('Outback Coast & Mid-West','Outback Coast & Mid-West');
    selbox.options[selbox.options.length] = new Option('Perth','Perth');
    selbox.options[selbox.options.length] = new Option('Rottnest Island','Rottnest Island');
    selbox.options[selbox.options.length] = new Option('The Goldfields','The Goldfields');
    selbox.options[selbox.options.length] = new Option('The Heartlands','The Heartlands');
    selbox.options[selbox.options.length] = new Option('The Kimberley','The Kinberley');
    selbox.options[selbox.options.length] = new Option('The Pilbara','The Pilbara');
    selbox.options[selbox.options.length] = new Option('The South-West','The South-West');
  }
}
function set_option(chosen) {
  var selbox = document.editaccount.region;	
  selbox.options.length = 0;
  if (chosen == "") {
    selbox.options[selbox.options.length] = new Option('','');
  }

  if (chosen == "ACT") {
    selbox.options[selbox.options.length] = new Option('Canberra and Surrounds','Canberra and Surrounds');
  }
  if (chosen == "NSW") {
    selbox.options[selbox.options.length] = new Option('Blue Mountains','Blue Mountains');
    selbox.options[selbox.options.length] = new Option('Capital Country','Capital Country');
    selbox.options[selbox.options.length] = new Option('Central Coast & Hawkesbury','Central Coast & Hawkesbury');
    selbox.options[selbox.options.length] = new Option('Central West','Central West');
    selbox.options[selbox.options.length] = new Option('Hawkesbury','Hawkesbury');
    selbox.options[selbox.options.length] = new Option('Hunter Valley & Coast','Hunter Valley & Coast');
    selbox.options[selbox.options.length] = new Option('Illawarra','Illawarra');
    selbox.options[selbox.options.length] = new Option('Mid North Coast','Mid North Coast');
    selbox.options[selbox.options.length] = new Option('New England','New England');
    selbox.options[selbox.options.length] = new Option('North Coast','North Coast');
    selbox.options[selbox.options.length] = new Option('North West','North West');
    selbox.options[selbox.options.length] = new Option('Snowy Mountains','Snowy Mountains');
    selbox.options[selbox.options.length] = new Option('Southern Highlands','Southern Highlands');
    selbox.options[selbox.options.length] = new Option('Sydney','Sydney');
    selbox.options[selbox.options.length] = new Option('The Murray','The Murray');
    selbox.options[selbox.options.length] = new Option('The Outback','The Outback');
    selbox.options[selbox.options.length] = new Option('The Riverina','The Riverina');
    selbox.options[selbox.options.length] = new Option('The South Coast','The South Coast');
  }
  if (chosen == "NT") {
    selbox.options[selbox.options.length] = new Option('Darwin Region','Darwin Region');
    selbox.options[selbox.options.length] = new Option('The Red Centre','The Red Centre');
  }
  if (chosen == "QLD") {
    selbox.options[selbox.options.length] = new Option('Around Brisbane & Hinterland','Around Brisbane & Hinterland');
    selbox.options[selbox.options.length] = new Option('Brisbane','Brisbane');
    selbox.options[selbox.options.length] = new Option('Brisbane Islands','Brisbane Islands');
    selbox.options[selbox.options.length] = new Option('Capricorn','Capricorn');
    selbox.options[selbox.options.length] = new Option('Darling Downs','Darling Downs');
    selbox.options[selbox.options.length] = new Option('Fraser Island & Coast','Fraser Island & Coast');
    selbox.options[selbox.options.length] = new Option('Gold Coast & Hinterland','Gold Coast & Hinterland');
    selbox.options[selbox.options.length] = new Option('Great Barrier Reef','Great Barrier Reef');
    selbox.options[selbox.options.length] = new Option('Outback & Gulf Country','Outback & Gulf Country');
    selbox.options[selbox.options.length] = new Option('Sunshine Coast & Hinterland','Sunshine Coast & Hinterland');
    selbox.options[selbox.options.length] = new Option('Tropical North','Tropical North');
  }
  if (chosen == "SA") {
    selbox.options[selbox.options.length] = new Option('Adelaide','Adelaide');
    selbox.options[selbox.options.length] = new Option('Adelaide Hills','Adelaide Hills');
    selbox.options[selbox.options.length] = new Option('Barossa Valley','Barossa Valley');
    selbox.options[selbox.options.length] = new Option('Clare Valley & Mid North','Clare Valley & Mid North');
    selbox.options[selbox.options.length] = new Option('Eyre Peninsula & Nullarbor','Eyre Peninsula & Nullarbor');
    selbox.options[selbox.options.length] = new Option('Fleurieu Peninsula','Fleurieu Peninsula');
    selbox.options[selbox.options.length] = new Option('Flinders Ranges & Outback','Flinders Ranges & Outback');
    selbox.options[selbox.options.length] = new Option('Kangaroo Island','Kangaroo Island');
    selbox.options[selbox.options.length] = new Option('Murray Region','Murray Region');
    selbox.options[selbox.options.length] = new Option('The South-East','The South-East');
    selbox.options[selbox.options.length] = new Option('Yorke Peninsula','Yorke Peninsula');
  }
  if (chosen == "TAS") {
    selbox.options[selbox.options.length] = new Option('Bass Strait Islands','Bass Strait Islands');
    selbox.options[selbox.options.length] = new Option('Hobart','Hobart');
    selbox.options[selbox.options.length] = new Option('The East Coast','The East Coast');
    selbox.options[selbox.options.length] = new Option('The Midlands','The Midlands');
    selbox.options[selbox.options.length] = new Option('The North West','The North West');
    selbox.options[selbox.options.length] = new Option('The South-East','The South-East');
    selbox.options[selbox.options.length] = new Option('The South-West','The South-West');
  }
  if (chosen == "VIC") {
    selbox.options[selbox.options.length] = new Option('Bays & Peninsulas','Bays & Peninsulas');
    selbox.options[selbox.options.length] = new Option('East Gippsland','East Gippsland');
    selbox.options[selbox.options.length] = new Option('Goldfields','Goldfields');
    selbox.options[selbox.options.length] = new Option('Goulburn & Murray','Gouldburn & Murray');
    selbox.options[selbox.options.length] = new Option('Grampians & Central West','Grampians & Central West');
    selbox.options[selbox.options.length] = new Option('Mallee Country','Mallee Country');
    selbox.options[selbox.options.length] = new Option('Melbourne','Melbourne');
    selbox.options[selbox.options.length] = new Option('Phillip Island & Gippsland','Phillip Island & Gippsland');
    selbox.options[selbox.options.length] = new Option('South-West Coast','South-West Coast');
    selbox.options[selbox.options.length] = new Option('Spa & Garden Country','Spa & Garden Country');
    selbox.options[selbox.options.length] = new Option('The Legends','The Legends');
    selbox.options[selbox.options.length] = new Option('Yarra Valley & Dandenong Ranges','Yarra Valley & Dandenong Ranges');
  }
  if (chosen == "WA") {
    selbox.options[selbox.options.length] = new Option('Darling Range & Swan Valley','Darling Range & Swan Valley');
    selbox.options[selbox.options.length] = new Option('Esperance & Nullarbor','Esperance & Nullarbor');
    selbox.options[selbox.options.length] = new Option('Great Southern','Great Southern');
    selbox.options[selbox.options.length] = new Option('Outback Coast & Mid-West','Outback Coast & Mid-West');
    selbox.options[selbox.options.length] = new Option('Perth','Perth');
    selbox.options[selbox.options.length] = new Option('Rottnest Island','Rottnest Island');
    selbox.options[selbox.options.length] = new Option('The Goldfields','The Goldfields');
    selbox.options[selbox.options.length] = new Option('The Heartlands','The Heartlands');
    selbox.options[selbox.options.length] = new Option('The Kimberley','The Kinberley');
    selbox.options[selbox.options.length] = new Option('The Pilbara','The Pilbara');
    selbox.options[selbox.options.length] = new Option('The South-West','The South-West');
  }
}

function validatePwd() {
var invalid = " "; // Invalid character is a space
var minLength = 5; // Minimum length
var pw1 = document.form.password.value;
var pw2 = document.form.password2.value;
// check for a value in both fields.
if (pw1 == '' || pw2 == '') {
alert('Please enter your password twice.');
return false;
}
// check for minimum length
if (document.form.password.value.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}
// check for spaces
if (document.form.password.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else {
if (pw1 != pw2) {
alert ("You did not enter the same new password twice. Please re-enter your password.");
return false;
}
else {
return true;
      }
   }
}
function validatePwd_admin(){
var invalid = " "; // Invalid character is a space
var minLength = 5; // Minimum length
var pw1 = document.form.new_password.value;
var pw2 = document.form.confirm_password.value;
var pw3 = document.form.old_password.value;
// check for a value for old_passsword field
if (pw3 == '' ) {
alert('Please enter your old password.');
return false;
}
// check for a value in both fields.
if (pw1 == '') {
alert('Please enter new password.');
return false;
}
if (pw2 == '') {
alert('Please enter confirm password.');
return false;
}

// check for minimum length
if (document.form.new_password.value.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}
// check for spaces
if (document.form.new_password.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else {
if (pw1 != pw2) {
alert ("You did not enter the same new password twice. Please re-enter your password.");
return false;
}
else {
return true;
      }
   }
}

function checkDropdown(choice) {
    var error = "";
    if (choice == 0) {
       error = "Please select a valid option from the drop-down list.\n";
    }    
return error;
}

function validEmailAddress(email)
{
		invalidChars = " /:,;~"
		if (email == "") 
		{
			return (false);
		}
		for (i=0; i<invalidChars.length; i++) 
		{
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) != -1) 
			{
				return (false);
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1) 
		{
			return (false);
		}
		if (email.indexOf("@",atPos+1) != -1) 
		{
			return (false);
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) 
		{
			return (false);
		}
		if (periodPos+3 > email.length)	
		{
			return (false);
		}
			
		return (true);
}


function validEmailAddress(email)
{
		invalidChars = " /:,;~"
		if (email == "") 
		{
			return (false);
		}
		for (i=0; i<invalidChars.length; i++) 
		{
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) != -1) 
			{
				return (false);
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1) 
		{
			return (false);
		}
		if (email.indexOf("@",atPos+1) != -1) 
		{
			return (false);
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) 
		{
			return (false);
		}
		if (periodPos+3 > email.length)	
		{
			return (false);
		}
			
		return (true);
}

function imagestatus(val,valid,page){
	
document.location='view_image.php?imagestatus='+val+'&statusid='+valid;
}
function competitionsstatus(val,valid,page){
	
document.location='view_competitions.php?competitionsstatus='+val+'&statusid='+valid;
}
function advertorialsstatus(val,valid,page){
	
document.location='view_advertorials.php?advertorialsstatus='+val+'&statusid='+valid;
}
function changestatus(val,valid,page,advid){
	
document.location='currentactive.php?changestatus='+val+'&statusid='+valid+'&s='+page+'&advid='+advid+'&formsubmit=1';
	//alert(document.change.formsubmit.value);
//document.change.submit();
}
function changefeatured(val,valid,page){
	//alert(valid);
document.location='currentactive.php?changefeatured='+val+'&statusid='+valid+'&s='+page+'&formsubmit=1';
//alert(document.change.formsubmit.value);
//document.change.submit();
}
function changehot(val,valid,page){
document.location='currentactive.php?changehot='+val+'& statusid='+valid+'&s='+page+'&formsubmit=1';
//document.change.submit();
}
function changepop(val,valid,page){
	document.location='currentactive.php?changepop='+val+'& statusid='+valid+'&s='+page+'&formsubmit=1';
	//document.change.submit();
}
function changepaid(val,valid,page,advid){
	document.location='paymentreport.php?advid='+advid+'&changepaid='+val+'&statusid='+valid;
	//document.change.submit();
}
function changepaidtype(a,b){
	document.location='paymentreport.php?advid='+b+'&PMethod='+a;
}

function changeplan(val,valid,page){
	document.location='paymentreport.php?changeplan='+val+'&statusid='+valid+'&aid='+page;
	//document.change.submit();
}
function adminAccountValidate() {
        var themessage = "You are required to complete the following field(s): \n\n";
        var valid=1;
        if (document.createaccount.venue_name.value=="") {
                themessage = themessage + " - Venue Name\n";
                valid=0;
        }
        if (document.createaccount.contact_name.value=="") {
                themessage = themessage + " - Contact Name\n";
                valid=0;
        }

        if (document.createaccount.address1.value=="") {
                themessage = themessage + " - Address\n";
                valid=0;
        }

        if (document.createaccount.suburb.value=="") {
                themessage = themessage + " - Suburb\n";
                valid=0;
        }

        if (document.createaccount.state[document.createaccount.state.selectedIndex].value=='') {
                themessage = themessage + " - State\n";
                valid = 0;
        }

        if (document.createaccount.region[document.createaccount.region.selectedIndex].value=='') {
                themessage = themessage + " - Region\n";
                valid = 0;
        }

        if (document.createaccount.postcode.value=="") {
                themessage = themessage + " - Postcode\n";
                valid = 0;
        }

        if (document.createaccount.abn.value=="") {
                themessage = themessage + " - ABN / ACN\n";
                valid = 0;
        }

        if (document.createaccount.phone_number.value=="") {
                themessage = themessage + " - Phone Number\n";
                valid = 0;
        }

        if (document.createaccount.fax_number.value=="") {
                themessage = themessage + " - Fax Number\n";
                valid = 0;
        }

        if (document.createaccount.email.value==""){
                themessage = themessage + " - Email\n";
                valid = 0;
		}
         else if(!validEmailAddress(document.createaccount.email.value))
	{
		themessage = themessage + " - Enter valid Email\n";		
	}
		

        if (document.createaccount.password.value=="") {
                themessage = themessage + " - Password\n";
                valid = 0;
        }else if (document.createaccount.password.value.length<5) {
                themessage = themessage + " - Your password must be at least 5 characters long.\n";
                valid = 0;
        }

        if (document.createaccount.passwordrepeat.value=="") {
                themessage = themessage + " - Confirm Password\n";
                valid = 0;
        }
		
		if(document.createaccount.password.value!=document.createaccount.passwordrepeat.value)
		{
			themessage = themessage + " - Enter Password Same As  Confirm Password ";
			valid = 0;
		}

	if ( ( document.createaccount.plan[0].checked == false ) && ( document.createaccount.plan[1].checked == false ) && ( document.createaccount.plan[2].checked == false ) && ( document.createaccount.plan[3].checked == false ) ) {
		themessage = themessage + " - Plan Type\n";
		valid = 0;
	}

        if (valid == 1) {
                document.createaccount.action="../admin/paymentdetails.php";
                document.createaccount.submit();
                return true;
        } else {
                alert(themessage);
                return false;
        }
        return false;
}

function AccountValidate() {
        var themessage = "You are required to complete the following field(s): \n\n";
        var valid=1;
        if (document.createaccount.venue_name.value=="") {
                themessage = themessage + " - Venue Name\n";
                valid=0;
        }
        if (document.createaccount.contact_name.value=="") {
                themessage = themessage + " - Contact Name\n";
                valid=0;
        }

        if (document.createaccount.address1.value=="") {
                themessage = themessage + " - Address\n";
                valid=0;
        }

        if (document.createaccount.suburb.value=="") {
                themessage = themessage + " - Suburb\n";
                valid=0;
        }

        if (document.createaccount.state[document.createaccount.state.selectedIndex].value=='') {
                themessage = themessage + " - State\n";
                valid = 0;
        }

        if (document.createaccount.region[document.createaccount.region.selectedIndex].value=='') {
                themessage = themessage + " - Region\n";
                valid = 0;
        }

        if (document.createaccount.postcode.value=="") {
                themessage = themessage + " - Postcode\n";
                valid = 0;
        }

        if (document.createaccount.abn.value=="") {
                themessage = themessage + " - ABN / ACN\n";
                valid = 0;
        }

        if (document.createaccount.phone_number.value=="") {
                themessage = themessage + " - Phone Number\n";
                valid = 0;
        }

        if (document.createaccount.fax_number.value=="") {
                themessage = themessage + " - Fax Number\n";
                valid = 0;
        }

        if (document.createaccount.email.value==""){
                themessage = themessage + " - Email\n";
                valid = 0;
		}
         else if(!validEmailAddress(document.createaccount.email.value))
	{
		themessage = themessage + " - Enter valid Email\n";		
	}
		

        if (document.createaccount.password.value=="") {
                themessage = themessage + " - Password\n";
                valid = 0;
        }
		

        if (document.createaccount.passwordrepeat.value=="") {
                themessage = themessage + " - Confirm Password\n";
                valid = 0;
        }
		
		if(document.createaccount.password.value!=document.createaccount.passwordrepeat.value)
		{
			themessage = themessage + " - Enter Password Same As  Confirm Password ";
			valid = 0;
		}

	if ( ( document.createaccount.plan[0].checked == false ) && ( document.createaccount.plan[1].checked == false ) && ( document.createaccount.plan[2].checked == false ) && ( document.createaccount.plan[3].checked == false ) ) {
		themessage = themessage + " - Plan Type\n";
		valid = 0;
	}

        if (valid == 1) {
                document.createaccount.action="../advertiser/paymentdetails.php";
                document.createaccount.submit();
                return true;
        } else {
                alert(themessage);
                return false;
        }
        return false;
}


function advertiserAccountValidate() {
        var themessage = "You are required to complete the following field(s): \n\n";
        var valid=1;
        if (document.editaccount.venue_name.value=="") {
                themessage = themessage + " - Venue Name\n";
                valid=0;
        }

        if (document.editaccount.contact_name.value=="") {
                themessage = themessage + " - Contact Name\n";
                valid=0;
        }

        if (document.editaccount.address1.value=="") {
                themessage = themessage + " - Address\n";
                valid=0;
        }

        if (document.editaccount.suburb.value=="") {
                themessage = themessage + " - Suburb\n";
                valid=0;
        }

        if (document.editaccount.postcode.value=="") {
                themessage = themessage + " - Postcode\n";
                valid = 0;
        }

        if (document.editaccount.phone_number.value=="") {
                themessage = themessage + " - Phone Number\n";
                valid = 0;
        }

        if (document.editaccount.email.value=="") {
                themessage = themessage + " - Email\n";
                valid = 0;
        }

        if (document.editaccount.password.value=="") {
                themessage = themessage + " - Password\n";
                valid = 0;
        }else if (document.editaccount.password.value.length<5) {
                themessage = themessage + " - Password Should be atleast 5 Characters Long.\n";
                valid = 0;
        }

        if (document.editaccount.passwordrepeat.value=="") {
                themessage = themessage + " - Confirm Password\n";
                valid = 0;
        }


        if (valid == 1) {
                document.editaccount.action="../advertiser/ea-parse.php";
                document.editaccount.submit();
                return true;
        } else {
                alert(themessage);
                return false;
        }
        return false;
}



function upgradeAccountValidate() {
        var themessage = "You are required to complete the following field(s): \n\n";
        var valid=1;

        if ( ( document.upgradeaccount.plan[0].checked == false ) && ( document.upgradeaccount.plan[1].checked == false ) && ( document.upgradeaccount.plan[2].checked == false ) ) {
                themessage = themessage + " - See Upgrade notes in FREE account plus\n";
                valid = 0;
        }

        if(!document.upgradeaccount.agree.checked) {
                themessage = themessage + " - Please agree with the terms and conditions\n";
                valid = 0;
        }

        if (valid == 1) {
			
                document.upgradeaccount.action="../advertiser/ua-parse.php";      
                return true;
        } else {
                alert(themessage);
                return false;
        }
        return false;
}

function paybillValidate() {
        var themessage = "You are required to complete the following field(s): \n\n";
        var valid=1;
        
        if (document.paybill.description.value=="") {
                themessage = themessage + " - Please complete a payment description\n";
                valid = 0;
        }        

        if (document.paybill.amount.value=="") {
                themessage = themessage + " - Please enter a valid amount\n";
                valid = 0;
        }       
        
        if (document.paybill.owner.value=="") {
                themessage = themessage + " - Please enter a valid credit card owner\n";
                valid = 0;
        }  
        
        if (document.paybill.creditCard1.value=="") {
                themessage = themessage + " - Please enter a valid credit card number\n";
                valid = 0;
        }      
        
        if (document.paybill.cvvno.value=="") {
                themessage = themessage + " - Please enter a valid CVV number\n";
                valid = 0;
        }                         

        if(!document.paybill.agree.checked) {
                themessage = themessage + " - Please agree with the terms and conditions\n";
                valid = 0;
        }

        if (valid == 1) {
			
                document.paybill.action="https://www.securepay.com.au/securepay/payments/process2.asp";      
                return true;
        } else {
                alert(themessage);
                return false;
        }
        return false;
}

function word_count(text, doc, doc2)
{
     text = text.replace(/^\s*|\s*$/g,'');
     var count_array = text.split(" ");
     doc.value = count_array.length;
}

function word_count2(text, doc, doc2)
{
     text = text.replace(/^\s*|\s*$/g,'');
     var count_array = text.split(" ");
     doc.value = count_array.length;
     //if(doc.value>49) {
		 //doc2.disabled='disabled';
		// alert("50 words or less");
		 //}
}

function word_count3(text, doc, doc2)
{
     text = text.replace(/^\s*|\s*$/g,'');
     var count_array = text.split(" ");
     doc.value = count_array.length;
     //if(doc.value>999) doc2.disabled='disabled';
}

function showhide_show(layer_ref) {
	var state = 'block';
	//display:block
	//display:none
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
	eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
	document.layers[layer_ref].display = state;
	}
	if (document.getElementById && !document.all) {
	maxwell_smart = document.getElementById(layer_ref);
	maxwell_smart.style.display = state;
	}
}
function showhide_hide(layer_ref) {
	var state = 'none';
	//display:block
	//display:none
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
	eval( "document.all." + layer_ref + ".style.display = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
	document.layers[layer_ref].display = state;
	}
	if (document.getElementById && !document.all) {
	maxwell_smart = document.getElementById(layer_ref);
	maxwell_smart.style.display = state;
	}
}