var ad=mat('admin',WD.location),heer=WD.location+'';
if(/[\/?#][^\/]+$/.test(heer))heer=heer.replace(/[\/?#][^\/]+$/,'');
heer=heer.replace(/[\/?#]+$/,'');

xtend('hullb',{
	countries:['Home~Home','Nigeria~Nigeria','South Africa~South Africa','Ghana~Ghana','Angola~Angola',
			"Cote Divoire~C&ocirc;te D'ivoire",'Rest of Africa~Rest of Africa'],
	top:function(){
		var topb=[];if(ad){
			//hullb.countries.length=9;
			topb.push('<a class="dib fr navbar" href="#" onmousedown="return sCMS.admin();">ADMIN</a> ');
		}
		for(var i in hullb.countries){
			var cc=hullb.countries[i].split('~');
			topb.push('<a class="dib fr navbar" href="#" onmousedown="return hullb.loadframe(unescape(\''
				+escape(cc[0])+'\'),'+i+',true);">'+cc[1]+'</a> ');
		}
		return '<div class="wide tar" style="padding:9px 0 0 0"><div class="tar"><div class="tac wide">'
			+topb.reverse().join('')+'<br/>'+eD+eD+eD
			+'<div style="border-bottom:black solid 2px;height:107px;background-image:url('+heer+'/client/img/top-bg.png)" class="wide">'
			+'<img src="client/img/banner-left.jpg" class="dib fl" style=""/>'
			+'<img id="banna" src="client/img/banner-Home.jpg" class="dib fr" style="border-top:black solid 1px;"/>'
			+eD
	},
	section:'Home',
	navs:['Company History & Profile','Our Contact Details','Get a Quotation','Vessel Agency',
		'Oil & Gas Services','Crew Change/Protocol','Project Cargo Support','Logistics/Clearing','Terminal Management',
		'Deconsolidation'],
	texts:{},
	loadframe:function(a,b,c,d){
		if(!a)a='Home';
		if(c)dge('banna').src='client/img/banner-'+(a.split('/')[0])+'.jpg';
		//if(b||a=='Home'){if(a=='Home')b=0;swapclass(dge('navlist'),'navlist'+b,'navlist~d');}
		if(hullb.texts[a]){hullb.printframe(a);if(d)fzz(d)()}
		else new call('data/'+(a.replace(/['\/]/g,''))+'.txt?cc='+Math.round(Math.random()*10000),0,
			"hullb.texts[unescape('"+escape(a)+"')]=a.text;hullb.printframe(unescape('"+escape(a)+"'));"+(d||''));
		return false
	},
	hovermap:function(img,place,activ){
		if(activ){
			img.src='images/hov-'+place+'.png';dr(hullb.texts['hov-'+place],'mainwinL');
		}else{
			img.src='client/img/b.gif';dr(hullb.texts['Home'].split('[split]')[1],'mainwinL');
		}
	},
	sizeup:function(){
		if(!hullb.nightmare || hullb.nightmare==322)return;
		var a=hullb.section,wiide=hullb.width,riight=(a=='Home'||a=='Rest of Africa')?538:490;wiide-=riight;
		dimz(dge('Ltd'),'d',wiide);dimz(dge('mainwinL'),'d',wiide);dimz(dge('Rtd'),'d',riight);dimz(dge('Rtd'),'d',riight);
	},
	printframe:function(a){if(a)hullb.section=a;
		if(!dge('mainwin'))hullb.redraw(a);
		var right_left=hullb.texts[a].split('[split]');hullb.nightmare=false;
		
		if(right_left.length==1){
			dr('<div id="mainwinL" class="oa wide" style="height:452px;">'+right_left[0]+eD,'mainwin');
		}else{
			if(right_left[0].indexOf('[requestform]')!=-1){
				var c='<div id="mainwinL" class="oa wide" style="height:322px;">'
					+right_left[1]+eD
				dr(c,'mainwin');hullb.nightmare=322;
			}else{
				var hii=a=='Home'?388:452,wiide=hullb.width,riight=(a=='Home'||a=='Rest of Africa')?538:490;wiide-=riight;
				var c=tab(1)+'<td id="Ltd" style="width:'+wiide+'px;height:'+hii+'px;"><div id="mainwinL" class="w oa" style="width:'+wiide+'px;height:'+hii+'px;">'
					+right_left[1]+eD
					+'</td><TD><img src="client/img/splitv.jpg" class="dib fl" style="padding:55px 2px 55px 2px;width:2px;height:303px;"/>'
					+'</td><TD id="Rtd" style="width:'+riight+'px;height:'+hii+'px;"><div id="mainwinR" class="oh">'
					+right_left[0]+eD+te;
				dr(c+'<br/>','mainwin');
				if(a=='Home'){
					hullb.nightmare=hii;right_left.shift();right_left.shift();
					hullb.texts['hov-ghana']=right_left.shift();hullb.texts['hov-nigeria']=right_left.shift();
					hullb.texts['hov-angola']=right_left.shift();hullb.texts['hov-cotedivoire']=right_left.shift();
					hullb.texts['hov-southafrica']=right_left.shift();
				}
			}
		}
		hullb.feedback(a);
		if(hullb.nightmare){ dimz(dge('mainwin'),'D',hullb.nightmare);heidi('bottomcontent',1)}
		else{dimz(dge('mainwin'),'D',452);heidi('bottomcontent')}
		dge('mainwinL').scrollTop=0;dge('mainwinL').scrollLeft=0;kl.resize();
		hullb.anipart.trytry();
	},
	aniparts:['tms~http://www.tmssouthafrica.co.za/','multiport~http://www.multiport.org/','nita~http://www.stellartravelghana.com','stellar~http://stellar-africa.com/'],
	anipart:wyle({lifetime:0,id:'party',img:0,prel:new Image(),inter:33,
		testf:"c=hullb.aniparts;if(a.count==1){if(++a.img==c.length)a.img=0;"
			+"d=c[a.img].split('~');dge('myparty').src='client/img/partner-'+d[0]+'.png';"
			+"dge('myparty').parentNode.href=d[1]||'#'}"
			+"if(a.count>300)a.count=0;opcss(100-(Math.abs(a.count-150)/2), dge('myparty'));"
			+"dimz(dge('myparty'),'c',12+12*Math.tan(3.14*(a.count-150)/300));"
	}),
	main:function(a){
		var leftnav='';
		for(var i in hullb.navs){var tx=hullb.navs[i];
			leftnav+='<a class="db ma" href="#" onmousedown="return hullb.loadframe(\''+tx+'\',0,true);">'
				+tx.replace(/&/g,'&amp;')+'</a>'
				+(tx!='Get a Quotation'?'':'<img class="db pup" src="client/img/our_services.gif"/>')
				+(tx!='Deconsolidation'?'':'<img class="db pup" src="client/img/partners.gif"/>'
				+'<div id="partners" style="width:170px;height:130px" class="oh w pup prl">'
					+'<a style="background:transparent" href="#" target="_new"><img id="myparty" class="pab" style="left:200px;border:0" src="client/img/partner-multiport.png"/></a>'
				+eD
				);
		}
		leftnav='<div id="navlist" class="navlist0 dib fl">'+leftnav
			+'<br/>'+eD;
		
		var randy=Math.floor(Math.random()*999999),p=location.protocol=='https:'?'https:':'http:';
		return '<div id="gradblok" class="db cb">'
				+leftnav
				+'<div id="allcontent" style="height:472px" class="dib fl">' // width:715px;height:452px;
					+'<div id="mainwin" class="w" style="border:solid black 1px;margin:6px 0;height:388px">'
					+eD
					+'<div id="bottomcontent">'+eD
				+eD
			+eD
			+hullb.rssbit()
			+'<br/>'
			+tab(1)+'<td class="botnav tal nw" style="width:35%">&nbsp;&copy; 2008 Hull Blyth Group. All rights reserved.</td>'
			+'<td class="botnav tac" style="width:30%">'
			+'<a href="#" onmousedown="return hullb.loadframe(\'Privacy Policy\');">Privacy Policy</a>'
			+' | '
			+'<a href="#" onmousedown="return hullb.loadframe(\'Legal Notice\');">Legal Notice<a/> </td>'
			+'<td style="width:35%" class="botnav tar nw"><span style="color:#312C8A">Powered by: </span><a href="http://helloelastic.co.uk" target="_nu"><span style="color:#D97215">Elastic Design</span></a>&nbsp; '
			+'</div>'
			+eD
	},
	anigif:["West Africa's foremost independent ship agent and services provider",
		"We've got the African Coast covered, from Djibouti to Mauritania",
		"Now with unmatched travel services for crew change, oil and gas, mining and shipping industries"
	],
	fillform:function(a){
		hullb.loadframe('Our Contact Details',0,0,a?"dge('comtxt').value=unescape('"+escape(a)+"');":'');
	},
	feedback:function(a,b){
		if(a=='Home')b='<div id="reqform" class="wide" style="height:66px;color:white;margin:2px 0;border:#00899E solid 1px;background-image:url(client/img/gogo.png)">'
			+'<div id="reqformT" class="db wide" style="height:60px;">'
				+(hullb.dunintro?hullb.hometexts[hullb.hometexts.length-1]:'')
			+eD+eD;
		else b='<div id="reqform" style="font-size:10px;margin:2px 0;padding:8px 8px 0 8px;height:120px;border:#00899E solid 1px;background-image:url(client/img/reqform.png)">'
			+'<div class="dib fl" style="padding:0 8px 0 0">'
				+'<img src="images/happy.jpg" style="border:#00899E solid 1px;">'
			+eD
			+'<div class="dib fl" style="padding:0 8px 0 0">'
			+'<div class="w" style="font-size:12px;height:61px;border:#00899E solid 1px;padding:4px 8px;">'
				+'PETER JAMES<br/>Business Development Manager<br/>'
				+'Tel: + 233 244 332394<br/>Fax:+ 233 244 303053'
			+eD+eD
			+'<div class="dib fl">'
				+'<textarea id="comtxt" class="w p2" style="font-family:Arial;font-size:11px;width:413px;height:64px;border:#00899E solid 1px;" onblur="if(this.value==\'\')this.value=\'Your request\';" onmousedown="if(this.value==\'Your request\')this.value=\'\';">Your request</textarea>'
			+eD
			+'<br/>'
			+'<div class="dib fl">Your name:<br><input class="boti" type="text" id="yrname">'+eD
			+'<div class="dib fl">Your company:<br><input class="boti" type="text" id="yrcomp">'+eD
			+'<div class="dib fl">Your email:<br><input class="boti" type="text" id="yrmail">'+eD
			+'<div class="dib fl">Your telephone:<br><input class="boti" type="text" id="yrtele">'+eD
			+'<div class="dib fl"><img alt="submit" onmousedown="hullb.sendform()" src="client/img/submit.png" style="margin:11px 0 0 0">'+eD
		+eD
		dr(b,'bottomcontent');
		if(a=='Home'&&!hullb.dunintro)hullb.hometext.go()
	},dunintro:false,
	hometexts:["<div class='tac' style='font-size:14px;padding-top:16px'>West Africa's foremost independent ship agent and services provider<br/><b><i>We've got the African Coast covered, from Djibouti to Mauritania</i></b>"+eD,
		"<div class='tac' style='font-size:14px;padding-top:22px'>Now with unmatched travel services for crew change, oil and gas, mining and shipping industries"+eD,
		'<div class="dib fl" style="padding:8px 16px;font-size:18px;"><i><b>feel free to leave us<br/>a comment or suggestion</b></i></div>'
			+'<input id="comsug" type="text" class="dib fl" style="border:#00899E solid 1px;padding:4px;margin:18px 0 0 2px;width:380px"><img class="dib fl bUt" style="padding:8px 0" src="client/img/go.png" onmousedown="hullb.fillform(dge(\'comsug\').value)">'
	],
	hometext:wyle({id:'aniban',lifetime:0,inter:2000,
		startf:"a.op=0;a.dir=-5;a.numb=0;",
		testf:"if(a.op>99){a.inter=2000;a.dir=-5}else{a.inter=200}"
			+"if(a.numb>=hullb.hometexts.length&&a.op>99)return true;"
			+"if(a.dir<0&&a.op>0){a.op+=a.dir;opcss(a.op,dge('reqformT'))}" // fade out
			+"else if(a.op<1){opcss(1,dge('reqformT'));dr(hullb.hometexts[a.numb++],'reqformT');a.dir=10;a.op=5}" // replace text
			+"else{a.op+=a.dir;opcss(a.op,dge('reqformT'))}", // fade in
		endf:"opcss(100,dge('reqformT'));hullb.dunintro=true;"
	}),
	sendform:function(){
		var a=dge('comtxt').value,b=a=='Your request',
			c='name='+ex(dge('yrname').value)+'&comp='+ex(dge('yrcomp').value)
				+'&mail='+ex(dge('yrmail').value)+'&tele='+ex(dge('yrtele').value)
		if(b||!a)alert('Please enter your\ncomments/suggestions!');
		else new call('php/sendit.php',c+'&mess='+ex(a),"alert('Message sent!\\nThank you for contacting Hull Blyth.');"
			+"hullb.loadframe('Home');")
	},
	rssbit:function(){
		hullb.news();
		return '<div class="db wide cb" style="line-height:22px;font-size:12px;height:24px;background-color:#1D323A;background-image:url('+heer+'/client/img/rss_b.gif);">'
			+'<img class="fl" src="client/img/rss_l.gif"/>'
			+'<img class="fr" src="client/img/rss_r.gif"/>'
			+'<div class="dib fl"><a style="color:white;text-decoration:none" type="application/rss+xml" href="http://www.lloydslist.com/content/rss/lloydslist/all_headlines.xml"><img class="vm" style="padding:1px;border:0" src="client/img/rss.png">RSS News Feeds |</a></div>'
			+'<div id="tiktok" class="dib fl" style="height:24px;width:745px"><div class="prl nw oh wide" style="height:24px"><div id="rssfeed" class="oh nw pab rlink">'+eD+eD+eD
			+eD
	},
	newsdata:'',
	news:function(){
		if(!hullb.newsdata){new call('php/rssread.php',"feed="
			+ex("http://www.lloydslist.com/content/rss/lloydslist/all_headlines.xml"),
			"hullb.newsdata=a.text;hullb.news();");
			return
		}
		var parsed=hullb.newsdata.split('</item>'),heads=[];parsed.shift();
		for(var i in parsed){
			if(/<title>(.+?)<\/title>\s+<link>(.+?)<\/link>/.test(parsed[i]))
			heads.push('<a target="_rss" href="'+RegExp.$2+'">'+RegExp.$1+'</a>')
		}
		parsed=heads.join(' | ');
		dr(parsed,'rssfeed');
		hullb.newstick.go()
		//return '<div class="oa" style="height:220px">'+parsed+'</div>'
	},
	newstick:wyle({id:'newws',lifetime:0,inter:55,x:0,xL:0,
		startf:"a.x=dimz(dge('tiktok'),'d')+15;a.xL=-dge('rssfeed').scrollWidth;",
		testf:"a.x--;dimz(dge('rssfeed'),'c',a.x);if(a.x<a.xL)a.x=dimz(dge('tiktok'),'d')+15;"
	}),
	redraw:function(a){
		var stuff='<div id="floor" style="width:'+hullb.width+'px;margin:0px auto">'+hullb.top()+hullb.main(a)+eD
		dr(stuff,'field')
	},
	width:Math.min(1280,Math.max(bios.x1-70,902))
});

var lhnz='td,body{font-family:Arial;font-size:12px}.pup{padding:3px 0px}',ni=3;while(ni--)
	lhnz+='.navlist'+ni+' a{width:149px;height:21px;font-size:11px;color:#fff;padding:0 0 0 7px;margin:0 0 0 11px;text-decoration:none;'
		+'background-image:url('+heer+'/client/img/lcols/up'+ni+'.gif);background-repeat:no-repeat}img{border:0px none}'
		+'.boti{border:#00899E solid 1px;margin:0px 6px 0 0;width:152px;height:23px;}'
		+'h1{color:#0087A0;font-size:19px;padding:2px 0 0 0}h2{color:#0087A0;font-size:17px;padding:2px 0 0 0}'
		+'h3{color:#0087A0;font-size:14px;margin:5px 0 3px 0;padding:0px}'
		+'.navlist'+ni+' a:hover{background:url('+heer+'/client/img/over.gif) no-repeat;color: #000000;}'
		+'.rlink a{text-decoration:none;color:#CBE0E8}.rlink a:hover{color:white}'
		+'.navlist'+ni+' a:active{background:url('+heer+'/client/img/over.gif) no-repeat;color:#1e5ebd;}';

kl.addcss(lhnz);
kl.addcss();
kl.sized.push(fzz("a=hullb.width=Math.min(1280,Math.max(bios.x1-70,902));dimz(dge('floor'),'d',a);dimz(dge('allcontent'),'d',a-178);dimz(dge('mainwin'),'d',a-188);dimz(dge('tiktok'),'d',a-155);hullb.sizeup();"));
hullb.loadframe('Home',0,0,"kl.resize();");


if(ad){
	new call('client/riched.js',0,'fzz(a.text)()');
	new call('admin/launchCMS.js',0,'fzz(a.text)()');
	xtend('sCMS',{
		intoDIV:'gradblok',style:lhnz,
		xinstructions:'<h3>Important Special Cases</h3><p>The <b>Home</b> section also contains the mouse-hover content for the dynamic Africa map.</p>'
			+'<p>Do not accidently delete occurances of the special phrase <b>[split]</b>, which is used to split these sections up.'
			+'<p>The country pages also use <b>[split]</b>, to separate the images on the right from the content on the left. Again, be careful when '
			+'editing not to delete the word <b>[split]</b>.</p>'
			+'<p>The other special case is pages which require a request form below them. Use the keyword <b>[requestform]</b>, followed by <b>[split]</b> to set this up. You must use square brackets!',
		redraw:fzz("hullb.redraw();"),
		edtexts:[
		// left hand nav
			'Company History & Profile','Our Contact Details','Get a Quotation',
		// our services
			'Vessel Agency','Oil & Gas Services',
			'Crew Change/Protocol','Project Cargo Support',
			'Logistics/Clearing','Terminal Management','Deconsolidation',
		// bot left
		// Countries
			'Angola',"Cote Divoire",'Home','Ghana','Nigeria',
	        'South Africa','Rest of Africa',
		// other
			'Privacy Policy','Legal Notice'
		]
	});
}