var result_page	=	0;
// display decision alert box
function decision(message, url){
	if(confirm(message)) location.href = url;
}

// open browser window
function openPopUp(url, windowName, w, h, scrollbar) {

           var winl = (screen.width - w) / 2;
           var wint = (screen.height - h) / 2;
           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar ;
		   win = window.open(url, windowName, winprops);
           if (parseInt(navigator.appVersion) >= 4) { 
              	win.window.focus(); 
           } 
}
function getImage(imageName)
{
		document.getElementById('img').src = imageName;
}
function jumpMenu(target,object,restore){ 
  eval(target+".location='"+object.options[object.selectedIndex].value+"'");
  if (restore) object.selectedIndex=0;
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function submitDoc(formName) { 
  var obj;
 
	if (obj=findObj(formName)!=null) 
	{
		findObj(formName).submit(); 
	}
	else 
	{
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}

}
//======================== MARQUEE NEWS ===================================================
function domticker(content, divId, divClass, delay, fadeornot){
this.content=content
this.tickerid=divId //ID of master ticker div. Message is contained inside first child of ticker div
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
this.pointer=1
this.opacitystring=(typeof fadeornot!="undefined")? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); -moz-opacity: 1" : ""
if (this.opacitystring!="") this.delay+=500 //add 1/2 sec to account for fade effect, if enabled
this.opacitysetting=0.2 //Opacity value when reset. Internal use.
document.write('<div id="'+divId+'" class="'+divClass+'"><div style="'+this.opacitystring+'">'+content[0]+'</div></div>')
var instanceOfTicker=this
setTimeout(function(){instanceOfTicker.initialize()}, delay)
}

domticker.prototype.initialize=function(){
var instanceOfTicker=this
this.contentdiv=document.getElementById(this.tickerid).firstChild //div of inner content that holds the messages
document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
this.rotatemsg()
}

domticker.prototype.rotatemsg=function(){
var instanceOfTicker=this
if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
else{
this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
this.contentdiv.innerHTML=this.content[this.pointer]
this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
this.pointer=(this.pointer<this.content.length-1)? this.pointer+1 : 0
setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container
}
}

// -------------------------------------------------------------------
// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox
// -------------------------------------------------------------------

domticker.prototype.fadetransition=function(fadetype, timerid){
var contentdiv=this.contentdiv
if (fadetype=="reset")
this.opacitysetting=0.2
if (contentdiv.filters && contentdiv.filters[0]){
if (typeof contentdiv.filters[0].opacity=="number") //IE6+
contentdiv.filters[0].opacity=this.opacitysetting*100
else //IE 5.5
contentdiv.style.filter="alpha(opacity="+this.opacitysetting*100+")"
}
else if (typeof contentdiv.style.MozOpacity!="undefined" && this.opacitystring!=""){
contentdiv.style.MozOpacity=this.opacitysetting
}
else
this.opacitysetting=1
if (fadetype=="up")
this.opacitysetting+=0.2
if (fadetype=="up" && this.opacitysetting>=1)
clearInterval(this[timerid])
}
//===========================================================================
function open_divMain(url){
	document.getElementById('divMainVT').innerHTML = "Requesting data...";
	alert(url);
	ajaxpage(url,'divMainVT');
	return false;
}

//===========================================================================
function vt_navigator(page,own_event,total_row,max_row,divnavigator){

	var limit	=	3; // 7
	
	var npage	=	page;
	
	var totalr	=	total_row;
	var totalp	=	(totalr/max_row);
	totalp		=	Math.floor(totalp);//totalp.toFixed(0);
	
	if(totalr % max_row) totalp++; 
	
	var out		=	'';
	
	var begin	=	'';
	var pre		=	'';
	var next	=	'';
	var end		=	'';
	
	var startno	=	0;
	var endno	=	0;
	
	startno	=	npage - 3;
	if(startno<=0)	startno	=	1;
	endno	=	startno + limit;
	
	if(endno>totalp){
		endno	=	totalp;
		startno	=	endno - limit;
		if(startno<=0)	startno	=	1;
	}
	
	for(i=startno;i<=endno;i++){
		if(i!=npage){
			out	+='<a href=\"javascript:'+ own_event + '(' + (i) + ');\" class=\"page_num\">'+ (i) +'</a> | ';   
		}else{
			out +='<font color=red size=\"2\">'+ (i) +'</font> | '; 
		}
	}//end for
	

	if(page>0 && page<totalp){
		next	=	'<a href=\"javascript:'+ own_event + '(' + (page+1) + ');\"  class=\"page_num\" title=\"Next page\">></a></a>&nbsp;| ';
		end		=	'<a href=\"javascript:'+ own_event + '(' + (totalp) + ');\"  class=\"page_num\" title=\"End page\">>></a></a>&nbsp;';
	}
	if(page>1){
		pre	=	'<a href=\"javascript:'+ own_event + '(' + (page-1) + ');\" class=\"page_num\" title=\"Previous page\"><</a>&nbsp;| ';
		if(page>4){
			pre		+=	" ";
			begin	=	'<a href=\"javascript:'+ own_event + '(' + (1) + ');\" class=\"page_num\" title=\"First page\"><<</a>&nbsp;| ';
		}
	}
	
	
	//if(page==1)	out	=	'Page: ' + out;
	
	
	out	=	'<div class=\"navigator\">Page: '+ begin + pre + out + next + end + '</div>';
	if(totalp==1 || totalp==0)	out	=	'';
	
	document.getElementById(divnavigator).innerHTML = out;
	
	//========= add on 17-8-06
	if(result_page){
		start	=	(page-1)*max_row + 1;
		end		=	start + max_row - 1;
		if(end>total_row)	end	= total_row;
		if(end==0)	start = 0;
		content	=	'Results: '+ start +' - '+ end +' of <b>'+ total_row +'</b>';
		document.getElementById('compresultarea').innerHTML = content;
	}
	return false;
}
//=================================================================================================
var marked_cell = new Array();

function contains(a, num) { 
	for( var i = 0; i <= a.length; i++ ) { 
		if( a[i] == num ) { 
			return new Array( 1, i );
		}
	}

	return new Array( 0, 0 );
}

function setPointer(theCell, CellNum, Action, thePointerColor) {
	var idx = contains(marked_cell, CellNum);
	if (Action == 'click') { 
		if (idx[0] ) {
			marked_cell.splice( idx[1], 1 );
			theCell.style.backgroundColor = '#FFFFFF';
			idx[0] = 0;
		} else {
			marked_cell.push( CellNum );
			theCell.style.backgroundColor = '#FF0000';
			idx[0] = 1;
		}
	} else {
		if (idx[0] == 0) {
			theCell.style.backgroundColor = thePointerColor;
		}
	}

	return true;
} 
//=================================================================================================