$(document).ready(function(){
	loadModule(document.getElementById("content").className);
});

function loadModule(mod){
    var modules = "home,about,perfume,collections,bags,archive,diana,news,contacts";
    if (modules.indexOf(mod) > -1) {
        var c = document.getElementById("content");
		var html;
        //clearHtml(c);
		$("#content").hide();
        if (mod == 'about') {
            c.className = "about";
        } else if (mod == 'perfume') {
			c.className = "perfume";
			html = '';
        } else if (mod == 'contacts') {
			c.className = "contacts";
        } else if (mod == 'diana') {
			c.className = "diana";
			html = '<div class="showbox"></div><div class="link"><a href="http://www.gettyimages.com" target="_blank">Photographs by Tim Graham available from: www.gettyimages.com</a></div><div class="page"><a href="#" onclick="loadSubModule(\'\',\'1\')">1</a> <a href="#" onclick="loadSubModule(\'\',\'2\')">2</a> <a href="#" onclick="loadSubModule(\'\',\'3\')">3</a> <a href="#" onclick="loadSubModule(\'\',\'4\')">4</a> <a href="#" onclick="loadSubModule(\'\',\'5\')">5</a> <a href="#" onclick="loadSubModule(\'\',\'6\')">6</a></div>';
			c.innerHTML = html;
        } else if (mod == 'bags') {
			c.className = "bags";
			html = '<div class="menu"><p><b><small>Please Select:</small></b></p><p><a href="#" onclick="loadSubModule(\'2008\');return false;">Spring/Summer 2008<a/></p><p><a href="#" onclick="loadSubModule(\'2007\');return false;">Autumn/Winter 2007</a></p></div>';
			c.innerHTML = html;
		} else if (mod == 'collections') {
			c.className = "collections";
			html = '<div class="lefttext"><p>The AZAGURY shop in Knightsbridge offers a ready made collection available from stock.  If we do not have your size or you would prefer a different colour, fabric or maybe adapted to suit you, we will be able to make it to order to your measurements.<br/><br/>If you would like to meet with the designer JACQUES AZAGURY an appointment is advisable, otherwise we operate as a normal shop where our knowledgeable staff will be able to assist you.<br/><br/>We look forward to welcoming you.<br/><br/>Monday to Friday 9.30 to 5.30<br/>Saturday 12.00 to 4.00<br/>Sunday closed<br/><br/>AZAGURY<br/>50 KNIGHTBRIDGE<br/>LONDON SW1X 7JN<br/><br/>TEL: 020 7245 1216</p></div><div class="menu"><p><b><small>Please Select:</small></b></p><p><a href="#" onclick="loadSubModule(\'2010a\');return false;">A Selection from Spring/Summer 2010<a/></p><p><a href="#" onclick="loadSubModule(\'2009b\');return false;">A Selection from Autumn/Winter 2009<a/></p><p><a href="#" onclick="loadSubModule(\'2009\');return false;">A Selection from Spring/Summer 2009<a/></p><p><a href="#" onclick="loadSubModule(\'2008\');return false;">A Selection from Spring/Summer 2008</a></p><p><a href="#" onclick="loadSubModule(\'2007a\');return false;">A Selection from Autumn/Winter 2007</a></p><p><a href="#" onclick="loadSubModule(\'2007s\');return false;">A Selection from Spring/Summer 2007</a></p></div>';
			c.innerHTML = html;
		} else if (mod == 'archive') {
			c.className = "archive";
			html = '<div class="showbox"><table><tbody><tr><th>Please Select:</th></tr>';
			html += '<tr><td><a href="#" onclick="loadSubModule(\'vogue\');return false;"><img src="archive/vogue.gif" /></a></td></tr>';
			html += '<tr><td><a href="#" onclick="loadSubModule(\'elle\');return false;"><img src="archive/elle.gif" /></a></td></tr>';
			html += '<tr><td><a href="#" onclick="loadSubModule(\'tatler\');return false;"><img src="archive/tatler.gif" /></a></td></tr>';
			html += '<tr><td><a href="#" onclick="loadSubModule(\'harpers\');return false;"><img src="archive/harpers.gif" /></a></td></tr></tbody></table></div>';
			c.innerHTML = html;
		} else if (mod == 'news') {
			c.className = "news";
			loadNews(1);
		} 
		$("#content").fadeIn();
    }
}

