// glow test
function glowit(which){
if (document.all.glowtext[which].filters[0].strength==3)
document.all.glowtext[which].filters[0].strength=2
else
document.all.glowtext[which].filters[0].strength=3
}
function glowit2(which){
if (document.all.glowtext.filters[0].strength==3)
document.all.glowtext.filters[0].strength=2
else
document.all.glowtext.filters[0].strength=3
}
function startglowing(){
if (document.all.glowtext&&glowtext.length){
for (i=0;i<glowtext.length;i++)
eval('setInterval("glowit('+i+')",150)')
}
else if (glowtext)
setInterval("glowit2(0)",150)
}
// glow test
function winPop(url, windowName, w, h){
    var winProp = 'height=' + h + ', width=' + w
    window.open(url, windowName, winProp);
}

function HistoryBack(index){
  if (window.history.length>index)
  {
	  document.write ('<input type="button" class="cs_button" name="back" value="<back" onclick="javascript:window.history.go(-'+index+');">');
  }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  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=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function isSecureConnection(){

   var protocol=window.location.protocol;

   if (protocol=="https:"){
      return true;
   }
   else if (protocol=="http:"){
      return false;
   }
   else{
      return false;
   }
   
}

function isEmptyString(str) {
	var ans = 0
	var ansStr = ""
	if (str=="") return 1
	for (var i = 0; i < str.length; i++)	{
		var ch = str.substring(i, 1)
        if (ch != " ")
		ansStr += ch
	}
	if (ansStr == "")
		ans = 1
	return ans
	// answer 1 if it is an empty string, otherwise answer 0.
}

function SSLNeed(a){

   var protocol = window.location.protocol;
   var origurl = window.location.href;
   var bsecure = isSecureConnection();

   if (a == true && bsecure == false){
      var new_url=origurl.substring(0,4)+"s"+ origurl.substring(4,origurl.length);
      window.location.href = new_url;
   }
   else if (a == false && bsecure == true){
      var new_url=origurl.substring(0,4)+origurl.substring(5,origurl.length);
      window.location.href = new_url;
   }
   else{
   }

}

function setTime(obj){
	var d=new Date();
	var str,strMonth,strDate;
	if ((d.getMonth()+1)<10)
		strMonth="0"+(d.getMonth()+1);
	else
		strMonth=(d.getMonth()+1);
	
	if (d.getDate()<10)
		strDate="0"+d.getDate();
	else
		strDate=d.getDate();

	str=d.getYear()+"-"+strMonth+ "-" +strDate;
	obj.value=str;
}

function closewin(){
   window.opener.location.reload();
   window.close();   
   }

function closewinonly(){  
   window.close();   
   }

function MM_displayStatusMsg(msgStr) { 

  status=msgStr;

  document.MM_returnValue = true;

}

//Browser in Browser
var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
	return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
	if (ie5&&dragapproved&&event.button==1){
	document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
	document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
	document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
	document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
	}
}

function initializedrag(e){
	offsetx=ie5? event.clientX : e.clientX
	offsety=ie5? event.clientY : e.clientY
	document.getElementById("dwindowcontent").style.display="none" //extra
	tempx=parseInt(document.getElementById("dwindow").style.left)
	tempy=parseInt(document.getElementById("dwindow").style.top)

	dragapproved=true
	document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
	window.open(url,"","width=width,height=height,scrollbars=1")
else{
	document.getElementById("dwindow").style.display=''
	document.getElementById("dwindow").style.width=initialwidth=width+"px"
	document.getElementById("dwindow").style.height=initialheight=height+"px"
	document.getElementById("dwindow").style.left="30px"
	document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
	document.getElementById("cframe").src=url
	}
}

function maximize(){
	if (minrestore==0){
	minrestore=1 //maximize window
	document.getElementById("maxname").setAttribute("src","restore.gif")
	document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
	document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
	minrestore=0 //restore window
	document.getElementById("maxname").setAttribute("src","max.gif")
	document.getElementById("dwindow").style.width=initialwidth
	document.getElementById("dwindow").style.height=initialheight
	}
	document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
	document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
	document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
	dragapproved=false;
	document.getElementById("dwindow").onmousemove=null;
	document.getElementById("dwindowcontent").style.display="" //extra
}

function MM_showModalDialog(url,obj,param){
	window.showModalDialog(url,obj,param);
}

function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) 
				c_end=document.cookie.length
			return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return ""
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}


function setCookie(c_name,value,expiredays)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function GetXmlHttpObject(){
	var xmlHttp;
	try{
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();
	}
	catch(e){
		try
		{      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
		}
		catch (e)
		{      
			try
			{        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  
			}
			catch (e)
			{        
				alert("Your browser does not support AJAX!");     
				return false; 
			}
		}
	}

	return xmlHttp;
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "0";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} 

function trim(str){
	return str.replace(/(^\s*)|(\s*$)/g, "");
}