﻿/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: kojak :: http://commoncoder.com */

// fieldname, warningname, remainingname, maxchars
function CheckFieldLength(fn,rn,mc) {
  var len = document.getElementById(fn).value.length;
  if (len > mc) {
    document.getElementById(fn).value = document.getElementById(fn).value.substring(0,mc);
    len = mc;
  }
////    document.getElementById(wn).innerHTML = len;
    document.getElementById(rn).innerHTML = mc - len;
}


function BlinkText(control)
{
//document.getElementById(control).style.color = "Black";
//alert(document.getElementById(control).style.color == "Black" || document.getElementById(control).style.color == "");
    if(document.getElementById(control).style.color == "Black" || document.getElementById(control).style.color == "")
   {document.getElementById(control).style.color = "Red";}
   else
   {document.getElementById(control).style.color = "Black";} 
}

function BtnMouseOver(control, imgsrc)
{
    var ctrid = control.id;
    alert(document.getElementById(ctrid).src);
    document.getElementById(ctrid).src = imgsrc; 
}

/***********************************************

* JavaScript Image Clock- by JavaScript Kit (www.javascriptkit.com)
* This notice must stay intact for usage
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more

***********************************************/
var imageclock=new Object()
var imagemthclock=new Object()
	//Enter path to clock digit images here, in order of 0-9, then "am/pm", then colon image:
	imageclock.digits=["../App_Themes/Default/Images/ClockImages/c0.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c1.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c2.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c3.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c4.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c5.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c6.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c7.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c8.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/c9.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/cam.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/cpm.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/ccolon.jpg"]
	imageclock.instances=0
	var preloadimages=[]
	for (var i=0; i<imageclock.digits.length; i++){ //preload images
		preloadimages[i]=new Image()
		preloadimages[i].src=imageclock.digits[i]
	}
	
	//Enter path to clock digit images here, in order of 0-9, then "am/pm", then colon image:
	imagemthclock.mth=["../App_Themes/Default/Images/ClockImages/cjan.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/cfeb.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/cmar.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/capr.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/cmay.jpg",
	                        "../App_Themes/Default/Images/ClockImages/cjun.jpg",
	                        "../App_Themes/Default/Images/ClockImages/cjul.jpg",
	                        "../App_Themes/Default/Images/ClockImages/caug.jpg",
	                        "../App_Themes/Default/Images/ClockImages/csep.jpg",
	                        "../App_Themes/Default/Images/ClockImages/coct.jpg",
	                        "../App_Themes/Default/Images/ClockImages/cnov.jpg",
	                        "../App_Themes/Default/Images/ClockImages/cdec.jpg", 
	                         "../App_Themes/Default/Images/ClockImages/cdash.jpg"] 
	imagemthclock.instances=0
	var preloadmthimages=[]
	for (var i=0; i<imagemthclock.mth.length; i++){ //preload images
		preloadmthimages[i]=new Image()
		preloadmthimages[i].src=imagemthclock.mth[i]
	}

	imageclock.imageHTML=function(timestring){ //return timestring (ie: 1:56:38) into string of images instead
		var sections=timestring.split(":")
		if (sections[0]=="0") //If hour field is 0 (aka 12 AM)
			sections[0]="12"
		else if (sections[0]>=13)
			sections[0]=sections[0]-12+""
		for (var i=0; i<sections.length; i++){
			if (sections[i].length==1)
				sections[i]='<img src="'+imageclock.digits[0]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i])]+'" />'
			else
				sections[i]='<img src="'+imageclock.digits[parseInt(sections[i].charAt(0))]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i].charAt(1))]+'" />'
		}
		return sections[0]+'<img src="'+imageclock.digits[12]+'" />'+sections[1]+'<img src="'+imageclock.digits[12]+'" />'+sections[2]
	}
	
	imagemthclock.dateimageHTML=function(datestring, type){ //return timestring (ie: March-01-2007) into string of images instead
		var sections=datestring.split("-")
		for (var i=0; i<sections.length; i++){
            if(type == "m" && i == 0)
		    { sections[i]= '<img src="'+imagemthclock.mth[parseInt(sections[i].charAt(0))]+'" />'}
		   else
		    {  
                if (sections[i].length==1)
				    sections[i]='<img src="'+imageclock.digits[0]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i])]+'" />'
			    else if(sections[i].length==2)
				    sections[i]='<img src="'+imageclock.digits[parseInt(sections[i].charAt(0))]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i].charAt(1))]+'" />'		    
                else if(sections[i].length==4)				    
                    sections[i]='<img src="'+imageclock.digits[parseInt(sections[i].charAt(0))]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i].charAt(1))]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i].charAt(2))]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i].charAt(3))]+'" />'		     
		    }
		}
		return sections[0]+'<img src="'+imagemthclock.mth[12]+'" />'+ sections[1]+'<img src="'+imagemthclock.mth[12]+'" />'+ sections[2]
	}

	imageclock.display=function(){
		var clockinstance=this
		this.spanid="clockspan"+(imageclock.instances++)
		document.write('<span id="'+this.spanid+'"></span>')
		this.update()
		setInterval(function(){clockinstance.update()}, 1000)
	}

	imageclock.display.prototype.update=function(){
		var dateobj=new Date()
		var currentdate = dateobj.getMonth() + '-' + dateobj.getDate() + '-' + dateobj.getFullYear()
		var currentdateHTML = imagemthclock.dateimageHTML(currentdate,'m')
		
		var currenttime=dateobj.getHours()+":"+dateobj.getMinutes()+":"+dateobj.getSeconds() //create time string
		var currenttimeHTML=imageclock.imageHTML(currenttime)+'<img src="'+((dateobj.getHours()>=12)? imageclock.digits[11] : imageclock.digits[10])+'" />'
		document.getElementById(this.spanid).innerHTML=currentdateHTML + "&nbsp;&nbsp;&nbsp;&nbsp;" + currenttimeHTML
	}



