function ChangeCountry(dropdown)
{
    var thelocation = location.href.split("?");
	window.location.href = (thelocation[0] + "?cc=" + dropdown);
    return true;
}

function ChangeLanguage(dropdown) //Will not allow you to change the language and keep php variables in url.
{
    var thelocation = location.href.split("?");
	var theURL = thelocation[0];
	// Find position of thrid forward slash: http://www.gpsfarmmap.com/en
	var doubleslashPos = theURL.indexOf("//"); //find index of double forward slash in url
	var singleslashPos = theURL.indexOf("/", doubleslashPos +3); //find position of next forward slash (just before language)
	var urlPartA = theURL.slice(0,singleslashPos);
	var urlPartB = "/" + dropdown;
	var urlPartC = theURL.slice(singleslashPos + 3);
	var	URL = urlPartA + urlPartB + urlPartC;
	
	window.location.href = (URL + "?lang=" + dropdown);
    return true;
}

function ChangeGPS(dropdown) //Will not allow you to change the language and keep php variables in url.
{
	var thelocation = location.href.split("?");
	window.location.href = (thelocation[0] + "?selectGPS=" + dropdown);
    return true;
}
function ChangeSoftware(dropdown) //Will not allow you to change the language and keep php variables in url.
{
    var thelocation = location.href.split("?");
	window.location.href = (thelocation[0] + "?selectSoftware=" + dropdown);
    return true;
}
function ChangeAccessory(checkbox) //Will not allow you to change the language and keep php variables in url.
{
	var thelocation = location.href.split("?");
	if (checkbox.checked == true)
		//alert ("checkbox " + checkbox.value + " checked");
		window.location.href = (thelocation[0] + "?AddAccessory=" + checkbox.value);
	else
		//alert("checkbox " + checkbox.value + " unchecked");
		window.location.href = (thelocation[0] + "?RemoveAccessory=" + checkbox.value);
	 
    return true;
}

function freightclick() { //Select the freight options on products/diygps/buy_online1.php
			if (document.buy_online1_form.aboveaddress.checked==true){
			document.buy_online1_form.freight_street.value = document.buy_online1_form.street.value;
			document.buy_online1_form.freight_city.value = document.buy_online1_form.city.value;
			document.buy_online1_form.freight_state.value = document.buy_online1_form.state.value;
			document.buy_online1_form.freight_zip.value = document.buy_online1_form.zip.value;
			document.buy_online1_form.freight_thecountry.selectedIndex = document.buy_online1_form.thecountry.selectedIndex;
			//alert (document.buy_online1_form.thecountry.selectedIndex);
			}
			}

//Custom JavaScript Functions by Shawn Olson
//Copyright 2006-2008
//http://www.shawnolson.net
//If you copy any functions from this page into your scripts, you must provide credit to Shawn Olson & http://www.shawnolson.net
//*******************************************

		function changecss(theClass,element,value) {
	//Last Updated on June 23, 2009
	//documentation for this script at
	//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
	 var cssRules;

	 var added = false;
	 for (var S = 0; S < document.styleSheets.length; S++){

    if (document.styleSheets[S]['rules']) {
	  cssRules = 'rules';
	 } else if (document.styleSheets[S]['cssRules']) {
	  cssRules = 'cssRules';
	 } else {
	  //no rules found... browser unknown
	 }

	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    if(document.styleSheets[S][cssRules][R].style[element]){
	    document.styleSheets[S][cssRules][R].style[element] = value;
	    added=true;
		break;
	    }
	   }
	  }
	  if(!added){
	  if(document.styleSheets[S].insertRule){
			  document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule) {
				document.styleSheets[S].addRule(theClass,element+': '+value+';');
			}
	  }
	 }
	}