
function print_r(x, max, sep, l) { 
	 
	    l = l || 0; 
	    max = max || 10; 
	    sep = sep || ' '; 
	 
	    if (l > max) { 
	        return "[WARNING: Too much recursion]\n"; 
	    } 
	 
	    var 
	        i, 
	        r = '', 
	        t = typeof x, 
	        tab = ''; 
	 
	    if (x === null) { 
	        r += "(null)\n"; 
	    } else if (t == 'object') { 
	 
	        l++; 
	 
	        for (i = 0; i < l; i++) { 
	            tab += sep; 
	        } 
	 
	        if (x && x.length) { 
	            t = 'array'; 
	        } 
	 
	        r += '(' + t + ") :\n"; 
	 
	        for (i in x) { 
	            try { 
	                r += tab + '[' + i + '] : ' + print_r(x[i], max, sep, (l + 1)); 
	            } catch(e) { 
	                return "[ERROR: " + e + "]\n"; 
	            } 
	        } 
	 
	    } else { 
	 
	        if (t == 'string') { 
	            if (x == '') { 
	                x = '(empty)'; 
	            } 
	        } 
	 
	        r += '(' + t + ') ' + x + "\n"; 
	 
	    } 
	 
	    return r; 
	 
	}





var dtCh= "-";
var minYear=1900;
var maxYear=2100;
function isInteger(s)
{
	var i;
	 for (i = 0; i < s.length; i++)
	{   
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	return true;
}
function stripCharsInBag(s, bag)
{
	var i;
	var returnString = "";
	 // Search through string's characters one by one.
	 // If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}
function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
	// EXCEPT for centurial years which are not also divisible by 400.
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n)
{
	for (var i = 1; i <= n; i++) 
	{
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
	} 
	return this
}

function isDate(dtStr)
{
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	//var strMonth=dtStr.substring(0,pos1)
	//var strDay=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++)
	{
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	day=parseInt(strDay)
	month=parseInt(strMonth)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1)
	{
		//alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12)
	{
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month])
	{
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear)
	{
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
	{
		//alert("Please enter a valid date")
		return false
	}
	return true;
}
function isInt(arg)
{
	if(parseInt(arg).toString()!=arg)
	{
		return false;
	}
	return true;
}
function validatePwd(pwd)
{
	var invalid = " "; 
	var minLength=6;
	var msg="";
	var pw=pwd;
	// check for minimum length
	if(pwd.length < minLength)
	{
		msg='Your password must be at least ' + minLength + ' characters long.\n';
	}
	// check for spaces
	if(pwd.indexOf(invalid) > -1)
	{
		msg=msg+"Spaces in password are not allowed.\n";
	}
	return msg;
}
function echeck(str)
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1)
	{
		return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid E-mail ID")
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		return false
	}
	if (str.indexOf(at,(lat+1))!=-1)
	{
		return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		return false
	}
	if (str.indexOf(dot,(lat+2))==-1)
	{
		return false
	}
	if (str.indexOf(" ")!=-1)
	{
		return false
	}
	return true					
}

function getXYPosition(e){
	myMouseX=(e||event).clientX;
	myMouseY=(e||event).clientY;
	if (document.documentElement.scrollTop > 0) {
		myMouseY = myMouseY + document.documentElement.scrollTop;
	}
	return [myMouseX,myMouseY];	
}

function pageSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight];
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function show_desc(desc_num)
{
	var el = document.getElementById('newsdesc_'+desc_num);
	if(el)
	{
		
		el.style.display	= 'block';
	}
}

function move_desc(desc_num,evt)
{
	var el = document.getElementById('newsdesc_'+desc_num);
	if(el)
	{
		var x	= getScrollXY()[0] + getXYPosition(evt)[0];
		
		var y	= getScrollXY()[1] + getXYPosition(evt)[1];
		
		if(x > (pageSize()[0] - 170))
		{
			x = pageSize()[0] - 170;
		}
		
		el.style.top	= (y+10)+'px';
		el.style.left	= (x+10)+'px';
	}
}

function hide_desc(desc_num)
{
	var el = document.getElementById('newsdesc_'+desc_num);
	if(el)
	{
		el.style.display	= 'none';
	}
}

function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function js_slideshow(page_id)
{
	var els = getElementsByClassName('slideshow_'+page_id);
	if(els.length>0)
	{
		simulateClick(els[0]);
	}
	return false;
}

function simulateClick(el) {
var evt;
//var el = document.getElementById(elId);
if (document.createEvent){
evt = document.createEvent("MouseEvents");
if (evt.initMouseEvent){
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
} else {
evt = false;
}
}
(evt)? el.dispatchEvent(evt):(el.click && el.click());
} 
