function dispStatus(){
	var workingNow = "Operation in Progress.";
	if(window.status == "" || window.status.length > 50)
		window.status = workingNow;
	else
		window.status = window.status + ".";
}

function dispWordStatus(){
	var workingNow = "In Progress.";
	if(window.status == "" || window.status.length > 50)
		window.status = workingNow;
	else
		window.status = window.status + ".";
}


function ifNumber(num){
	for(var i=0;i<num.length;i++){
		if(isNaN(parseInt(num.substring(i,i+1)))) return true;
	}
	return false;
}

function inArray(str,ary){
	for(var i=0;i<ary.length;i++){
		if(ary[i] == str) return true;
	}
	return false;
}

function ifEmpty(obj,message){
	if(obj.value == ""){
		alert(message);
		obj.focus();
		return false;
	}
	return true;
}

function openUrlAuto(theUrl,wlength,hlength)
{
    window.open(theUrl, "","width="+wlength+",height="+hlength+",resizable=yes,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,top=150,left=200");
}

function openUrlWithMenu(theUrl,wlength,hlength)
{
    window.open(theUrl, "","width="+wlength+",height="+hlength+",resizable=yes,toolbar=no,location=no,status=yes,menubar=yes,scrollbars=yes,top=150,left=200");
}

function FirstLetterUpperCaseForShortName(obj){
	txt= obj.value+" ";
	txt=txt.toLowerCase();
	txtModified="";
	while ((txt.length>0)&&(txt.indexOf(" ")>-1)){
		pos=txt.indexOf(" ");
		word=txt.substring(0,pos);
		txt=txt.substring((pos+1),txt.length);
		txtModified+=word.substring(0,1).toUpperCase()+word.substring(1,word.length).toLowerCase()+" "; 
	}

	obj.value=trim(txtModified);
}

function trim(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
}

function checkInutNumber(e)
{
	var k = window.event.keyCode;
	if (k < 48 || k > 57){
		alert("Please enter number£¡")
		window.event.keyCode = 0 ;}
}

document.nbrofTimeout=0;
document.currentTimeOut = 0;
function loadBigPic(image){
	document.img=image;
	document.awayFromPic=false;
	setTimeout("changePic2Big()",1000);
	document.nbrofTimeout+=1;
}

function changePic2Big(){
	var image = document.img;
	var oPath = "icopic";
	var dPath = "smallpic";
	document.currentTimeOut+=1;
	
	if(image.src.indexOf(dPath)>0) return;
	if ((document.awayFromPic==false) && (document.currentTimeOut==document.nbrofTimeout)){
		image.src=image.src.replace(oPath,dPath);
		document.awayFromPic=true;

        try{
            moveRedCross();
        }catch(err){
            
        }
    }
}

function outOfPic(){
	document.awayFromPic=true;
}

function gotoW(url,w,h){  
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; 
TopPosition = (screen.height) ? (screen.height-h)/2 : 0; 
settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes'+',status=yes,resizable=yes'
window.open(url,'_blank',settings);  
}

function moveToCenter(windowWidth,windowLength){
	var LeftPosition = (screen.width-windowWidth)/2;
	var TopPosition  = (screen.height-windowLength)/2;
	window.moveTo(LeftPosition,TopPosition);
}

function viewHistory(url)
{
		window.open(url,'_blank','status=no,resizable=yes,scrollbars=yes,top=70,right=10,width=780,height=400');	
}

function getRadioValue(obj){
    for(var i=0;i<obj.length;i++){
        if(obj[i].checked) return obj[i].value;
    }
    return "";
}

function setOptionSelected(obj,val){
	for(var i=0;i<obj.length;i++){
		if(obj.options[i].value == val)
			obj.options[i].selected = true;
	}
}