function loadNews(page){
			var news = [];
			news[0] = ['<b>Febuary, 2009. V&A</b><br />"Hats: An Anthology" launch at the V&A',1];
			news[1] = ['<b>January, 2009. PASHION magazine</b><br />Model featured in PASHION magazine wearing AZAGURY dress.',1];
			news[2] = ['<b>January, 2009</b><br />Jenni Faulkner models <b>AZAGURY</b>.',1];
			news[3] = ['<b>January, 2009. h&f news newspaper</b><br />Davina McCall is featured wearing <b>AZAGURY</b> dress.',1];
			news[4] = ['<b>January, 2009. Woman and Home magazine</b><br />Julie Walters featured on the cover of Woman and Home magazine wearing <b>AZAGURY</b> dress.',1];
			news[5] = ['<b>30th December, 2008. PRIDE magazine</b><br />Model featured in PRIDE magazine wearing AZAGURY dresses.',5];
			news[6] = ['<b>30th December, 2008. OK magazine</b><br />"The Saturdays" girl band featured in OK magazine wearing AZAGURY dresses.',1];
			news[7] = ['<b>November, 2008, Daily Mail newspaper</b><br />Daily Mail reader offer',2];
			news[8] = ['<b>December, 2008. OK magazine</b><br />Norwood/Ravenswood charity dinner',2];
			news[9] = ['<b>November, 2008. HELLO! magazine</b><br />Tamara Beckwith featured in HELLO! magazine wearing AZAGURY dress.',1];
			news[10] = ['<b>November, 2008. CANDiD magazine</b><br />Model wears AZAGURY dress in CANDiD magazine',1];
			news[11] = ['<b>November, 2008, FRAU magazine</b><br />AZAGURY parfume featured in Japanese magazine',1];
			news[12] = ['<b>8th October, 2008. Tatle magazine</b><br />Tatler previews AZAGURY fragrance',1];
			news[13] = ['<b>September, 2008. HERS magazine</b><br />Jacques Azagury was a guest in Japan for the opening of Princess Diana Exhibition and the launch of his new fragrance',1];
			news[14] = ['<b>September, 2008. Japanese Magazine</b><br />Jacques Azagury was a guest in Japan to attend the opening The Diana Exhibition and for launch of his new fragrance',2];
			news[15] = ['<b>6th Julyl, 2008, Scotland on Sunday magazine</b><br />Jacques Azagury\'s apartment featured in Scotland on Sunday magazine',1];
			news[16] = ['<b>18th January, 2008. Evening Standard</b><br />Helena Bonham Carter wears <b>AZAGURY</b> red silk taffeta full length opera coat. ',1];
			news[17] = ['<b>12th May, 2008. Daily Mail</b><br />Fashion Designer Jacques Azagury\'s Central London apartment looks like a hotel room - but that\'s just the way he likes it...',1];
			news[18] = ['<b>18th April, 2008. The London Paper</b><br />Sophie Ellis Bextor at <b>AZAGURY</b> Fragrance Launch',1];
			news[19] = ['<b>17th April, 2008</b><br /><b>AZAGURY</b> FRAGRANCE LAUNCH AT SELFRIDGES',3];
			news[20] = ['<b>1st April, 2008. OK Magazine</b><br />Lisa Butcher wears <b>AZAGURY</b> dress',1];
			news[21] = ['<b>Evening Standard</b><br />Newsreader Emily Maitlis appears on Evening Standard wearing <b>AZAGURY</b>',1];
			news[22] = ['<b>Childline</b><br />Lisa B wears <b>AZAGURY</b> for "Childline" charity fashion show',1];
			news[23] = ['<b>Daily Mail</b><br />Interview with Jacques Azagury for Daily Mail',1];
			news[24] = ['Denise wears <b>AZAGURY</b> dress',2];
			news[25] = ['Jenni Eclair wears <b>AZAGURY</b> dress',1];
			news[26] = ['<b>29th August 2007</b><br />Fox News<br />Jacques Azagury is Interviewed by Martha MacCallum for Fox News. ',1];
			news[27] = ['<b>6th August 2007</b><br />Richard & Judy - Chanell 4<br />Jacques Azagury takes part in a debate to discuss \'the high street copyists of Designer clothing.',0];
			news[28] = ['<b>5th August</b><br />Jacques Azagury features in the 3-part series The Diana Years on SKY One.',0];
			news[29] = ['<b>24th July</b><br />Carly Zucker, Joe Coles fiancee, appears in OK magazine wearing <b>AZAGURY</b>',1];
			news[30] = ['<b>9th July 2007</b><br />Jacques Azagury participates in the filming of ODE TO DIANA for TBS television with famous Japanese actress Hitomi Kuroki to be broadcast on Japanese television to an audience of 20.000.000.',1];
			news[31] = ['<b>2ND July</b><br />Jacques Azagury is featured with brother shoe designer Joseph Azagury in German Magazine ICON.',2];
			news[32] = ['<b>29th June</b><br />Jacques Azagury?accepts an Honoury Fellowship from the Arts Institute at Bournemouth Graduation Ceremony.',1];
			news[33] = ['<b>27th June</b><br />Jacques Azagury takes part in the filming of the finals of AMERICAN PRINCESS with Paul Burrell and presented by Catherine??Oxenburg. To be broadcast in the USA beg.August on the \'WE\' network and shortly after on ITV.',1];
			news[34] = ['Helen Mirren wears <b>AZAGURY</b> dress',0];
			news[35] = ['Emily Maitlis',1];
			news[36] = ['<b>15TH OF APRIL</b><br />Jacques Azagury appears on Australian Princess on ITV2 where he dresses four finalists and Princess Olga Romanoff in Azagury evening wear',1];
			news[37] = ['<b>2ND OF APRIL</b><br />Jacques is asked to accept the AWARD OF DESIGN FELLOW of the Arts Institute',0];
			news[38] = ['<b>15th OF MARCH</b><br />Jacques is approached by the V&A as one of the top 150 creative people in the world to be included in 150th Anniversary Album and to create a page for the Album',0];
			news[39] = ['Sharon Osbourne',0];
			news[40] = ['Angela Gheorghiu',2];
			news[41] = ['Katherine Jenkins',2];
			news[42] = ['Nancy Dell\'Olio',1];
	var html;
	html = '<table width="90%" align="center"><tbody><tr><td align="center" width="350">';
	if((page-1)>0){
		html += '<a href="#" onclick="loadNews('+(page-1)+');return false;">Page up</a>';
	}else{
		html += 'Page up';
	}
	html += '</td><td></td></tr>';
	for(var i=0;i<5;i++){
		if(((page-1)*5+i-news.length)>=0){
			html += '<tr><td align="center"></td><td></td></tr>';
		}else{
			if(news[(page-1)*5+i][1]>0){
				html += '<tr><td align="center"><a href="#" onclick="loadSubModule(\''+((page-1)*5+i+1)+'\',0,'+news[(page-1)*5+i][1]+');return false;"><img src="news/'+((page-1)*5+i+1)+'.gif" /></a></td><td><a href="#" onclick="loadSubModule(\''+((page-1)*5+i+1)+'\');return false;">'+news[(page-1)*5+i][0]+'</a></td></tr>';
			}else{
				html += '<tr><td align="center"><img src="news/'+((page-1)*5+i+1)+'.gif" /></td><td>'+news[(page-1)*5+i][0]+'</td></tr>';
			}
		}
	}
	html += '<tr><td align="center">';
	if((page+1)<=9){
		html += '<a href="#" onclick="loadNews('+(page+1)+');return false;">Page down</a>';
	}else{
		html += 'Page down';
	}
	html += '</td><td></td></tr></tbody></table>';
	$("#content").html(html);
}

