/*setting the date */
//Current date script credit: 
//Website Abstraction (www.wsabstract.com)
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym

/*---------------------------------------------------------------------------*/



function open_audio(theURL) { 
  window.open(theURL,'audio','menubar=no,scrollbars=no,resizable=yes,width=750,height=150');
}

function open_flash(theURL) { 
  window.open(theURL + '&width=430&height=346','flash','menubar=no,scrollbars=no,resizable=yes,width=750,height=521');
}

function open_photo(theURL) { 
  window.open(theURL,'photoToday','menubar=no,scrollbars=no,resizable=yes,width=900,height=600');
}



/* function detecting browser to get correct css*/

if (navigator.appName.indexOf("Mac") != -1 )
	{
	CURL = 'macbrowser.css';
	}
else
	if (navigator.appName.indexOf("Microsoft") != -1 )
		{
		CURL = 'iebrowser.css';
		}
	else
		if (navigator.appName.indexOf("Netscape") != -1 )
			{
			CURL = 'netbrowser.css';
			}
		else
		if (navigator.userAgent.indexOf('Mozilla/5.0') != -1)
			{
			CURL = 'netbrowser.css';
			}
		else
			{
			CURL = 'otherbrowser.css';
			}

/*actual detecting of browser and assign appropriate css */
document.write('<link rel=stylesheet href="http://www.ugpulse.com/css/' + CURL + '" type=text/css>');

/*---------------------------------------------------------------------------*/

/* land and jump for navigation */
function land(ref, targ) 

{ lowtarg=targ.toLowerCase();
if (lowtarg=="_self") {window.location=loc;} 
else {if (lowtarg=="_top") {top.location=loc;} 
else {if (lowtarg=="_blank") {window.open(loc);} 
else {if (lowtarg=="_parent") {parent.location=loc;} 
else {parent.frames[targ].location=loc;}; 
}}} 
} 
function jump(menu) 
{ ref=menu.choice.options[menu.choice.selectedIndex].value; splitc=ref.lastIndexOf(" "); targ="";
menu.choice.selectedIndex = 0; 
if (splitc!=-1)
{loc=ref.substring(0,splitc); targ=ref.substring(splitc+1,1000);}
else {loc=ref; targ="_self";}; 
if (ref != ""){land(loc,targ);} 
}


/*----script to open up new small window-----*/


function MM_openBrWindow(theURL,winName,features) { //v2.0
 if(winName=="audio")
   window.open(theURL,'audio','menubar=no,scrollbars=no,resizable=no,width=750,height=150');
 else
  window.open(theURL,winName,features);
}


/*---------------------------------------------------------------------------*/

//Countdown script by Mike Thompson
//http://www.members.tripod.com/webdesign123now/
//Based on script by Website Abstraction (http://wsabstract.com)

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="/images/logo/1.jpg"
myimages[2]="/images/logo/2.jpg"
myimages[3]="/images/logo/3.jpg"
myimages[4]="/images/logo/4.jpg"

myimages[5]="/images/logo/5.jpg"
myimages[6]="/images/logo/6.jpg"
myimages[7]="/images/logo/7.jpg"
myimages[8]="/images/logo/8.jpg"

myimages[9]="/images/logo/9.jpg"
myimages[10]="/images/logo/10.jpg"
myimages[11]="/images/logo/11.jpg"
myimages[12]="/images/logo/12.jpg"

myimages[13]="/images/logo/13.jpg"
myimages[14]="/images/logo/14.jpg"
myimages[15]="/images/logo/15.jpg"
myimages[16]="/images/logo/16.jpg"

myimages[17]="/images/logo/17.jpg"
myimages[18]="/images/logo/18.jpg"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
return '<img src="'+myimages[ry]+'"  width ="150" height="90"  alt="Photos of Uganda"><img src="/images/spacer.gif" width ="3" >'
}


function random_imglink2(){
var myimages=new Array()
//specify random images below. You can have as many as you wish

myimages[1]="/images/logo/34.jpg"
myimages[2]="/images/logo/35.jpg"
myimages[3]="/images/logo/19.jpg"
myimages[4]="/images/logo/20.jpg"

myimages[5]="/images/logo/21.jpg"
myimages[6]="/images/logo/22.jpg"
myimages[7]="/images/logo/23.jpg"
myimages[8]="/images/logo/24.jpg"

myimages[9]="/images/logo/25.jpg"
myimages[10]="/images/logo/26.jpg"
myimages[11]="/images/logo/27.jpg"
myimages[12]="/images/logo/28.jpg"

myimages[13]="/images/logo/29.jpg"
myimages[14]="/images/logo/30.jpg"
myimages[15]="/images/logo/31.jpg"
myimages[16]="/images/logo/32.jpg"

myimages[17]="/images/logo/33.jpg"



var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
return '<img src="/images/spacer.gif" width ="3" ><img src="'+myimages[ry]+'" width ="150" height="90" alt="Photos of Uganda">'
}
/*-------------------------------------------------

document.oncontextmenu = function(){return false}

if(document.layers) {
window.captureEvents(Event.MOUSEDOWN);
window.onmousedown = function(e){
if(e.target==document)return false;
}
}

-----------------------------------------------------*/

