var moduleRunning = false

function showModule (url, parameters, container) {

//	clearInterval (directory)
	clearTimeout (timeout);

	var css = document.createElement("link");
	css.setAttribute ("type", "text/css");
	css.setAttribute ("rel", "stylesheet");
	css.setAttribute ("href", "/style/" + defaultLang + "/" + url + ".css");
	document.getElementsByTagName("head")[0].appendChild(css);

	var script = document.createElement("script");
	script.setAttribute ("type", "text/javascript");
	script.setAttribute ("src", "/script/" + url + ".js");
	document.getElementsByTagName("head")[0].appendChild(script);

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}

	divContainer = container
	document.getElementById(divContainer).innerHTML = '<table width="960" class="loading" cellspacing="0" cellpadding="0"><tr><td align="center"><img src="images/ajax-loading.gif" border="0"></td></tr></table>'

	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET", 'showModule.php?module='+url+'&'+parameters,true)
	xmlHttp.send(null)
	
//  	directory = setInterval('showAds ()', 5000)
	if(go == 0){
		timeout = setTimeout("scrollFromSide()",50);
	};


}

function PostRequest (url, parameters, container) {

//	clearInterval (directory)
	clearTimeout (timeout);

	var css = document.createElement("link");
	css.setAttribute ("type", "text/css");
	css.setAttribute ("rel", "stylesheet");
	css.setAttribute ("href", "/style/" + defaultLang + "/" + url + ".css");
	document.getElementsByTagName("head")[0].appendChild(css);

	var script = document.createElement("script");
	script.setAttribute ("type", "text/javascript");
	script.setAttribute ("src", "/script/" + url + ".js");
	document.getElementsByTagName("head")[0].appendChild(script);

	xmlHttp=GetPostXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}

	divContainer = container
	document.getElementById(divContainer).innerHTML = '<table width="960" class="loading" cellspacing="0" cellpadding="0"><tr><td align="center"><img src="images/ajax-loading.gif" border="0"></td></tr></table>'

	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open('POST', url + '.php', true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);

//  	directory = setInterval('showAds ()', 5000)
	if(go == 0){
		timeout = setTimeout("scrollFromSide()",50);
	};
}

/**

	Directory
	
**/

var type = 0;

function showAds () {

	var container
	var directorytype

//	alert (type);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}

	if (type == 0) {
		container = 'AviationDirectory'
		directorytype = 'A'
		type++
	}
	else {
		if (type == 1) {
			container = 'MaritimeDirectory'
			directorytype = 'M'
			type++
		}
		else {
			container = 'LogisticsDirectory'
			directorytype = 'L'
			type = 0
		}
	}
	divContainer = container
//	document.getElementById(divContainer).innerHTML = '<table class="loadingDirectory" cellspacing="0" cellpadding="0"><tr><td align="center"><img src="images/ajax-loading.gif" border="0"></td></tr></table>'

	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET", 'getAds.php?dt=' + directorytype,true)
	xmlHttp.send(null)

}

/**

	Add as Homepage
	
**/

function addBookmarkForBrowser(objSender) {

	if (document.all) {
//		window.external.AddFavorite(document.location.href , document.title);
		objSender.style.behavior = 'url(#default#homepage)';
		objSender.setHomePage (self.location.href);
	} else {
		var ea = document.createEvent("MouseEvents");
		ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
		var eb = document.getElementsByTagName("head")[0];
		eb.ownerDocument.getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
		eb.dispatchEvent(ea);
	}
	
}


/**

	Scrolling AlliancePartners 
	
**/

var pWidth = 0;
var speed = 5; // change scroll speed with this value

/**
 * Get a collection of all of the objects of a particular type, can pass in an object that they should be collected from.
 */

function getElementsByTagNames(list,obj) {
  if (!obj) var obj = document;
  var tagNames = list.split(',');
  var resultArray = new Array();
  for (var i=0;i<tagNames.length;i++) {
    var tags = obj.getElementsByTagName(tagNames[i]);
    for (var j=0;j<tags.length;j++) {
      resultArray.push(tags[j]);
    };
  };
  var testNode = resultArray[0];
  if(!testNode){
    return [];
  };
  if(testNode.sourceIndex){
    resultArray.sort(function(a,b){
      return a.sourceIndex - b.sourceIndex;
    });
  }else if(testNode.compareDocumentPosition){
    resultArray.sort(function(a,b){
      return 3 - (a.compareDocumentPosition(b) & 6);
    });
  };
  return resultArray;
}
 
/**
 * Initialize the marquee, and start the marquee by calling the marquee function.
 */
