
function hh(id, name) {
    this.id = id;
	this.name = name;
	this.children = new Array();
	this.add = hh_add;
}

function hh_add(code, name) {
	this.children[this.children.length] = {"code" : code, "name" : name};
}

var h = new Array();

h[11] = new hh('11','On another website');
h[11].add('9485','NOW.CO.UK');
h[11].add('9430','THESUN.CO.UK');
h[11].add('6445','Other');
h[11].add('5464','Facebook Fan Page');
h[11].add('7585','YouTube');
h[11].add('5018','Confetti.co.uk');
h[11].add('7219','Website Video Chat Show');
h[11].add('4779','Bounty.com');
h[3] = new hh('3','Event/Exhibition');
h[3].add('9433','Milton Keynes Fashion Show');
h[3].add('9359','VQ  SHOPIING AFFAIR');
h[3].add('9480','FASHION SHOW AT OCEANA');
h[3].add('9377','West Yorkshire W.I AGM');
h[3].add('9482','Princes Trust Lunch');
h[7] = new hh('7','Magazine article/feature/review');
h[7].add('9381','COMPANY');
h[7].add('9385','Essentials');
h[7].add('9473','Look');
h[7].add('9379','New magazine');
h[7].add('9476','Now');
h[7].add('9423','Prima');
h[7].add('9419','Red');
h[7].add('6930','STYLIST MAGAZINE');
h[7].add('9383','She');
h[7].add('9435','Woman');
h[7].add('9421','Woman Diet Special');
h[7].add('6202','Other');
h[7].add('6143','Local magazine article');
h[17] = new hh('17','TV');
h[17].add('9450','Bravissimo TV advert');
h[17].add('9374','This Morning');
h[6] = new hh('6','Magazine advertisement');
h[6].add('9391','Closer (code Closer FP 11/09)');
h[6].add('9442','COMPANY (CODE COMPANY FP 12/09)');
h[6].add('9438','COSMO (CODE COSMO FP 12/09)');
h[6].add('9425','Easy Living (code Easy Living 12/09 ad)');
h[6].add('9387','Glamour (code Glam FP 12/09)');
h[6].add('4714','Best (code Best 10/09 ad)');
h[6].add('4992','Company (code Company 10/09 ad)');
h[6].add('5638','Good Housekeeping (code GHK 11/09 ad)');
h[6].add('9446','She (code She FP 12/09)');
h[6].add('6823','She (code She 10/09 ad)');
h[6].add('6201','Other');
h[6].add('9427','Vogue (code Vogue 12/09 ad)');
h[6].add('6666','Red (code Red 11/09 ad)');
h[10] = new hh('10','Newspaper article/feature/review');
h[10].add('9429','The Sun');
h[10].add('9370','NEWCASTLE EVENING CHRONICLE');
h[10].add('9367','Liverpool Echo Oct 09 (Reg PR)');
h[10].add('6345','Other');
h[10].add('6149','local newspaper article');
h[5] = new hh('5','Leaflet in a magazine/newspaper');
h[5].add('9403','Best (Insert code IBest 11/09A)');
h[5].add('9407','Best (Insert code IBest 11/09B)');
h[5].add('9411','Heat (Insert code IHeat 11/09A)');
h[5].add('9415','Heat (Insert code IHEAT 11/09B)');
h[5].add('9395','SAINSBURY\'S MAGAZINE (INSERT CODE ISAINS 12/09A)');
h[5].add('9399','Sainsbury\'s Magazine (Insert code ISains 12/09B)');
h[5].add('6088','Woman & Home (insert code IWOMAN 12/09A)');
h[5].add('6089','Woman & Home (Insert code IWOMAN 12/09B)');
h[15] = new hh('15','Recommended by friend/family/other');
h[15].add('9362','Nancy Stevens');
h[15].add('6690','Refer a Friend HS09');
h[16] = new hh('16','Search engine');
h[16].add('6003','OTHER');
h[16].add('5667','Google');
h[13] = new hh('13','Passing by a Bravissimo Shop');
h[13].add('6848','Aberdeen');
h[13].add('4871','Brighton');
h[13].add('4881','Cambridge');
h[13].add('6849','Cardiff');
h[13].add('4904','Chester');
h[13].add('5175','Covent Garden');
h[13].add('5304','Ealing');
h[13].add('5336','Edinburgh');
h[13].add('5594','Glasgow');
h[13].add('6850','Leamington');
h[13].add('6103','Leeds');
h[13].add('6120','Liverpool Shop');
h[13].add('6158','London - Oxford Circus');
h[13].add('6205','Manchester');
h[13].add('6851','Milton Keynes Shop');
h[13].add('6343','Newcastle');
h[13].add('6351','Norwich Shop');
h[13].add('6357','Nottingham');
h[13].add('6448','Oxford');
h[13].add('6892','Solihull');
h[12] = new hh('12','Outdoor media');
h[12].add('6923','On the street quiz in cardiff');
h[9] = new hh('9','Newspaper advert');
h[9].add('6346','Other');


function bindHowHeard() {
	select = $.$(pageId+"howHeardDdl");
	if (select == null) {
		return;
	}
	select.onchange = function() {
		bindHowHeard2(select);
	}
	if (select.selectedIndex > 0) {
		var s = $.$(pageId + "howHeardDdl2");
		if (s.options.length > 0) {
			row = $.$("howheardrow");
			row.className = "show";
		}
	}
}

function bindHowHeard2(el) {
	row = $.$("howheardrow");
	if (el.selectedIndex == 0) {
		row.className = "";
		return;
	}
	var s = $.$(pageId + "howHeardDdl2");
	s.options.length = 0;
	
	ix = -1;
	thisText = el.options[el.selectedIndex].value;
	for (i in h) {
		if (h[i].id == thisText) {
			ix = i;
			break;
		}
	}
	if (ix == -1) {
		row.className = "";
		return;
	}
	o = h[ix];
	
	if (o.children.length == 0) {
		row.className = "";
		return;			
	}
	
	s.options.add(new Option("-- please select --", "null"));
	for (i=0; i<o.children.length; i++) {
		s.options.add(new Option(o.children[i].name, o.children[i].code));	
	}		
	row.className = "show";
}