/*--------------------------Weather------------------
function ugWeather(){
document.write('<form method="post" style="display:inline">')
document.write('<select name="choice" onChange="jump(this.form)" ')
document.write('style="BACKGROUND: #e7e7cf; ')
document.write('BORDER-BOTTOM: outset; BORDER-LEFT: outset; BORDER-RIGHT: outset; BORDER-TOP: outset; ')
document.write('COLOR: #666633; FONT-FAMILY: Arial; FONT-SIZE: 11px">')
document.write('<option selected value=""  >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;UG Weather Forecast&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</option>')
document.write('<option style="color: #cc6600" value="http://www.weather.com/activities/travel/businesstraveler/weather/fcst-hrly.html?locid=UGXX0002 _blank" >')
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Kampala Weather </option>')
document.write('<option style="color: #cc6600" value="http://www.weather.com/activities/travel/businesstraveler/weather/fcst-hrly.html?locid=UGXX0001 _blank" >')
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Entebbe Weather </option>')
document.write('</select></form>')
}
---------------*/

/*---------daily image function-------------*/
function getDailyPic( which ){

	var monthNum 

	if(month < 9)
		monthNum = "0" + (month + 1)
	else
		monthNum =  month + 1
 if( which =="today"){
	
	document.write("<a href=\"#mat1\" onClick=\"MM_openBrWindow(\'/largepic.asp\',\'photoToday\',\'menubar=no,scrollbars=no,resizable=yes,width=900,height=590\')\">")
	document.write("<img src= \"/images/dailyphoto/" + year +  monthNum + daym  + ".jpg\" height =\"210\" width=\"288\" border= \"0\" alt= \"Today in Uganda:Click to Enlarge\"></a>")
	}
else if( which =="weeklypeople")

	document.write("<img src= '/images/weeklypple/200607_jackson.jpg' width='288' border='0' alt='Ugandan of the month: Twesigye Jackson Kaguri'>")

else if( which =="index"){
	document.write("<a href=\"#mat1\" onClick=\"MM_openBrWindow(\'/largepic.asp?sendBack=1\',\'photoToday\',\'menubar=no,scrollbars=no,resizable=yes,width=900,height=600\')\">")
	document.write("<img src= \"/images/dailyphoto/" + year +  monthNum + daym  + "_93.jpg\" height =\"93\" width=\"157\" border=\"0\"  alt= \"Today in Uganda:Click to Enlarge\"></a>")
	}
}
/*----script to open up new small window-----*/




/*---------------------------------------------------------------------------*/

//walletpop cott module
function walletpop_cott_next(){
        if(cottIndex + 2 < cottMax){
                document.getElementById("section"+cottIndex).style.display = 'none';
                document.getElementById("section"+(cottIndex+3)).style.display = 'block';
                cottIndex++;
        } else {
          for(i=1;i<=cottMax;i++){              document.getElementById("section"+i).style.display = 'none';
          }
          cottIndex = 1;
          document.getElementById("section1").style.display = 'block';
          document.getElementById("section2").style.display = 'block';
          document.getElementById("section3").style.display = 'block';
        }
}
function walletpop_cott_pre(){
        if(cottIndex > 1){
                cottIndex--;
                document.getElementById("section"+(cottIndex+3)).style.display = 'none';
                document.getElementById("section"+(cottIndex)).style.display = 'block';

        } else {
          for(i=1;i<=cottMax;i++){              document.getElementById("section"+i).style.display = 'none';
          }
          cottIndex = cottMax - 2;
          document.getElementById("section"+cottIndex).style.display = 'block';
          document.getElementById("section"+(cottIndex +1)).style.display = 'block';
          document.getElementById("section"+(cottIndex +2)).style.display = 'block';
        }
}
function hoverstate(elemNum){
    document.getElementById("cott_img_" +elemNum).setAttribute("class", "activeSection");
    document.getElementById("cott_img_" +elemNum).setAttribute("className", "activeSection");
} 
function hoverOutstate(elemNum){
    document.getElementById("cott_img_" +elemNum).setAttribute("class", "cott_img_box");
    document.getElementById("cott_img_" +elemNum).setAttribute("className", "cott_img_box");
}

function truncateStr(str, limit) {

var bits, i;


bits = str.split('');

if (bits.length > limit) {

for (i = bits.length - 1; i > -1; --i) {

if (i > limit) {

bits.length = i;

}

else if (' ' === bits[i]) {

bits.length = i;

break;

}

}

bits.push('...');

}
return bits.join('');
}
