function addtocart(pid){
  document.form1.productid.value=pid;
  document.form1.command.value='add';
  document.form1.submit();
}

function del(pid){
  if(confirm('Do you really mean to delete this item')){
	document.form1.pid.value=pid;
	document.form1.command.value='delete';
	document.form1.submit();
  }
}

function ddel(pid){
	document.form1.pid.value=pid;
	document.form1.command.value='delete';
	document.form1.submit();
}

function clear_cart(){
  if(confirm('This will empty your shopping cart, continue?')){
	document.form1.command.value='clear';
	document.form1.submit();
  }
}

function update_cart(){
  document.form1.command.value='update';
  document.form1.submit();
}

function toggle2Div(id,flagit) {
  if (flagit=="1"){
    if (document.layers) document.layers[''+id+''].visibility = "show"
	  else if (document.all) document.all[''+id+''].style.visibility = "visible"
	  else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
	}
	else
	  if (flagit=="0"){
	    if (document.layers) document.layers[''+id+''].visibility = "hide"
		  else if (document.all) document.all[''+id+''].style.visibility = "hidden"
		  else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
		}
}

function initialize() {
      if (GBrowserIsCompatible()) {
	    var html = '<p style="text-align: left; font-family: Verdana; font-size: 10px;"><img src="./img/main_page/kozeelogo.png" width="115" alt="Kozee Komforts" /><br /><br /><b>Kozee Komforts</b><br />Komfort House, Boundary Road,<br />Bessingby Industrial Estate, Bridlington<br />YO16 4SD East Yorkshire<br /><br /></p><p style="text-align: right; font-family: Verdana; font-size: 10px;">Tel: +44 (0) 1262 409 200<br />Fax: +44 (0) 1262 602 102</p>';
        var map = new GMap2(document.getElementById("kozee_map"));
        map.setCenter(new GLatLng(54.082954, -0.204766), 15);
        map.addControl(new GSmallMapControl());
        var baseIcon = new GIcon();
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);
        baseIcon.infoShadowAnchor = new GPoint(18, 25);

        function createMarker(point, index) {
          var letter = String.fromCharCode("K".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);
          letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";

          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);
		  		  
          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(html);
          });
          return marker;
        }

        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
        for (var i = 0; i<1; i++) {
        var latlng = new GLatLng(54.080292, -0.209730);
        map.addOverlay(createMarker(latlng, i));
        }
      }
}

function submitForm(formName, navigateValue) {
	if (navigateValue != null && navigateValue != "") {
		document.forms[formName].navigate.value = navigateValue;
	}
    document.forms[formName].submit();
}

function lookup(inputString) {
  if(inputString.length == 0) {			
	$('#suggestions').hide();
  } else {
  $.post("include/rpc.php", {queryString: ""+inputString+""}, function(data){
	if(data.length >0) {
	  $('#suggestions').show();
	  $('#autoSuggestionsList').html(data);
	}
  });
  }
} 

function fill(thisValue) {
  $('#inputString').val(thisValue);
  setTimeout("$('#suggestions').hide();", 200);
}

function setVisibility(id, visibility) {
  document.getElementById(id).style.display = visibility;
}

function IsDeliverySame_clicked() {
  if (document.customerform.IsDeliverySame.checked) {
    document.customerform.DeliveryFirstnames.value = "";
    document.customerform.DeliveryFirstnames.className = "inputBoxDisable";
    document.customerform.DeliveryFirstnames.disabled = true;   
    document.customerform.DeliverySurname.value = "";
    document.customerform.DeliverySurname.className = "inputBoxDisable";
    document.customerform.DeliverySurname.disabled = true;     
    document.customerform.DeliveryAddress1.value = "";
    document.customerform.DeliveryAddress1.className = "inputBoxDisable";
    document.customerform.DeliveryAddress1.disabled = true;
    document.customerform.DeliveryAddress2.value = "";
    document.customerform.DeliveryAddress2.className = "inputBoxDisable";
    document.customerform.DeliveryAddress2.disabled = true;
    document.customerform.DeliveryAddress3.value = "";
    document.customerform.DeliveryAddress3.className = "inputBoxDisable";
    document.customerform.DeliveryAddress3.disabled = true; 	
	document.customerform.DeliveryAddress4.value = "";
    document.customerform.DeliveryAddress4.className = "inputBoxDisable";
    document.customerform.DeliveryAddress4.disabled = true; 
    document.customerform.DeliveryCity.value = "";
    document.customerform.DeliveryCity.className = "inputBoxDisable";
    document.customerform.DeliveryCity.disabled = true;
    document.customerform.DeliveryPostCode.value = "";
    document.customerform.DeliveryPostCode.className = "inputBoxDisable";
    document.customerform.DeliveryPostCode.disabled = true;
    document.customerform.DeliveryPhoneArea.value = "";
    document.customerform.DeliveryPhoneArea.className = "inputBoxDisable";
    document.customerform.DeliveryPhoneArea.disabled = true;
    document.customerform.DeliveryPhonePhone.value = "";
    document.customerform.DeliveryPhonePhone.className = "inputBoxDisable";
    document.customerform.DeliveryPhonePhone.disabled = true;		
 } else {
    document.customerform.DeliveryFirstnames.disabled = false;
    document.customerform.DeliveryFirstnames.className = "inputBoxEnable";
    document.customerform.DeliveryFirstnames.focus();		
    document.customerform.DeliverySurname.disabled = false;
    document.customerform.DeliverySurname.className = "inputBoxEnable";		
    document.customerform.DeliveryAddress1.disabled = false;
    document.customerform.DeliveryAddress1.className = "inputBoxEnable";		
    document.customerform.DeliveryAddress2.disabled = false;
    document.customerform.DeliveryAddress2.className = "inputBoxEnable";		
    document.customerform.DeliveryAddress3.disabled = false;
    document.customerform.DeliveryAddress3.className = "inputBoxEnable";		
    document.customerform.DeliveryAddress4.disabled = false;
    document.customerform.DeliveryAddress4.className = "inputBoxEnable";		
    document.customerform.DeliveryCity.disabled = false;
    document.customerform.DeliveryCity.className = "inputBoxEnable";		
    document.customerform.DeliveryPostCode.disabled = false;
    document.customerform.DeliveryPostCode.className = "inputBoxEnable";			
    document.customerform.DeliveryPhoneArea.disabled = false;
    document.customerform.DeliveryPhoneArea.className = "inputBoxEnable";		
    document.customerform.DeliveryPhonePhone.disabled = false;
    document.customerform.DeliveryPhonePhone.className = "inputBoxEnable";		
 }
}
