// ajf.js - ajax javascript functions

function ajax_call(x, y, cb){
  // which php function?
  if (cb == 'price_blurb_products1'){
    eval("x_get_price_blurb1(x, " + cb + ")");
  }else if(cb == 'static'){
    eval("x_get_static(x, y, " + cb + ")");
/*  }else if(cb == 'price_blurb_topten'){
    eval("x_get_price_blurb2(x, y, " + cb + ")");  */
  }else{
    eval("x_get_price_blurb(x, y, " + cb + ")");
  }
}

function price_blurb_topten(response){
  var text, x, y;
  x = response.split('~');

  // format some HTML
  text = "<h4>Door Style:</h4><h4 class=\"colourh4\" style=\"font-size:2em;\">" + x[3] + "</h4><h4>Colour Description:</h4><h4 class=\"colourh4\">" + x[4];
  text+= "</h4><br /><p>This drawer: &nbsp;<span id=\"price\">&pound;" + x[2] + "</span><br  />This door: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"price\">&pound;"+ x[1] + "</span>";
  text+= "</p>";  

  document.getElementById("pricediv").innerHTML = text;
}
function price_blurb_products1(response){
  var text, x, y;
  x = response.split('~');

  // format some HTML
  text = "<p>";
  if (x[1] != 0){
    text+= x[2] +": <span>&pound;" + x[1] + "</span><br /><br />";
  }
  text+= x[0] + "</p>";  

  document.getElementById("infoblurbtext").innerHTML = text;
}
function price_blurb_products2(response){
  var text, x, y;
  x = response.split('~');

  // format some HTML
  text = "<p>" + x[0];
  if (x[1] == -1){
    text+= "<br /><br /><span style=\"color:red;font-size: 12px;\">Unfortunately, we can't manufacture this combination of Style and Colour!";

    y = document.getElementById("infodoorbuttons");
    if (y)
      y.style.visibility = "hidden";

  }else{
    if (x[1] != ""){
      text+= "<br /><br />This drawer: &nbsp;<span id=\"price\">&pound;" + x[2] + "</span><br  />This door: &nbsp;&nbsp;&nbsp;&nbsp;<span class=\"price\">&pound;"+ x[1] + "</span>";
    }
  }
  text+= "</p>";  

  document.getElementById("infoblurbtext").innerHTML = text;
}
function static(response){
    var x,y,z;

    y = response.split('.');
    z = y[0];
    if (z == "Shaker"){
      z = "Contemporary";
    }
    x = "<h4>A "+ z +" style kitchen</h4>";
    z = "<p>There are <span>"+ y[1] +"</span> designs and up to <span>"+ y[2] +"</span> colours for our "+ z +" ranges.</p>";

    document.getElementById("infosmttext").innerHTML = x + z;
}
