// --------------------------------------------------------------
// This javascript carries all the utility functions
//
// bpoikayi 28-11-07  Created 
// bpoikayi Nov-09-08 Added function dropinslideshow
//                    Added function ArrayBuilder
// --------------------------------------------------------------

// --------------------------------------------------------------
// This function is for printing page breaks
// --------------------------------------------------------------
function PrintBreaks(n)
{
   var i=0;
   for (i=0;i<=n;i++)
   {
      document.write("<br>")
   }
}

// --------------------------------------------------------------
// This function is for getting alternate color for table rows
// --------------------------------------------------------------
function alternate(id)
{ 
   if(document.getElementsByTagName)
   {  
      var table = document.getElementById(id);   
      var rows = table.getElementsByTagName("tr");   
      for(i = 0; i < rows.length; i++)
	  {           
         // Manipulate rows 
         if(i % 2 == 0)
	     { 
            rows[i].className = "even"; 
         }
		 else
		 { 
            rows[i].className = "odd"; 
         }       
      } 
   }  
}

//----------------------------------------------------------------------
// This function initlizes the image array and then call the function 
// Dropinslideshow for doing the slide show of those images one by one
//-----------------------------------------------------------------------
function  ArrayBuilder(ImageGroup)
{
	var ImageArray=new Array();
    if(ImageGroup == "customer")
	{
    	ImageArray[0]=["images/logo_customer_intelliswift.gif", "http://www.dynamicdrive.com", "_new"];
		ImageArray[1]=["images/logo_customer_plusmo.gif", "http://www.dynamicdrive.com", "_new"];
		ImageArray[2]=["images/logo_customer_bayarea.gif", "http://www.javascriptkit.com", "_new"];
		ImageArray[3]=["images/logo_customer_fidelity.gif", "http://www.javascriptkit.com", "_new"];
		ImageArray[4]=["images/logo_customer_abacus-inc.gif", "http://www.javascriptkit.com", "_new"];
		ImageArray[5]=["images/logo_customer_lfc.gif", "http://www.dynamicdrive.com", "_new"];
		new dropinslideshow(ImageArray, 200, 62, 2000);
	}
    else
    {
	   ImageArray[0]=["images/logo_partner_docedge.gif", "http://www.dynamicdrive.com", "_new"];
	   ImageArray[1]=["images/logo_partner_netronline.jpg", "http://www.dynamicdrive.com", "_new"];
	   ImageArray[2]=["images/logo_partner_garvoo.jpg", "http://www.javascriptkit.com", "_new"];
	   new dropinslideshow(ImageArray, 200, 80, 3000);
	}	   
}

// -------------------------------------------------------------------
// Drop-in Slideshow Script- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Last updated: March 9th, 2007
// -------------------------------------------------------------------

var _dropinslideshowcount=0

function dropinslideshow(imgarray, w, h, delay){
	this.id="_dropslide"+(++_dropinslideshowcount) //Generate unique ID for this slideshow instance (automated)
	this.createcontainer(parseInt(w), parseInt(h))
	this.delay=delay
	this.imgarray=imgarray
	var preloadimages=[]
	for (var i=0; i<imgarray.length; i++){
		preloadimages[i]=new Image()
		preloadimages[i].src=imgarray[i][0]
	}
	this.animatestartpos=parseInt(h)*(-1) //Starting "top" position of an image before it drops in
	this.slidedegree=10 //Slide degree (> is faster)
	this.slidedelay=30 //Delay between slide animation (< is faster)
	this.activecanvasindex=0 //Current "active" canvas- Two canvas DIVs in total
	this.curimageindex=0
	this.zindex=100
	this.isMouseover=0
	this.init()
}


dropinslideshow.prototype.createcontainer=function(w, h){
 document.write('<div id="'+this.id+'" style="position:relative; width:'+w+'px; height:'+h+'px; overflow:hidden">')
	document.write('<div style="position:absolute; width:'+w+'px; height:'+h+'px; top:0;"></div>')
	document.write('<div style="position:absolute; width:'+w+'px; height:'+h+'px; top:-'+h+'px;"></div>')
	document.write('</div>')
	this.slideshowref=document.getElementById(this.id)
	this.canvases=[]
	this.canvases[0]=this.slideshowref.childNodes[0]
	this.canvases[1]=this.slideshowref.childNodes[1]
}

dropinslideshow.prototype.populatecanvas=function(canvas, imageindex){
	var imageHTML='<img src="'+this.imgarray[imageindex][0]+'" style="border: 0" />'
	if (this.imgarray[imageindex][1]!="")
		imageHTML='<a href="'+this.imgarray[imageindex][1]+'" target="'+this.imgarray[imageindex][2]+'">'+imageHTML+'</a>'
	canvas.innerHTML=imageHTML
}


dropinslideshow.prototype.animateslide=function(){
	if (this.curimagepos<0){ //if image hasn't fully dropped in yet
		this.curimagepos=this.curimagepos+this.slidedegree
		this.activecanvas.style.top=this.curimagepos+"px"
	}
	else{
		clearInterval(this.animatetimer)
		this.activecanvas.style.top=0
		this.setupnextslide()
		var slideshow=this
		setTimeout(function(){slideshow.rotateslide()}, this.delay)
	}
}


dropinslideshow.prototype.setupnextslide=function(){
	this.activecanvasindex=(this.activecanvasindex==0)? 1 : 0
	this.activecanvas=this.canvases[this.activecanvasindex]
	this.activecanvas.style.top=this.animatestartpos+"px"
	this.curimagepos=this.animatestartpos
	this.activecanvas.style.zIndex=(++this.zindex)
	this.curimageindex=(this.curimageindex<this.imgarray.length-1)? this.curimageindex+1 : 0
	this.populatecanvas(this.activecanvas, this.curimageindex)
}

dropinslideshow.prototype.rotateslide=function(){
	var slideshow=this
	if (this.isMouseover)
		setTimeout(function(){slideshow.rotateslide()}, 50)
	else
		this.animatetimer=setInterval(function(){slideshow.animateslide()}, this.slidedelay)
}

dropinslideshow.prototype.init=function(){
	var slideshow=this
	this.populatecanvas(this.canvases[this.activecanvasindex], 0)
	this.setupnextslide()
	this.slideshowref.onmouseover=function(){slideshow.isMouseover=1}
	this.slideshowref.onmouseout=function(){slideshow.isMouseover=0}
	setTimeout(function(){slideshow.rotateslide()}, this.delay)
}


/***********************************************
* Cross browser Marquee  
* For New and Events
***********************************************/

var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var newsspeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=newsspeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
else
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("newscontent")
cross_marquee.style.top=0
marqueeheight=document.getElementById("newscontainer").offsetHeight
actualheight=cross_marquee.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee