// JavaScript Document

function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}

//DELCLARES THE GLOBAL VARIABLES FOR THE SCRIPT

var blind_type = null; // will contain the type of blind as it is being defined
var blind_colour = null; // will contain the reference to the coour selected by the user
var blind_control_position = null; // will contain the position of the blind
var blind_control_drop = null; //will contain the drop length of the controls
var control_colour = null // will contain the colour of controls selected
var control_upgrade = false; // will contain any information upgrading the controls
var blind_measurement_fit = null; //will contain the measurement fit details either inside fit or outside fit
var blind_width = null; // will contain the current width of a blind as it is being defined
var blind_drop = null; // will contain the current height of a blind as it is being defined
var stacked_height = null; // will contain the current stacked height or 'drop' of a blind as it is being defined
var blind_price = null; // will contain the current price of a blind as it is being defined

var blind_array = Array(); // array will contain all the elements of a defined blind before it is committed to the stack
var blind_stack = Array(); // will contain all the blind_array objects


//DECLARES EXTRA, POTENTIALLY CHANGEABLE VARIABLES

var chain_price = 10; // this is the cost of adding a silver coloured chain to a roller blind
var motor_price = 275; // this is the price of a motor and a remote or two!

function reInitialiseGlobals() {
	blind_type = null;
	blind_colour = null;
	blind_control_position = null;
	blind_control_drop = null;
	control_colour = null;
	control_upgrade = false;
	blind_measurement_fit = null;
	blind_width = null;
	blind_drop = null;
	stacked_height = null;
	blind_price = null;
	
	blind_array = Array();
	
	$('#silver_chain').show();
	$('input[name=control_drop]').attr('disabled', false);
}

// BEGIN TO IMPLEMENT OOP VERSION

//CREATE BLIND CLASS
function BrightBlind(name) {
	this.Name = name;
	this.Type = null;					//Options are Aluminium/Wooden/Faux/Roller, with various sub categories
	this.Colour = null;					//Options vary from type to type, material/colour/style of blind itself
	this.ComponentSide = null;			//Options are 'left' or 'right'
	this.ComponentLength = 700;			//Option is a numerical value
	this.FitType = null;				//Options are 'inside' or 'outside'
	this.Width = 500;					//Option is numerical, minimum 500;
	this.Drop = 500;					//Option is numerical, minimum 500;
	this.Price = 0;						//Option is numerical and currency based
	this.Discount = 0;					//Option is a percentage applied at cart to Price
}

// AT CURRENT ONLY THOSE TYPES REQUIRING A DISCOUNT NEED AN OBJECT - PLAN IS TO MOVE WHOLE APP TO OOP
cedar_painted_46mmObj = new BrightBlind();
cedar_painted_60mmObj = new BrightBlind();
cedar_stained_46mmObj = new BrightBlind();
cedar_stained_60mmObj = new BrightBlind();
roller_reg_blockoutObj = new BrightBlind();
roller_reg_blockout_designerObj = new BrightBlind();
roller_reg_sunfilter_classicObj = new BrightBlind();
roller_reg_sunfilter_luxuryObj = new BrightBlind();
roller_reg_sunfilter_designerObj = new BrightBlind();
roller_reg_sunscreenObj = new BrightBlind();
roller_motor_blockoutObj = new BrightBlind();
roller_motor_blockout_designerObj = new BrightBlind();
roller_motor_sunfilter_classicObj = new BrightBlind();
roller_motor_sunfilter_luxuryObj = new BrightBlind();
roller_motor_sunfilter_designerObj = new BrightBlind();
roller_motor_sunscreenObj = new BrightBlind();

cedar_painted_46mmObj.Discount = 25;
cedar_painted_60mmObj.Discount = 25;
cedar_stained_46mmObj.Discount = 25;
cedar_stained_60mmObj.Discount = 25;
roller_reg_blockout_designerObj.Discount = 25;
roller_reg_sunfilter_classicObj.Discount = 25;
roller_reg_sunfilter_luxuryObj.Discount = 25;
roller_reg_sunfilter_designerObj.Discount = 25;
roller_reg_sunscreenObj.Discount = 25;
roller_motor_blockoutObj.Discount = 25;
roller_motor_blockout_designerObj.Discount = 25;
roller_motor_sunfilter_classicObj.Discount = 25;
roller_motor_sunfilter_luxuryObj.Discount = 25;
roller_motor_sunfilter_designerObj.Discount = 25;
roller_motor_sunscreenObj.Discount = 25;

//alert (eval('cedar_stained_60mm' + 'Obj.Discount'));
