// JavaScript Document

// News Box stuff
function NewsBox(BoxID,W,H)
{
	/*
	this.Speed = 10;
	this.Box = null;
	this.Div = null;
	this.RotateInterval = 5;
	this.BoxTop = 0;
	this.BoxHeight = H;
	this.BoxWidth = W;
	this.CoverContainer = null;
	this.NewsContainer = null;
	
	
	
	//this.Box = ;
	this.Div = document.getElementById(BoxID) ;
	this.Div.style.overflow = "hidden";
	this.Div.style.width = this.BoxWidth + "px";
	this.Div.style.height = this.BoxHeight + "px";
	
 	this.Box = document.getElementById( BoxID + "Table" );
	this.Box.style.width = this.BoxWidth + "px";
	this.Box.style.height = this.BoxHeight + "px";
	this.Box.style.position = "relative";
	this.Box.style.borderStyle = "solid";
	this.Box.style.borderWidth = "0px";
	this.Box.cellPadding = "0";
	this.Box.cellSpacing = "0";

	
	
	this.CoverContainer = this.Box.rows[0].cells[0];
	var img = new Image();
	img.src = "newscover.jpg";
	this.CoverContainer.appendChild(img);
	 
	this.NewsContainer = this.Box.rows[1].cells[0];
	this.NewsContainer.innerHTML = "ssssss";
	 
	this.newsdirection = 1;
  	this.newstimecalls = 0;
	this.contentNotChanged = true;
	
	this.NewsItems = new Array();
	this.NewsItemsCount = 0;
	this.CurrentNewsItem = 0;
	*/
	
}


function StartRotation( boxindex )
{
	//bb = new NewsBox ("")	;
 	bb = boxes[boxindex];
	//alert("Ro" + bb.RotateInterval + ";;;" + bb.aaaaa );
	bb.BoxTop  =  -1 * bb.BoxHeight;
   	
   	bb.newsdirection = 1;  // -1 is up 1 is down
	bb.newstimecalls = 0; 
	bb.contentNotChanged = true ;
	
	
	this.RollUpDown(boxindex);
	var tt = setTimeout("StartRotation(" + boxindex + ") ", bb.RotateInterval * 1000);
	
}




function RollUpDown(boxindex)
{
	
	//bb = new NewsBox ("")	;
	bb = boxes[boxindex];
	bb.Box.style.top = "" + bb.BoxTop.toString() + "px";
  	bb.BoxTop = (bb.BoxTop + bb.newsdirection);
  	bb.newstimecalls = bb.newstimecalls +1;
  
  	if(bb.newstimecalls > bb.BoxHeight)
  		{ 
  			bb.newsdirection = -1 ; 
			if (bb.contentNotChanged)
				{
					
					bb.CurrentNewsItem ++;
					if(bb.CurrentNewsItem > bb.NewsItemsCount){ bb.CurrentNewsItem = 1;}
					bb.NewsContainer.innerHTML = bb.NewsItems[bb.CurrentNewsItem - 1] ;
					bb.contentNotChanged = false
				}
		}
    
  	if (bb.newstimecalls < ((bb.BoxHeight * 2) +1))
  		{
  			var t  = setTimeout("RollUpDown(" + boxindex +")",bb.Speed);
		}
	
	
}


// End News Box stuff


// Scroll stuff