function init(){
  var div = document.getElementById("marquee");
  div.style.overflow = 'hidden';
  
  var ps = getElementsByTagNames('p',div);
  for(var j=0;j<ps.length;j++){
    pWidth += ps[j].offsetWidth;
  }
 
  var startdiv = document.getElementById("start");
  startdiv.style.width = pWidth+'px';
  div.scrollLeft = 0;
  setTimeout("scrollFromBottom()",50);
}
 
var go = 0;
var timeout = '';
 
/**
 * This is where the scroll action happens.
 * Recursive method until stopped.
 */
function scrollFromSide(){
  clearTimeout(timeout);
  var el = document.getElementById("marquee");
  if(el.scrollLeft >= pWidth-1000){
    el.scrollLeft = 0;
  };
  el.scrollLeft = el.scrollLeft+speed;
  if(go == 0){
    timeout = setTimeout("scrollFromSide()",50);
  };
}
 
/**
 * Set the stop variable to be true (will stop the marquee at the next pass).
 */
function stop(){
  go = 1;
  timeout = '';
}
 
/**
 * Set the stop variable to be false and call the marquee function.
 */
function startit(){
  go = 0;
  scrollFromSide();
}
// –>

// Show Breaking News / Most Read

var set_visible = document.all ? "block" : "table-row";
var set_invisible = "none";

function showBreakingNews () {

	document.getElementById("BreakingNewsButton").innerHTML = '<img src="images/btn_news_1.gif" alt="Breaking News" width="90" height="22" />'
	document.getElementById("BreakingNewsBlock").style.display = set_visible;
	document.getElementById("MostReadButton").innerHTML = '<img src="images/btn_mostRead_2.gif" alt="Most Read" name="Image_mostRead" width="71" height="22" id="Image_mostRead" onmouseover="MM_swapImage(\'Image_mostRead\',\'\',\'images/btn_mostRead_3.gif\',1)" onmouseout="MM_swapImgRestore()" onclick="showMostRead ()" />'
	document.getElementById("MostReadBlock").style.display = set_invisible;
	
}

function showMostRead () {
	
	document.getElementById("BreakingNewsButton").innerHTML = '<img src="images/btn_news_2.gif" alt="Breaking News" name="Image_news" width="90" height="22" id="Image_news" onmouseover="MM_swapImage(\'Image_news\',\'\',\'images/btn_news_3.gif\',1)" onmouseout="MM_swapImgRestore()" onclick="showBreakingNews ()" />'
	document.getElementById("BreakingNewsBlock").style.display = set_invisible;
	document.getElementById("MostReadButton").innerHTML = '<img src="images/btn_mostRead_1.gif" alt="Most Read" width="71" height="22" />'
	document.getElementById("MostReadBlock").style.display = set_visible;
	
}

var topAds = new Array (
//				'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=6&src=T&url=http%3a%2f%2fwww.africanlogisticsclub.com%2f\'" onmouseover="logAds(6, \'T\'); return false;" target="_blank"><img src="images/Ads/alc700x60.png" width="700" height="60" border="0" alt="African Logistics Club" /></a>',
//				'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=7&src=T&url=http%3a%2f%2fwww.chinalogisticsclub.com%2f\'" onmouseover="logAds(7, \'T\'); return false;" target="_blank"><img src="images/Ads/clc_banner700x60.png" width="700" height="60" border="0" /></a>',
//				'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=8&src=T&url=http%3a%2f%2fwww.europeanlogisticsclub.com%2f\'" onmouseover="logAds(8, \'T\'); return false;" target="_blank"><img src="images/Ads/elc700x60.png" width="700" height="60" border="0" alt="European Logistics Club" /></a>',
//				'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="700" height="60" title="ATE Group"><param name="movie" value="images/Ads/banner1_v4.swf" /><param name="quality" value="high" /><param name=wmode value=transparent /><embed src="images/Ads/banner1_v4.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="700" height="60" wmode="transparent"></embed></object>'
//				'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=10&src=T&url=http%3a%2f%2fwww.airtiger.com%2f\'" onmouseover="logAds(10, \'T\'); return false;" target="_blank"><img src="images/Ads/ate_banner.jpg" width="700" height="60" border="0" alt="Air Tiger Express" /></a>'
				'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=10&src=T&url=http%3a%2f%2fwww.airtiger.com%2f\'" target="_blank"><img src="images/Ads/ate_banner.jpg" width="700" height="60" border="0" alt="Air Tiger Express" /></a>'
				);

//var leftAds = new Array (
//				'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=6&src=L&url=http%3a%2f%2fwww.africanlogisticsclub.com%2f\'" onmouseover="logAds(6, \'L\'); return false;"><img src="images/Ads/alc_banner240x175.png" width="240" height="175" border="0" /></a>',
//				'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=7&src=L&url=http%3a%2f%2fwww.chinalogisticsclub.com%2f\'" onmouseover="logAds(7, \'L\'); return false;"><img src="images/Ads/clc_banner240x175.png" width="240" height="175" border="0" /></a>'
//			);
var leftAds = new Array ();

