var ad=mat('admin',WD.location),heer=WD.location+'';
if(/[\/?#][^\/]+$/.test(heer))heer=heer.replace(/[\/?#][^\/]+$/,'');
heer=heer.replace(/[\/?#]+$/,'');

xtend('stellar',{
	texts:{},
	loadframe:function(a,b){
		if(!a)a='Home';var c=a!='Contact';
		heidi('clients',c?0:1);heidi('howhelp',c?1:0);
		if(stellar.texts[a])stellar.printframe(a);
		else new call('data/'+(a.replace(/['\/]/g,''))+'.txt?cc='+Math.round(Math.random()*10000),0,
			"stellar.texts[unescape('"+escape(a)+"')]=a.text;stellar.loadframe(unescape('"+escape(a)+"'));");
		return false
	},
	printframe:function(a){
		if(!dge('mainwin'))stellar.redraw();
		dge('reveal').src='reveals/'+a+'.jpg';
		dr(stellar.texts[a],'mainwin');dge('mainwin').scrollTop=0;dge('mainwin').scrollLeft=0;
		if(a=='Services'){
			dge('name').value=stellar.pfform.name||'';
			dge('mail').value=stellar.pfform.mail||'';
			dge('tele').value=stellar.pfform.tele||'';
			dge('mess').value=stellar.pfform.mess||'';
			dge('service').selectedIndex=stellar.pfform.dex||0;
		}
	},
	makedrops:function(ad){
		heidi('dd_1');heidi('dd_2');
		if(ad)heidi('dd_'+ad,1);
		return false
	},
	onebut:function(butty){
		return '<div class="bUt" style="line-height:27px;padding:0px 4px;background-color:#025D95;font-size:11px;color:white;font-weight:bold;border-top:#003366 solid 1px"'
			+' onmouseover="stellar.naving=true;this.style.color=\'yellow\';" onmouseout="this.style.color=\'white\';return stellar.outnav()"'
			+' onmousedown="return stellar.loadframe(\''+butty+'\');">'
			+butty.replace(/&/g,'&amp;').replace(/ /g,'&nbsp;')+eD
	},
	naving:false,
	outnav:function(){
		stellar.naving=false;
		setTimeout("if(!stellar.naving)stellar.makedrops();",200)
		return false
	},
	dropdown:function(title,index,drops){
		var dd='<div class="dib fl" style="font-size:12px">'
			+'<div class="prl arrow"'
			+' onmouseout="this.style.backgroundImage=\'\';" onmouseover="this.style.background=\'url('+heer+'/client/img/chrome.gif)\'; stellar.naving=true;return stellar.makedrops('+index+');">'
			+title.replace(/&/g,'&amp;')+'&nbsp;<img src="client/img/drop.png">'
			+'<div id="dd_'+index+'" class="pab" style="display:none;top:'+(nav.IE&&nav.IE<8?20:29)+'px;left:0px;border-left:#003366 solid 2px;border-right:#003366 solid 2px;border-bottom:#003366 solid 2px;border-top:#003366 solid 1px;">';
		for(var i in drops)dd+=stellar.onebut(drops[i]);
		dd+=eD+eD+eD;
		return dd;
	},
	topbuts:function(){
		var sep='<div class="dib fl" style="padding:4px 8px"><div style="height:23px;width:1px;background:#B5E2FE"></div></div>';
		return '<div style="font-size:14px;line-height:32px;">'
			+(ad?('<div class="dib fl">'
				+'<div class="prl bUt" onmouseout="this.style.backgroundImage=\'\';" onmouseover="this.style.background=\'url('+heer+'/client/img/chrome.gif)\'; stellar.naving=true;return stellar.outnav();">'
					+'<span style="line-height:25px" onmousedown="return sCMS.admin();">&nbsp;Admin&nbsp;</span>'
				+eD
			+eD
			+sep):'')
			//+stellar.dropdown('About Us',1,['Home'],'Home') // ,'Management Team'
			+'<div class="dib fl" style="font-size:12px"><div class="prl bUt" onmouseout="this.style.backgroundImage=\'\';" onmouseover="this.style.background=\'url('+heer+'/client/img/chrome.gif)\';return stellar.outnav()" onmousedown="return stellar.loadframe(\'Home\')">Home'+eD+eD
			+sep
			+stellar.dropdown('Products & Services',2,['Vessel Agency','Freight Management & Logistics','Travel Agency Services', 'Hospitality Division','Manpower Division','Real Estate Services','Furnished Offices','Base Management'])
			+sep+'<div class="dib fl" style="font-size:12px"><div class="prl bUt" onmouseout="this.style.backgroundImage=\'\';" onmouseover="this.style.background=\'url('+heer+'/client/img/chrome.gif)\';return stellar.outnav()" onmousedown="return stellar.loadframe(\'Contact\')">Contact'+eD
			+eD
		+eD
	},
	aniparts:['tms~http://www.tmssouthafrica.co.za/','hb~http://www.hull-blyth.com/','multiport~http://www.multiport.org/','nita~http://www.nitatours.com','stellar~http://stellar-africa.com/'],
	anipart:wyle({lifetime:0,id:'party',img:0,prel:new Image(),inter:33,
		testf:"c=stellar.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));"
	}),
	newsdata:'',
	newstick:wyle({id:'newws',lifetime:0,inter:95,y:0,yL:0,
		startf:"a.y=222;a.yL=-dge('rssfeed').scrollHeight;",
		testf:"a.y--;dimz(dge('rssfeed'),'C',a.y);if(a.y<-dge('rssfeed').scrollHeight)a.y=222;"
			+"return !dge('rssfeed');"
	}),
	news:function(){
		if(!stellar.newsdata)new call('php/rssread.php',"feed="+ex(heer+"/data/News.xml"),
			"stellar.newsdata=a.text;stellar.news();")
		var parsed=stellar.newsdata.split('<item>'),heads=[];parsed.shift();
		for(var i in parsed){
			if(/<title>(.+?)<\/title>\s+<link>(.+?)<\/link>/.test(parsed[i]))
			heads.push('<a class="rlink" target="_rss" href="'+RegExp.$2+'">'+RegExp.$1+'</a>')
		}
		parsed=heads.join('<br/><br/>');
		dr(parsed,'rssfeed');
		return '<div class="prl oh" style="width:156px;height:220px"><div id="rssfeed" style="top:220px" class="prl">'+parsed+'</div>'
	},
	clients:function(){
		setTimeout("stellar.anipart.trytry();",1000);
		return '<div id="partners" style="width:160px;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
	},
	howhelp:function(){
		return '<br/><select id="service" name="service" class="sell"><option value="How can we help?">How can we help?</option><option value="Vessel Agency">Vessel Agency</option><option value="Freight Management">Freight Management</option><option value="Travel Agency">Travel Agency</option><option value="Manpower Division">Manpower Division</option><option value="Real Estates">Real Estates</option><option value="Furnished Offices">Furnished Offices</option><option value="Base Management">Base Management</option></select>'
			+'<div>Your Name:</div><input id="_name" style="width:120px;" type="text">'
			+'<div>Telephone:</div><input id="_tele" style="width:120px;" type="text">'
			+'<div>E-mail:</div><input id="_mail" style="width:120px;" type="text">'
			+'<input type="button" value="submit" onmousedown="return stellar.fillform();">'
	},
	pfform:{},
	fillform:function(){
		stellar.pfform.name=dge('_name').value||'';
		stellar.pfform.tele=dge('_tele').value||'';
		stellar.pfform.mail=dge('_mail').value||'';
		stellar.pfform.dex=dge('service').selectedIndex||0;
		stellar.loadframe('Services');
	},
	sendform:function(){
		var a=dge('mess').value,b=a=='Your request',
			c='name='+ex(dge('name').value)+'&mail='+ex(dge('mail').value)+'&tele='+ex(dge('tele').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 Stellar.');"
			+"stellar.loadframe('Home');")
	},
	rightbox:function(title,id,img,height,content,shh){
		return '<div id="'+id+'" style="'+(shh?'display:none':'')+'">'
			+'<div style="margin:0 0 10px 4px;">'
			+'<div class="bbak">'
			+'<img src="client/img/blue-tl.png" class="fl">'
			+'<img src="client/img/blue-tr.png" class="fr">'
			+tab(1)+'<td class="whed" style="width:99%">'
			+title+'</td><td>'+'<img class="fr" src="client/img/icon-'+img+'.gif">'+te
			+'<div class="w news" style="'+(height?'height:'+height+'px;':'')
			+'margin:4px 4px 0 4px">'+content+eD
			+'</div><div class="grr">'
			+tab(1)+'<td><img src="client/img/blue-bl.png"></td><td style="width:99%;background-color:#025D95;">'
				+'&nbsp;</td>'
			+'<td><img src="client/img/blue-br.png"></td></table>'+eD
			+eD+eD
	},
	righthand:function(){
		return '<div class="dib fl vt" style="width:176px;">'
			+stellar.rightbox('How can we help','howhelp','help',178,stellar.howhelp())
			+stellar.rightbox('News Feed','newsf','news',221,stellar.news())
			+stellar.rightbox('Partners &amp; Affiliates','clients','clients',178,stellar.clients(),true)
			+stellar.rightbox('Downloads','download','download',0,'<div style="height:69px"><br/><a onmousedown="return stellar.loadframe(\'downloads\')" href="#">Get PDF downloads of Industry Information</a></div>')
			+eD
	},
	botty:function(){
		return '<div class="wide oh" style="height:11px;">'
			+'<img src="client/img/w2sea-bl.gif" class="fl">'
			+'<img src="client/img/w2sea-br.gif" class="fr">'
			+'<br/>'
		+eD
		+'<div class="oh" style="background-color:#336699;height:20px;">'
			+'<img src="client/img/blue2-bl.gif" style="line-height:20px;" class="fl vb">'
			+'<div class="dib fr copys" style="line-height:20px">'
			+'<a href="#" onmousedown="return stellar.loadframe(\'Copyright Statement\');">Copyright Statement</a>'
			+' - '
			+'<a href="#" onmousedown="return stellar.loadframe(\'Disclaimer\');">Disclaimer</a>'
			+' - '
			+'<a href="#" onmousedown="return stellar.loadframe(\'Privacy\');">Privacy</a> &nbsp;  &nbsp; '
			+'<img src="client/img/blue2-br.gif" class="vb"></div>'
			+'<br/>'
		+'</div>'
	},
	redraw:function(){
		var stuff='<div style="width:875px;margin:8px auto" class="oh">'
				+'<img class="dib fl" style="padding:0 4px 0 0" src="client/img/sidebar.jpg">'
				+'<div class="dib fl" style="width:795px;">'
					+'<img onmousedown="return stellar.loadframe()" class="bUt db cb" src="client/img/topbar.gif"><div>'
					+'<div class="dib fl w" style="width:606px">'
						+'<img src="client/img/white-tl.png" class="fl">'
						+'<img src="client/img/white-tr.png" class="fr">'
						+'<div id="topbuts" class="fr">'+stellar.topbuts()+eD+'<br/>'
						+'<img id="reveal" style="height:177px;width:606px;" src="reveals/home.png">'
						+'<div id="mainwin" class="wide oa" style="height:376px;width:606px">'+eD
						
						+stellar.botty()
					+eD
					+stellar.righthand()
				+eD
			+eD;
		dr(stuff,'field');
		stellar.newstick.go();
	},
	stylez:'td,body{font-family:Arial;font-size:12px}.pup{padding:3px 0px}'
		+'.grr td,tr{line-height:5px;font-size:5px;height:5px}.grr {line-height:5px;font-size:5px;height:5px}'
		+'.news{font-size:11px;padding:0 4px}.sell{font-size:11px;}.cmargin{margin:4px 9px;font-family:Arial;font-size:12px}'
		+'.copys{font-size:11px;color:#99CCFF} .copys a{text-decoration:none;color:#99CCFF} .copys a:hover{color:#FFFFFF} '
		+'.bbak{background-color:#025D95;}'
		+'.fbf{width:140px;background-color:#025D95;color:white;padding:3px;margin:3px;line-height:18px;}'
		+'.fbfi input{border:#025D95 solid 1px;padding:4px;margin:4px;line-height:18px;}'
		+'.fbft textarea{border:#025D95 solid 1px;}'
		+'.whed{padding:3px 0 0 4px;color:white;font-weight:bold}.style2{font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; color: #002F65; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; }'
});

kl.addcss(stellar.stylez);
kl.addcss();
stellar.loadframe();

if(ad){
	new call('client/riched.js',0,'fzz(a.text)()');
	new call('admin/launchCMS.js',0,'fzz(a.text)()');
	xtend('sCMS',{
		intoDIV:'mainwin',style:stellar.stylez,
		onstart:function(){
			heidi('reveal');dimz(dge('mainwin'),'D',500)
		},
		folders:['images','downloads'],
		redraw:fzz("stellar.redraw();"),
		edtexts:['Home','Base Management','Contact','Copyright Statement','Disclaimer','downloads','Freight Management & Logistics','Furnished Offices','Contact','Management Team','Manpower Division','Privacy','Real Estate Services','Hospitality Division','Travel Agency Services','Vessel Agency','News']
	});
}