function ScrollBox(ScrollBoxIndex,ScrollBoxID,Width,Height,ItemCount,varAutoScrollInterval)
{
	
	/*this.scll = document.getElementById(ScrollBoxID);
	this.scllt = document.getElementById( ScrollBoxID + "Table");
  	this.scllsel = document.getElementById( ScrollBoxID + "selection");

	this. ItemsCount = ItemCount;
	this. Items = new Array();
	this. currentItem = 1;
	this.AutoScrollInterval = varAutoScrollInterval;


	this. movespeed = 10;
	this. moveinterval_1 = 2;
	this. moveinterval_2 = 5;
	this. moveviewinterval = 0;
	this. W = Width;
	this. H = Height;
	this. viewlocation = 0;

	this.scll.style.width = this.W.toString() + "px";
	this.scll.style.height = this.H.toString() + "px";
	this.scll.style.overflow = "hidden";
	this.scll.style.borderStyle = "solid";
	this.scll.style.borderWidth = "1px";
	this.scll.style.borderColor = "#E7B859";
	this.scll.style.padding = "0px";
	this.scll.style.margin = "0px";
	
	this.scllt.style.position = "relative";
	
	this.scllsel.setAttribute( "align","center");
	this.scllsel.insertRow(0);
	this. TR = this.scllsel.rows[0];
	
	this.CellBG1 = "#ECEDEA";
	this.CellBG2 = "#CECFCC";
	var bgswap = true;
	
	for (ix = 0;ix < this.ItemsCount;ix++)
	{	
		this.scllt.insertRow(ix);
		this.scllt.rows[ix].insertCell(0);
		//var td = document.getElementById("scroll1Table");
		var td = this.scllt.rows[ix].cells[0] ;
		
		var tdtestID = ScrollBoxID + "_item_" + ix.toString();
		td.innerHTML = document.getElementById(tdtestID).innerHTML  ;  
		td.style.width = this.W.toString() + "px";
		td.style.height = this.H.toString() + "px";
		
		if(bgswap) 
		{
			td.setAttribute ("bgcolor",this.CellBG1) ;
		}else{ 
			td.setAttribute ("bgcolor",this.CellBG2) ; 
		}
		bgswap = !bgswap ;
		
		
		this.TR.insertCell(ix);
		var sel = this.TR.cells[ix];
		
		var img = new Image();
		img.src = "images/dot1.jpg";
		img.setAttribute("onclick","fntmove("+ ScrollBoxIndex + "," + (ix + 1) + ") ;") ; 
				
		sel.appendChild(img) ;
		
	}
	
	var tt = setTimeout ("AutoScroll(" + ScrollBoxIndex + ")");
	*/
}
	 
	 
	 
	 
function  fntmove(ScrollBoxIndex ,tolocation)
{
	sb = scrollboxes[ScrollBoxIndex];
	//sb = new ScrollBox(0,"");
	
	
	//alert(tolocation + ";;" + currentItem);
	if (tolocation == sb.currentItem)
	{
			
	}
	
	if (tolocation > sb.currentItem)
	{
		if ((tolocation - sb.currentItem) > 1)
		{
			sb.moveviewinterval = sb.moveinterval_2 ;
		}else{
			sb.moveviewinterval = sb.moveinterval_1 ;
		}
		
		sb.currentItem = tolocation;
		
		ScrollerDown(ScrollBoxIndex);
	}
	
	if (tolocation < sb.currentItem)
	{
		if ((sb.currentItem - tolocation) > 1)
		{
			sb.moveviewinterval = sb.moveinterval_2 ;
		}else{
			sb.moveviewinterval = sb.moveinterval_1 ;
		}
		
		sb.currentItem = tolocation;
		
		ScrollerUp(ScrollBoxIndex);
	}
}
	 
	 function AutoScroll (ScrollBoxIndex)
	 {
		 sb = scrollboxes[ScrollBoxIndex];
	//sb = new ScrollBox(0,"");
	
	var nextitem = sb.currentItem + 1;
	if (nextitem > sb.ItemsCount )
	{
		nextitem = 1;
	}
	
	fntmove(ScrollBoxIndex,nextitem);
		 
		 var tt = setTimeout("AutoScroll(" + ScrollBoxIndex + ")",(sb.AutoScrollInterval * 1000));
		 
	 }
	 

function ScrollerDown(ScrollBoxIndex)
{
	sb = scrollboxes[ScrollBoxIndex];
	//sb = new ScrollBox(0,"");
	
	sb.viewlocation = sb.viewlocation - sb.moveviewinterval;
	sb.scllt.style.top = sb.viewlocation.toString() + "px" ;
	//alert(viewlocation);
	
	if(sb.viewlocation > (-1 * ((sb.currentItem - 1) * sb.H)))
		{
		 	var t = setTimeout("ScrollerDown(" + ScrollBoxIndex + ")",sb.movespeed);
		}else
		{
			var settop = (-1 * ((sb.currentItem - 1) * sb.H))
			sb.scllt.style.top =  settop.toString()  + "px" ;
		}
	
	
		
}
function ScrollerUp(ScrollBoxIndex)
{
	sb = scrollboxes[ScrollBoxIndex];
	//sb = new ScrollBox(0,"");
	
	sb.viewlocation = sb.viewlocation + sb.moveviewinterval;
	sb.scllt.style.top = sb.viewlocation.toString() + "px" ;
	//alert(viewlocation);
	
	if(sb.viewlocation < (-1 * ((sb.currentItem - 1) * sb.H)))
		{
		 	var t = setTimeout("ScrollerUp(" + ScrollBoxIndex + ")",sb.movespeed);
		}else
		{
			var settop = (-1 * ((sb.currentItem - 1) * sb.H))
			sb.scllt.style.top =  settop.toString()  + "px" ;
		}
	
	
		
}


// End Scroll stuff





function OpenPage(pagee)
  {
	  
	  url = "" ;
	  siteaddress = "http://www.ghanaembassy.or.kr/";
	  thispage = true ;
	  
	  switch (pagee)
	  {
	  	case "notice_001":
	  		url = "notice.php?id=_001" ; 
	  	break ;
	  
		case "notice_002":
	  		url = "notice.php?id=_002" ; 
	  	break ;
	  
	  
	  	// government agancies
		case "GIPC":
	  		url = "http://www.gipc.org.gh/home.aspx" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
		
		case "GGOP":
	  		url = "http://www.ghana.gov.gh" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
	 
	  case "GEOC":
	  		url = "http://www.ghanahighcom.org.au" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
		 case "GFZ":
	  		url = "http://www.gfzb.com" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
		
		 case "GTB":
	  		url = "http://www.ghanatourism.gov.gh" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
		 case "GPMMC":
	  		url = "http://www.pmmcghana.com" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
		
		case "MOFA":
	  		url = "http://www.mfa.gov.gh" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
		case "GTV":
	  		url = "http://www.ghanaclassified.com/tvroom/index.html" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
		
		case "WRG":
	  		url = "http://www.ghana.gov.gh" ; 
			thispage = false ;
			siteaddress = "";
	  	break ;
		
		
		
		
	  
	  }
	  
	if (thispage )
		{
	  		window.location.replace(siteaddress + url );
		}else
		{
			window.open(siteaddress + url,"_blank");
		}
		
  }