var leftAds1 = new Array ();

//var centerAds = new Array (
//			'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=7&src=C&url=http%3a%2f%2fwww.chinalogisticsclub.com%2f\'" onmouseover="logAds(6, \'C\'); return false;"><img src="images/Ads/clc_banner460x60.png" width="460" height="60" border="0" /></a>',
//			'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=6&src=C&url=http%3a%2f%2fwww.africanlogisticsclub.com%2f\'" onmouseover="logAds(7, \'C\'); return false;"><img src="images/Ads/alc_banner460x60.png" width="460" height="60" border="0" /></a>'
//			);
var centerAds = new Array ();

var centerAds1 = new Array (
//			'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=16&src=C&url=http%3a%2f%2fwww.thefreightsummit.com%2freseller%2fregistration%2f%3fb%3dR0003\'" onmouseover="logAds(16, \'C\'); return false;" target="_blank"><img src="images/Ads/TheFreightSummitLogo_460x68.jpg" width="460" height="68" border="0" alt="The Freight Summit" /></a>',
//			'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=17&src=C&url=http%3a%2f%2fwww.airfreightasia.com%2f\'" onmouseover="logAds(17, \'C\'); return false;" target="_blank"><img src="images/Ads/GCTL8_Combined2_AFA_web_460x60.gif" width="460" height="68" border="0" alt="Air Freight Asia" /></a>',
			'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=16&src=C&url=http%3a%2f%2fwww.thefreightsummit.com%2freseller%2fregistration%2f%3fb%3dR0003\'" target="_blank"><img src="images/Ads/TheFreightSummitLogo_460x68.jpg" width="460" height="68" border="0" alt="The Freight Summit" /></a>',
			'<a href="#" onclick="location:href=\'http://www.gctl8.com/AdsTrack.php?ads=17&src=C&url=http%3a%2f%2fwww.airfreightasia.com%2f\'" target="_blank"><img src="images/Ads/GCTL8_Combined2_AFA_web_460x60.gif" width="460" height="68" border="0" alt="Air Freight Asia" /></a>',
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="460" height="68" title="Advertisement"><param name="movie" value="images/Ads/banner2_v5.swf" /><param name="quality" value="high" /><param name=wmode value=transparent /><embed src="images/Ads/banner2_v5.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="460" height="68" wmode="transparent"></embed></object>'
			);

var rightAds = new Array ();

var topAdsCount = 0;
var leftAdsCount = 0;
var leftAds1Count = 0;
var centerAdsCount = 0;
var centerAds1Count = 0;
var rightAdsCount = 0;

function displayTopAds () {
	
	document.getElementById('TopAdsContainer').innerHTML = topAds[topAdsCount];
	topAdsCount++;
	if (topAdsCount > topAds.length - 1)
		topAdsCount = 0;
		
}

function displayLeftAds () {
	
	document.getElementById('LeftAdsContainer').innerHTML = leftAds[leftAdsCount];
	leftAdsCount++;
	if (leftAdsCount > leftAds.length - 1)
		leftAdsCount = 0;
		
}

function displayLeftAds1 () {
	
	document.getElementById('LeftAdsContainer1').innerHTML = leftAds1[leftAds1Count];
	leftAds1Count++;
	if (leftAds1Count > leftAds1.length - 1)
		leftAds1Count = 0;
		
}

function displayCenterAds () {
	
	document.getElementById('CenterAdsContainer').innerHTML = centerAds[centerAdsCount];
	centerAdsCount++;
	if (centerAdsCount > centerAds.length - 1)
		centerAdsCount = 0;
		
}

function displayCenterAds1 () {
	
	document.getElementById('CenterAdsContainer1').innerHTML = centerAds1[centerAds1Count];
	centerAds1Count++;
	if (centerAds1Count > centerAds1.length - 1)
		centerAds1Count = 0;
		
}

function displayRightAds () {
	
	document.getElementById('RightAdsContainer').innerHTML = rightAds[rightAdsCount];
	rightAdsCount++;
	if (rightAdsCount > rightAds.length - 1)
		rightAdsCount = 0;

}

function displayAds () {
	
	if (topAds.length > 0)
		displayTopAds ();
	if (leftAds.length > 0)
		displayLeftAds ();
	if (leftAds1.length > 0)
		displayLeftAds1 ();
	if (centerAds.length > 0)
		displayCenterAds ();
	if (centerAds1.length > 0)
		displayCenterAds1 ();
	if (rightAds.length > 0)
		displayRightAds ();
	
}

function logAds (AdsID, position) {
	
	xmlHttp = GetXmlHttpObject()
	if (xmlHttp == null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}

	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET", "AdsTrack.php?ads="+AdsID+"&src="+position,true)
	xmlHttp.send(null)

}