var orderArray = new Array();
orderArray[0] = new Array('label','130','146', '15','9','20','0','164','155','','1');
orderArray[1] = new Array('ribbon','130','157', '15','9','20','0','177','153','','2');
orderArray[2] = new Array('blank','0','0', '10','10','0','0','60','50','','4');
var arrange = new Array(orderArray[2],orderArray[0],orderArray[1]);
// orderArray[0] - Label Roll, [1] - Ribbon, [2] - Blank space

//orderArray[index] = new Array([0 pic title],[1 pic width A],[2 pic height A],[space][3 pic left A],[4 pic left B],
//[5 text left A],[6 text left B],[7 total height A],[8 total height B],[9 alt text],[10 link page]);

//Total ht is reqd as title may be 2 lines.

var ctrArray = new Array('quoteLab','','','-','','Weyfringe supply millions of labels and hundreds of thousands of ribbons every year. This gives us probably the best buying power in the country which, when linked with our quality service, provides an unbeatable package. We test every ribbon and label combination we supply to ensure you only receive compatible consumables. We strive to provide an absolutely first class service reacting to your requirements accurately and without delay to ensure your production keeps rolling without interruption. ','Request Label/Ribbon Quote');
// ctrArray[0] - name, [1] - pic width A, [2] - pic height A, [3] - link, [4] - pic src, [5] - alt text, [6] - page title,
// [optional beyond here] [7] - pic2 width A, [8] - pic2 height A, [9] - pic2 src, [10] - alt text2,
// [11] - pic3 width A, [12] - pic3 height A, [13] - pic3 src, [14] - alt text3,
// [15] - pic4 width A, [16] - pic4 height A, [17] - pic4 src, [18] - alt text4

function setBParams() {
	setTop('quoteLine',960,0);
	setTop('linkTable',1040,0);
	setTop('labRib',550,0);
	setTop('frmAddr',690,0);
	setLeft('frmAddr',20,1);
	setTop('frmLabel',1000,0);
	setTop('frmRibbon',1000,0);
}

//Global Declarations

checkTheseA = new Array('name',0,'addr1','email',0,'telNo',0,'postCode');
checkTheseL = new Array('widthL','length',0,'noAcross',0,0,0,0,0,0,0,'quoteQtyL');
checkTheseR = new Array('widthR','colour',0,'quoteQtyR','prtMake');
checkThese = new Array();

//Functions

function isBlank(val){
	for (var i = 0; i < val.length; i++) {
		var c = val.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) {
			return false;
		}
	}
	return true; //value is blank	
}

var firstBlank;
var offset;
var end;
function validate(index){
	switch(index) {
		case 0:
			checkThese = checkTheseA;
			offset = 0;
			end = 8;
			break;
		case 1:
			checkThese = checkTheseL;
			offset = 8;
			end = 12;
			break;			
		case 2:
			checkThese = checkTheseR;
			offset = 21;
			end = 5;
			break;
		default: 
			checkThese = checkTheseA;
			offset = 2;
			end = 12;
	}
	var fidl = 0;
	firstBlank = null;
	for (var i = 0; i < end; i++) {
		if (checkThese[i]) {
			var a = document.forms[0].elements[i + offset].value;
			if ((isBlank(a)) || (a == null) || (a == '')) {
				setBackgrd(checkThese[i],5);
				if (!fidl) {
					firstBlank = i + offset;
					fidl = 1;
				}
			}
		}
	}
	if (firstBlank != null) {
		alert('Please enter the pink coloured field(s)');
		document.forms[0].elements[firstBlank].focus();
		return;
	}
}

function clean(setField) {
	setBackgrd(setField,2);
}

function clearDown() {
	for (var i = 8; i < 29; i++) {
		if ((i == 10) || (i == 11) || (i == 13) || (i == 17) || (i == 23)) { continue; }
		document.forms[0].elements[i].value = ''
	}
	document.getElementById('material').selectedIndex = 0;
	document.getElementById('plainPrinted').selectedIndex = 0;		
	document.getElementById('directThermal').selectedIndex = 0;
	document.getElementById('ribbon').selectedIndex = 0;
	document.getElementById('samplesR').checked = false;
	document.getElementById('samplesL').checked = false;
	document.getElementById('check').value = false;
	document.getElementById('noAcross').value = 1;
}

function showTable() {
	validate(0);
	if (firstBlank != null) { return; }
	clearDown();
	if (labRib == 1) {
		showVisibility('frmLabel');
		setFocus('widthL');
	} else {
		showVisibility('frmRibbon');
		setFocus('widthR');
	}
	hideVisibility('labRib');
	hideVisibility('quoteLine');
	hideVisibility('linkTable');
}

var labRib = 0;
function showContact(index) {
	showVisibility('frmAddr');
	hideVisibility('click');
	hideVisibility('frmLabel');	
	hideVisibility('frmRibbon');
	labRib = index;
	setFocus('name');
	if (scrnSize == 'B') {
		hideVisibility('labRib');
		hideVisibility('quoteLine');
		hideVisibility('linkTable');
	}
}

function helpOverL() {
	showVisibility('helpBkgdL');
	showVisibility('helpTextL');	
}

function helpOutL() {
	hideVisibility('helpBkgdL');
	hideVisibility('helpTextL');	
}	

function helpOverR() {
	showVisibility('helpBkgdR');
	showVisibility('helpTextR');	
}

function helpOutR() {
	hideVisibility('helpBkgdR');
	hideVisibility('helpTextR');	
}

function setOther() {
	clean('otherMatl3');
	checkTheseL[4] = 'otherMatl3';
	setBackgrd('otherMatl1',6);
	setBackgrd('otherMatl2',6);
	document.forms[0].material.selectedIndex = 2;	
}

function setNumPrePrt() {
	clean('numPrePrt');
	checkTheseL[6] = 'numPrePrt';
	setBackgrd('prePrt',6);
	document.forms[0].plainPrinted.selectedIndex = 2;
}	

function checkSelect(getField,setField1,setField2,setField3,arrInd) {
	var field = document.getElementById(getField);
	var index = field.selectedIndex;
	if (index == 2) {
		setBackgrd(setField1,6);
		setBackgrd(setField2,6);
		checkThese[arrInd] = setField3;
	} else {
		setBackgrd(setField1,2);
		setBackgrd(setField2,2);
		if (getField == 'material') {
			document.forms[0].otherMatl3.value = '';
			checkThese[15] = 0;
		}
		if (getField == 'plainPrinted') {
			document.forms[0].numPrePrt.value = '';
			checkThese[17] = 0;
		}				
	}	
}

function sendForm() {
	validate(labRib);
	if (firstBlank != null) { return; }
	if ((document.getElementById('samplesL').checked) || (document.getElementById('samplesR').checked)) {
		document.getElementById('check').value = 'true';
	}
	checkTheseL[4] = checkTheseL[6] = 0;
	document.forms[0].submit();
}


