// JavaScript Document

if (navigator.userAgent.indexOf('Opera') != -1 ) {
document.write('<link rel="stylesheet" type="text/css" href="/css/operahack.css">');
}

if (navigator.userAgent.indexOf("Safari") != -1) {
document.write('<link rel="stylesheet" type="text/css" href="/css/safarihack.css">');
}



function move_field() {
	if (document.getElementById("td2_idform17224acf7125edcc1")) {
		document.getElementById("td2_idform17224acf7125edcc1").innerHTML=document.getElementById("td2_idform17224acf7125edcc1").innerHTML+" "+document.getElementById("td2_idform75944acf7608c7703").innerHTML;
		document.getElementById("td2_idform75944acf7608c7703").innerHTML="";
		document.getElementById("tridform75944acf7608c7703").style.display="none";
	
		var ac = new Ajax.Autocompleter('idform17224acf7125edcc1', 'postcodes_autocomplete', '?action=autocomplete_city', {
			paramName: 'value', 
			minChars: 1,
			updateElement: function(el){
				autoCompletePlacer(el);
			}
		});
	
		var ac = new Ajax.Autocompleter('idform75944acf7608c7703', 'postcodes_autocomplete', '?action=autocomplete_city', {
			paramName: 'value', 
			minChars: 1,
			updateElement: function(el){
				autoCompletePlacer(el);
			}
		});

		function autoCompletePlacer(el){
			var txt = el.innerHTML;
			var pcode = txt.substring(0, 4);
	
			var loc = txt.substring(7, txt.length);
	
			$('idform17224acf7125edcc1').value = pcode;
			$('idform75944acf7608c7703').value = loc;
	
	
			return true;
		}

	}
}

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];
}

function move_field_contact() {

	if (!document.getElementById("postcodes_autocomplete")) {
		var xdiv=document.createElement("DIV");
		xdiv.setAttribute("id","postcodes_autocomplete");
		xdiv.style.className="postcodes_autocomplete";
		xdiv.style.display="none";
		document.body.appendChild(xdiv);
	}

	if (document.getElementById("td2_idform495844cf12751e31d")) {
		document.getElementById("td2_idform246044cf12751f2ba").innerHTML=document.getElementById("td2_idform246044cf12751f2ba").innerHTML+" "+document.getElementById("td2_idform495844cf12751e31d").innerHTML;
		document.getElementById("td2_idform495844cf12751e31d").innerHTML="";
		document.getElementById("tridform495844cf12751e31d").style.display="none";

		if (gup("cmp_id")!="" && gup("cmp_id")!="undefined") {
	
			var ac = new Ajax.Autocompleter('idform246044cf12751f2ba', 'postcodes_autocomplete', '?cmp_id='+gup('cmp_id')+'&news_id='+gup('news_id')+'&action=autocomplete_city', {
				paramName: 'value', 
				minChars: 1,
				updateElement: function(el){
					autoCompletePlacer(el);
				}
			});
		
			var ac = new Ajax.Autocompleter('idform495844cf12751e31d', 'postcodes_autocomplete', '?cmp_id='+gup('cmp_id')+'&news_id='+gup('news_id')+'&action=autocomplete_city', {
				paramName: 'value', 
				minChars: 1,
				updateElement: function(el){
					autoCompletePlacer(el);
				}
			});

		} else {

			var ac = new Ajax.Autocompleter('idform246044cf12751f2ba', 'postcodes_autocomplete', '?action=autocomplete_city', {
				paramName: 'value', 
				minChars: 1,
				updateElement: function(el){
					autoCompletePlacer(el);
				}
			});
		
			var ac = new Ajax.Autocompleter('idform495844cf12751e31d', 'postcodes_autocomplete', '?action=autocomplete_city', {
				paramName: 'value', 
				minChars: 1,
				updateElement: function(el){
					autoCompletePlacer(el);
				}
			});

		}

		function autoCompletePlacer(el){
			var txt = el.innerHTML;
			var pcode = txt.substring(0, 4);
	
			var loc = txt.substring(7, txt.length);
	
			$('idform246044cf12751f2ba').value = pcode;
			$('idform495844cf12751e31d').value = loc;
	
	
			return true;
		}

	}
}


StkFunc(move_field);

StkFunc(move_field_contact);