// JavaScript Document


 function ById(id) 	{	return document.getElementById(id) ; }
 function ByName(name){	return document.getElementsByName(name) ; }
 
 
function removeByElement(arrayName,arrayElement)
 {
    for(var i=0; i<arrayName.length;i++ )
     { 
        if(arrayName[i]==arrayElement)
            arrayName.splice(i,1); 
      } 
  }


function InArray(Needle,hayStack)
{var Check=0;
	for(i=0;i<hayStack.length;i++)
	{if(Needle==hayStack[i])Check=1;}
	if(Check==1){ return true;}else{ return false;}
}
 
 
 
 
 
function ValidateNumeric(txtbox,e) {
var numstr=parseInt(txtbox.value);
if(isNaN(numstr)){txtbox.value=''}else{txtbox.value=numstr}
}

function ValidateNumeric2(txtbox,e) { 
  if (window.event)  var   key = window.event.keyCode;
  else if (e)   var  key = e.which;
  if(key<48 || key>57){ txtbox.value=txtbox.value.substring(0,(txtbox.value.length)-1); }
  
}
 
<!-- Paste this code into an external JavaScript file named: validNum.js  -->

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Manzi Olivier :: http://www.imanzi.com/ */

// calculate the ASCII code of the given character
function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}







function ValidateEmail(field){
if(field.value=='')
		{			
			alert("Email address is required");
			field.focus();
			return false;
			
		} else if (field.value.length >0){ 
			i=field.value.indexOf("@")
			j=field.value.indexOf(".",i)
			k=field.value.indexOf(",")
			kk=field.value.indexOf(" ")
			jj=field.value.lastIndexOf(".")+1
			len=field.value.length
			
			if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)){return true;
			}else {
				alert("Please enter a valid email address.\n");
				field.focus();
				return false;
			}
		} 
		
}









/***************** IMAGES SLIDESHOW FUNCTIONS ****************************************************/ 

function SlideSHOW(divId) {
    var $active = $('#'+divId+' IMG.active');
    if ( $active.length == 0 ) $active = $('#'+divId+' IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#'+divId+' IMG:first');
    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass('active last-active');
        });
}

 
/*function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    var $next = $active.next();

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
   // setInterval( "slideSwitch()", 5000 );
});
*/
/***************** DATE TIME RELATED ****************************************************/ 
 

 
 
 
 
 
var newDateObj = new Date()

var cDate=newDateObj.getDate()
var cMonth=newDateObj.getMonth()
var cYear=newDateObj.getFullYear()


var MonthsArray=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] 
 
 function DateInfo(dateObj)
{
var dateinfo='';	
  var x = new Array("Sunday", "Monday", "Tuesday");
  var x = x.concat("Wednesday","Thursday", "Friday");
  var x = x.concat("Saturday");
day = dateObj.getDay();
day = x[day] ;

dateinfo = day+', '+MonthsArray[dateObj.getMonth()]+' '+dateObj.getDate()+', '+dateObj.getFullYear();
 
 return dateinfo.toString(); 
}

/***************** DATE TIME RELATED ****************************************************/

var AS_CLASS_COMMON_TOOLS = function(OBJ){
 
this.Browser='';
this.IsIE=false ;
this.CenterX='';
this.CenterY='';
this.Top='';
this.UserAgent = navigator.userAgent;				

this.getBrowser=function(){
					if ((i = this.UserAgent.indexOf("Netscape6/")) >= 0) {this.Browser="NS"}	
					else if ((i = this.UserAgent.indexOf("MSIE")) >= 0)  {this.Browser="IE"; this.IsIE=true;}
					else if ((i = this.UserAgent.indexOf("Gecko")) >= 0) {this.Browser="NS"}	
					return this.Browser;
				};this.getBrowser();
				
this.GetAjax=function(){				
					var HTTPXML = null;
					if (document.all) 
					  HTTPXML = new ActiveXObject("Msxml2.XMLHTTP");
					else if (XMLHttpRequest)
					  HTTPXML = new XMLHttpRequest();				
				}
				
this.GetCenterCords=function(){
					 posYstart=parseInt((window.screen.availHeight)/2)
					 posXstart=parseInt((window.screen.availWidth)/2)
					 if (this.Browser=='IE'){ 
						  this.CenterX=document.body.scrollLeft+posXstart; 
						  this.CenterY=document.documentElement.scrollTop  + document.body.scrollTop+posYstart;
						  this.Top=document.body.scrollTop;
					  }
					 if (this.Browser=='NS'){   
						  this.CenterX=window.scrollX+posXstart;   
						  this.CenterY = window.scrollY+posYstart;
						  this.Top= window.scrollY;
					  }
					}




};
ASTOOLS=new AS_CLASS_COMMON_TOOLS();

 
function ShowLoader(val){if(val==1){ ById('loadinfo').style.display="block";}else{ ById('loadinfo').style.display="none";}}




 


  
 
 
// End code for Determine the browser. ////////
// Start code for Drag any Object. ////////
var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {
 
  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (ASTOOLS.Browser=="IE")
      dragObj.elNode = window.event.srcElement;
    if (ASTOOLS.Browser=="NS")
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (ASTOOLS.Browser=="IE") {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (ASTOOLS.Browser=="NS") {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (ASTOOLS.Browser=="IE") {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (ASTOOLS.Browser=="NS") {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (ASTOOLS.Browser=="IE") {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (ASTOOLS.Browser=="NS") {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (ASTOOLS.Browser=="IE") {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (ASTOOLS.Browser=="NS")
    event.preventDefault();
}

function dragStop(event) {

  // Clear the drag element global.

  dragObj.elNode = null;

  // Stop capturing mousemove and mouseup events.

  if (ASTOOLS.Browser=="IE") {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (ASTOOLS.Browser=="NS") {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
// End code for Drag any Object. ////////

