// JavaScript Document
var timer=0;
var timer2 = 0;
function HideText(d) 
{
	if(d.length < 1) 
	{ 
		return;
	}
	document.getElementById(d).style.display = "none";
}

function ShowText(d) 
{
	if(d.length < 1) 
	{ 
		return;
	}
	document.getElementById('1').style.display = "none";
	document.getElementById('2').style.display = "none";
	var dd = document.getElementById(d);
	var chd='';
	switch(d)
	{
		case '1':
			chd='2';
			break;
		case '2':
			chd='1';
			break;
	} 
	dd.style.display = "block";
	clearTimeout(timer);
	timer = setTimeout("ShowText('"+chd+"')",7000);
}
function ShowText2(d) 
{
	if(d.length < 1) 
	{ 
		return;
	}
	document.getElementById('img1').style.display = "none";
	document.getElementById('img2').style.display = "none";
	document.getElementById('img3').style.display = "none";
	var dd = document.getElementById(d);
	var chd='';
	switch(d)
	{
		case 'img1':
			chd='img2';
			break;
		case 'img2':
			chd='img3';
			break;
		case 'img3':
			chd='img1';
			break;
	} 
	dd.style.display = "block";
	clearTimeout(timer2);
	timer2 = setTimeout("ShowText2('"+chd+"')",7000);
}
function LinkUp() 
{
	var number = document.DropDown.D1.selectedIndex;
	location.href = document.DropDown.D1.options[number].value;
}
function ShowDiv(d)
{
	var dd = document.getElementById(d);
	dd.style.display = "block";
}
function HideDiv(d)
{
	var dd = document.getElementById(d);
	dd.style.display = "none";
}
function toSpans(span) {
  var str=span.firstChild.data;
  var a=str.length;
  span.removeChild(span.firstChild);
  for(var i=0; i<a; i++) {
    var theSpan=document.createElement("SPAN");
    theSpan.appendChild(document.createTextNode(str.charAt(i)));
    span.appendChild(theSpan);
  }
}
function RainbowSpan(span, hue, deg, brt, spd, hspd) {
    this.deg=(deg==null?360:Math.abs(deg));
    this.hue=(hue==null?0:Math.abs(hue)%360);
    this.hspd=(hspd==null?3:Math.abs(hspd)%360);
    this.length=span.firstChild.data.length;
    this.span=span;
    this.speed=(spd==null?50:Math.abs(spd));
    this.hInc=this.deg/this.length;
    this.brt=(brt==null?255:Math.abs(brt)%256);
    this.timer=null;
    toSpans(span);
    this.moveRainbow();
}
RainbowSpan.prototype.moveRainbow = function() {
  if(this.hue>359) this.hue-=360;
  var color;
  var b=this.brt;
  var a=this.length;
  var h=this.hue;

  for(var i=0; i<a; i++) {

    if(h>359) h-=360;

    if(h<60) { color=Math.floor(((h)/60)*b); red=b;grn=color;blu=0; }
    else if(h<120) { color=Math.floor(((h-60)/60)*b); red=b-color;grn=b;blu=0; }
    else if(h<180) { color=Math.floor(((h-120)/60)*b); red=0;grn=b;blu=color; }
    else if(h<240) { color=Math.floor(((h-180)/60)*b); red=0;grn=b-color;blu=b; }
    else if(h<300) { color=Math.floor(((h-240)/60)*b); red=color;grn=0;blu=b; }
    else { color=Math.floor(((h-300)/60)*b); red=b;grn=0;blu=b-color; }

    h+=this.hInc;

    this.span.childNodes[i].style.color="rgb("+red+", "+grn+", "+blu+")";
  }
  this.hue+=this.hspd;
}
function MM_jumpMenuT(targ,selObj,restore){ //v3.0
 eval(targ+".location='Bulletin_detail-"+selObj.options[selObj.selectedIndex].value+"'");
}

function MM_jumpMenuTT(targ,selObj,restore){ //v3.0
 eval(targ+".location='mms://stream.pbc.gov.pk:8080/"+selObj.options[selObj.selectedIndex].value+"'");
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0

  eval(targ+".location='UploadedFiles/"+selObj.options[selObj.selectedIndex].value+"'");
}
function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	//alert(value);
	selectbox.options.add(optn);
}

function removeAllOptions(selectbox, nFromOption)
{
	var i;
	for(i=selectbox.options.length-1;i>=nFromOption;i--)
	{
		selectbox.remove(i);
	}
}

function AddComboOptions(selectbox, arr, nFromOption)
{
	//alert(selectbox+"___"+nFromOption);
	removeAllOptions(selectbox, nFromOption);
	for( var arrMaker in arr ) 
	{	
		addOption(selectbox,arr[arrMaker],arrMaker);
	}
}

function numbersonly(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if(unicode==8 || unicode==9 ||  unicode==13 || unicode==46 ||  unicode==37 || unicode==39)
	{
	}
	else
	{ 
		if (unicode<48||unicode>57) //if not a number
			return false //disable key press
	}
}

