
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]+"'");
}

//addEvent( window, "load", fixIE );
function addEvent (obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

function openWindow(Url, winName, winWidth, winHeight) {
	try {

		//imgWindow = window.open(imgName, 'ZoomImage', 'top=0, left=0, toolbar=no, location=no, directories=no, scrollbars=yes, status=no, resizable=yes');
		var winWidth=(winWidth>screen.width)?screen.width:winWidth;
		var winHeight=(winHeight>screen.height)?screen.height:winHeight;

		var windowX = (screen.height-winHeight)/2;
		var windowY = (screen.width-winWidth)/2;

		newWindow = window.open(Url, winName, 'top='+windowX+', left='+windowY+', toolbar=no, location=no, directories=no, scrollbars=yes, status=no, resizable=yes, width='+winWidth+', height='+winHeight+'');
		newWindow.focus();

	} catch (e) { }

}

function FlashContent ( filename, width, height, wmode ) {
	try {
		var temp = filename.split('.');
		var files = '';
		for (i=0; i<temp.length-1; i++) files = files +temp[i] + (i<temp.length-2?'.':'');

		var wmode = (wmode==true?'transparent':'window');
		AC_FL_RunContent (
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			'width', width,
			'height', height,
			'src', files,
			'quality', 'high',
			'menu', 'false',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'scale', 'noscale',
			'movie', files,
			'wmode', wmode
		); //end AC code
		/*
AC_FL_RunContent(
'codebase', 'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
'width', '200',
'height', '200',
'src', 'yourswffile',
'quality', 'high',
'pluginspage', 'https://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'false',
'scale', 'noscale',
'wmode', 'window',
'devicefont', 'false',
'id', 'flash-animations',
'bgcolor', '#eeeeee',
'name', 'yourswffile',
'menu', 'false',
'allowScriptAccess','sameDomain',
'movie', 'yourswffile',
'salign', ''
);
		*/
	} catch (e) { }
}


/* Function String */
function getTextValue ( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcInput = eval( 'form.' + srcListName );
	if ( Trim(srcInput.value) != '') {
		return srcInput.value;
	} else {
		return null;
	}
}

function getSelectedOption( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i];
	} else {
		return null;
	}
}

function getSelectedValue( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].value;
	} else {
		return null;
	}
}


function setSelectedValue( frmName, srcListName, value ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	var srcLen = srcList.length;

	for (var i=0; i < srcLen; i++) {
		srcList.options[i].selected = false;
		if (srcList.options[i].value == value) {
			srcList.options[i].selected = true;
		}
	}
}
function getSelectedRadio( frmName, srcGroupName ) {
	var form = eval( 'document.' + frmName );
	var srcGroup = eval( 'form.' + srcGroupName );

	if (srcGroup[0]) {
		for (var i=0, n=srcGroup.length; i < n; i++) {
			if (srcGroup[i].checked) {
				return srcGroup[i].value;
			}
		}
	} else {
		if (srcGroup.checked) {
			return srcGroup.value;
		} // if the one button is checked, return zero
	}
	// if we get to this point, no radio button is selected
	return null;
}

function getSelectedText( frmName, srcListName ) {
	var form = eval( 'document.' + frmName );
	var srcList = eval( 'form.' + srcListName );

	i = srcList.selectedIndex;
	if (i != null && i > -1) {
		return srcList.options[i].text;
	} else {
		return null;
	}
}

function Trim(str){
	return str.replace(/^\s+|\s+$/g, ''); 
}

// onKeyPress="return KeyDigit(this.value, event);"
function KeyDigit(str, e) {
var keycode;
if (window.event)
	keycode = window.event.keyCode;
else if (e)
	keycode = e.which;
else
	return true;

if (((keycode>47) && (keycode<58) )  || (keycode==8))
	return true;
else
	return false;
}

function validateEmail( strValue) {
	var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
	var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;

	if (strValue == "") {
		return false;
	} else if (!emailFilter.test(strValue)) { //test email for illegal characters
		return false;
	} else if (strValue.match(illegalChars)) {
		return false;
	} else {
		return true;
	}
}

function validateNumeric( strValue ) { // Valid only numeric ( -1, 2.4, 5 )
	var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; 

	//check for numeric characters 
	return objRegExp.test(strValue);
}

function validateInteger( strValue ) { // Valid only 0-9
	var objRegExp  = /(^-?\d\d*$)/;

	//check for integer characters
	return objRegExp.test(strValue);
}

function validateTime ( strTime ) { // Valid only hh:mm or hh.mm
	//var objRegExp  = /^([01]?[0-9]|[2][0-3])(:|.)([0-5][0-9])?$/;
	var objRegExp = /^([0-9]|[0-1][0-9]|2[0-3])[:|.][0-5][0-9]$/;

	//check for time syntex
	return objRegExp.test(strTime);
	//return /^([01]?[0-9]|[2][0-3])(:|.)([0-5][0-9])?$/.test(strTime);
}

function swapImg (img, imgname) {
	try {
		img.src = imgname;
	} catch (e) { }
}

function setGMTTime( dt ) {
	try {
		var strGMT = dt.toGMTString().substring(0, dt.toGMTString().length-3); // remove string UTC
		var gmt = new Date( strGMT );
		gmt.setHours( gmt.getHours()+7 );
		return gmt;
	} catch (e) { }
	return dt;

}

function chgInnerHtml ( divName, Message ) {
	if (document.getElementById(divName)) { 
		if ( typeof document.getElementById(divName).innerHTML == 'string') { // IE
			document.getElementById(divName).innerHTML=Message;

		} else if ( typeof document.getElementById(divName).textContent == 'string') { // Firefox
			document.getElementById(divName).textContent=Message;

		}
		return divName;
	}
}