function loadSubModule(smod,page){
	var c = document.getElementById("content");
	var mod = c.className;
	var html,path;
	page = page==undefined?0:page;
	path = mod+'/'+smod;
	if(mod=="diana"){
		showLarge(path+'/'+page+".gif");
	}
	if(mod=="news"){
		if($("#newlayer").length<1){
			$("#content").append('<div id="newlayer"></div>');
		}
		$("#newlayer").html('<div class="showbox"></div>');
		$("#newlayer").show();
		showLarge(path+'-'+(page+1)+".gif");
		html = '<table class="page" align="center"><tbody><tr><td>';
		if(page-1>=0){
			html += '<a href="#" onclick="loadSubModule(\''+smod+'\','+(page-1)+')">Previous Page</a> ';
		}else{
			html += 'Previous Page ';
		}
		html += '</td><td> - </td><td><a href="#" onclick="$(\'#newlayer\').fadeOut();return false;">News list</a></td><td> - </td><td>';
		if(page+1<arguments[2]){
			html += '<a href="#" onclick="loadSubModule(\''+smod+'\','+(page+1)+')"> Next Page</a>';
		}else{
			html += ' Next Page';
		}
		html += '</td></tr></tbody></table>';
		$("#newlayer").append(html);
	}
	if(mod=="archive"){
		var n = [];
		n['vogue'] = 8;
		n['elle'] = 6;
		n['tatler'] = 4;
		n['harpers'] = 7;
		$("#content .showbox").html('');
		showLarge(path+'/'+(page+1)+".gif");
		$("#content .page").remove();
		html = '<table class="page" align="center"><tbody><tr><td>';
		if(page-1>=0){
			html += '<a href="#" onclick="loadSubModule(\''+smod+'\','+(page-1)+')">Previous Page</a> ';
		}else{
			html += 'Previous Page ';
		}
		html += '</td><td> - </td><td><a href="#" onclick="loadModule(\'archive\')">Archive</a></td><td> - </td><td>';
		if(page+1<n[smod]){
			html += '<a href="#" onclick="loadSubModule(\''+smod+'\','+(page+1)+')"> Next Page</a>';
		}else{
			html += ' Next Page';
		}
		html += '</td></tr></tbody></table>';
		$("#content").append(html);
	}
	if(mod=="collections"){
		var captions = [];
		var totalpages = [];
		captions['2010a'] = ['T17','T34','T20','T29','T29+T24','T2','T7','T7+T25','T7+T6','T13','T13+T14','T15','S7','S7+S8*','T9','S28','T8','T43+T26','T43+T10','T43+T16','T30','T4','T4+T3','T31','T23','T19','T1','T12','T32','T33','T35','T28','T21','T22','T11','T5 FRONT','T5 BACK','T18'];
		captions['2009b'] = ['S12-S13','S14','S7-S8','S7-S19','S11-S9','S26','S6','S2','S3','S21','S4' ,'S20' ,'S23' ,'R48' ,'S5' ,'PURPLE DRESS' ,'S1' ,'R44' ,'S25' ,'S16' ,'S15' ,'S17' ,'R39'];
		captions['2009'] = ['R7','R15','R35/R31','R10/R14','R11/R22','R21/R27','R19','R33/R26','R24','R20','R30','R3/R4','R2','Q5','R18','R5','R27','R16','R29','R37','R36','R1','R6','R28','R2e','Q2'];
		

		
		captions['2008'] = ['P25/P26','P25','P16','P37/P25','P5','P3','P4','P31','O56','P10','P6','P17','P11','O62','P15','P20','P18','P13/P14','P2','P1','P9/P9a','P38','O55','O57','P32','P30','P28','O41','O41','O61','P8','P12','P33','O29','O46','P22','P27','O13','P29','P36','O47/O48','P35/P34'];
		captions['2007a'] = ['','','','','','','','','','','','','','','','','','',''];
		captions['2007s'] = ['','','','','','','','','','','','','','','','','','','','','','','','','','','','','',''];
		totalpages['2010a'] = 3;
		totalpages['2009b'] = 2;
		totalpages['2009'] = 2;
		totalpages['2008'] = 3;
		totalpages['2007a'] = 2;
		totalpages['2007s'] = 2;
		html = '<table cellspacing="20"><tbody>';
		var n;
		for(var i = 0; i < 16; i++){
			if(i%4==0) html += '<tr>';
			if(captions[smod].length-page*16-i > 0){
				if ((smod=='2009b') || (smod=='2010a')) { html += '<td><img src="'+path+'/'+'s'+(i+page*16+1)+'.jpg" onmouseover="showLarge(\''+path+'/'+'b'+(i+page*16+1)+'.jpg\')" /><br />'+captions[smod][i+page*16]+'</td>';} else {
				html += '<td><img src="'+path+'/'+'s'+(i+page*16+1)+'.gif" onmouseover="showLarge(\''+path+'/'+'b'+(i+page*16+1)+'.gif\')" /><br />'+captions[smod][i+page*16]+'</td>';}
			}else{
				html += '<td></td>';
			}
			if(i%4==3) html += '</tr>';
		}
		html += '</tbody></table>';
		html += '<div class="showbox"></div>';
		if(page==0){
			html += '<div class="page"><< Previous Page - <a href="#" onclick="loadModule(\'collections\');$(\'#topnavigation a\').eq(3).addClass(\'hover\')">Collections</a> - <a href="#" onclick="loadSubModule(\''+smod+'\','+(page+1)+');return false;">Next Page</a> >></div>';
		}else if(page==totalpages[smod]-1){
			html += '<div class="page"><< <a href="#" onclick="loadSubModule(\''+smod+'\','+(page-1)+');return false;">Previous Page</a> - <a href="#" onclick="loadModule(\'collections\');$(\'#topnavigation a\').eq(3).addClass(\'hover\')">Collections</a> - Next Page >></div>';
		}else{
			html += '<div class="page"><< <a href="#" onclick="loadSubModule(\''+smod+'\','+(page-1)+');return false;">Previous Page</a> - <a href="#" onclick="loadModule(\'collections\');$(\'#topnavigation a\').eq(3).addClass(\'hover\')">Collections</a> - <a href="#" onclick="loadSubModule(\''+smod+'\','+(page+1)+');return false;">Next Page</a> >></div>';
		}
		c.innerHTML = html;		
	}
	if(mod=="bags"){
		var n = [];
		n[2008] = 25;
		n[2007] = 13;
		html = '<table cellspacing="10"><tr><td><h3>Azagury Bags Collection '+smod+'</h3></td></tr><tr><td>Please Select:</td></tr><tr><td><table cellspacing="20"><tbody>';
		for(var i = 0; i < 16; i++){
			if(i%4==0) html += '<tr>';
			if(n[smod]-page*16-i > 0){
				html += '<td><img src="'+path+'/'+'s'+(i+page*16+1)+'.gif" onmouseover="showLarge(\''+path+'/'+'b'+(i+page*16+1)+'.gif\')" /></td>';
			}else{
				html += '<td></td>';
			}
			if(i%4==3) html += '</tr>';
		}
		html += '</tbody></table></td></tr><tr><td>';
		if(n[smod]>16){
			if(page==0){
				html += '<a href="#" onclick="loadSubModule(\''+smod+'\',\'1\');return false;">Next Page</a>';
			}else if(page==1){
				html += '<a href="#" onclick="loadSubModule(\''+smod+'\');return false;">Previous Page</a>';
			}
		}
		html += '</td></tr><tr><td>Please email us for information on how to purchase items</td></tr></table><div class="showbox" style="position: absolute; display: inline; "></div>';
		c.innerHTML = html;		
	}
}

function showLarge(url){
	$("#content .showbox").hide();
	$("#content .showbox").css("background","url("+url+") center no-repeat");
	$("#content .showbox").fadeIn();
}

function clearHtml(obj){
    obj.innerHTML = "";
    obj.removeAttribute("class");
	obj.removeAttribute("style");
}