arrColorCode = new Array("f3f6f6","f4f4ed","f8f9fb","cbd2d0","eee9da","3b3332","5b3927","49372a","727465","9e9f93","929899","363d43","575e62","005c54","0e4438","6391b0","004c91","202e53","193058","69193b","a7323e","791f24","6c1b2a","ceb487");
arrGlassTypeName = new Array("BASIC", "COMFORT B", "EXCLUSIVE G", "COMFORT A", "EXCLUSIVE E", "COMFORT D", "EXCLUSIVE H", "COMFORT C", "EXCLUSIVE F");

function displayStep(stepNum)
{
  for(i=1;i<=6;i++)
  {
    if(stepNum==i)
    {
      document.getElementById("a_step"+i).className="on";
      document.getElementById("d_step"+i).className="prvky";
      document.getElementById('hide_focus').focus();
    }
    else
    {
      document.getElementById("a_step"+i).className="";
      document.getElementById("d_step"+i).className="prvky hidden";
    }
  }

}

function CDoor(glassType, colorCode, skyLight, bottomBar, orientation, doorFittings, colorCode2, glaassSurface) {

  this.glassType = glassType;
  this.colorCode = colorCode;
  this.skyLight = skyLight;
  this.bottomBar = bottomBar;
  this.orientation = orientation;
  this.doorFittings = doorFittings;
  this.colorCode2 = colorCode2;
  this.glaassSurface = glaassSurface;

  this.generateURL = function () {
   var retVal = "dvere.php?glassType=" + this.glassType + "&colorCode=" + this.colorCode+ "&skyLight=" + this.skyLight + "&bottomBar=" + this.bottomBar + "&orientation=" + this.orientation + "&doorFittings=" + this.doorFittings + "&colorCode2=" + this.colorCode2;
   return retVal;
  }

  this.generateURLPrint = function () {
   var retVal = "tisknout-dvere.php?glassType=" + this.glassType + "&colorCode=" + this.colorCode+ "&skyLight=" + this.skyLight + "&bottomBar=" + this.bottomBar + "&orientation=" + this.orientation + "&doorFittings=" + this.doorFittings + "&colorCode2=" + this.colorCode2 + "&glaassSurface=" + this.glaassSurface;
   return retVal;
  }
  
  this.generateURLRequest = function () {
	   var retVal = "dotaz-na-cenu.php?glassType=" + this.glassType + "&colorCode=" + this.colorCode+ "&skyLight=" + this.skyLight + "&bottomBar=" + this.bottomBar + "&orientation=" + this.orientation + "&doorFittings=" + this.doorFittings + "&colorCode2=" + this.colorCode2 + "&glaassSurface=" + this.glaassSurface;
	   return retVal;
	  }
  
  this.preLoaderStart = function () {
    document.getElementById("imgLeftGlass").style.display = "none";
    document.getElementById("imgRightGlass").style.display = "none";
    document.getElementById("imgDoor").style.visibility = "hidden";
    document.getElementById("imgLoading").style.display = "";
  }
  
  this.preLoaderEnd = function () {
    document.getElementById("imgLeftGlass").style.display = "";
    document.getElementById("imgRightGlass").style.display = "";
    document.getElementById("imgDoor").style.visibility = "visible";
    document.getElementById("imgLoading").style.display = "none";
  }

  this.changeDoorPicture = function (groupColorType) {
    this.preLoaderStart();
    if(document.getElementById("sjednotit").checked)
    {
      if(groupColorType==1)this.colorCode=this.colorCode2;
      else this.colorCode2=this.colorCode;
    }
    document.getElementById("imgDoor").src = myDoor.generateURL();
    if(this.skyLight==1 || this.skyLight==3){document.getElementById("imgLeftGlass").src="svetlik-levy.php?colorCode2="+this.colorCode2+"&skyLight="+this.skyLight;}
    else {document.getElementById("imgLeftGlass").src="images/navrhar/_system/none.png";}
    if(this.skyLight==2 || this.skyLight==3){document.getElementById("imgRightGlass").src="svetlik-pravy.php?colorCode2="+this.colorCode2+"&skyLight="+this.skyLight;}
    else {document.getElementById("imgRightGlass").src="images/navrhar/_system/none.png";}
    
    
    
    //if(this.colorCode!=this.colorCode2){;document.getElementById("sjednotit").disabled=false}
    //else {document.getElementById("sjednotit").checked=true;document.getElementById("sjednotit").disabled=true;}

    this.changeSelection("ds1_gt", 9, parseInt(this.glassType));
    this.changeSelection("ds3_sl", 4, parseInt(this.skyLight));
    this.changeSelection("ds3_gs", 8, parseInt(this.glaassSurface));
    this.changeSelection("ds4_bb", 2, parseInt(this.bottomBar));
    this.changeSelection("ds6_or", 2, parseInt(this.orientation));
    this.changeSelection("ds5_df", 12, parseInt(this.doorFittings));
    this.changeColorSelection("c1_", arrColorCode.length, this.colorCode);
    this.changeColorSelection("c2_", arrColorCode.length, this.colorCode2);

  }

  this.changeSelection = function (objName, count, selectedItem) {
    for(i=0;i<count;i++) if(document.getElementById(objName+i))document.getElementById(objName+i).className = "";
    if(document.getElementById(objName+selectedItem))document.getElementById(objName+selectedItem).className = "current";
  }

  this.changeColorSelection = function (objName, count, selectedItem) {
    for(i=1;i<count;i++)
      if(selectedItem==arrColorCode[i])document.getElementById(objName+selectedItem).className = "barva_current";
      else document.getElementById(objName+arrColorCode[i]).className = "barva";
  }

  this.unifyColor = function (val) {
    this.colorCode2 = this.colorCode;
  }
}

function printDoor()
{
  window.open(myDoor.generateURLPrint(),"tisk","menubar=no,width=550,height=420");
}

function sendRequest()
{
  self.location.href = myDoor.generateURLRequest();
}

var myDoor = new CDoor("00", "f8f9fb", "00", "00", "00", "00", "f8f9fb", 6);     // vytvoření nových objektů
