function del_space(s)
{
	for(i=0;i<s.length;++i)
	{
	 if(s.charAt(i)!=" ")
		break;
	}

	for(j=s.length-1;j>=0;--j)
	{
	 if(s.charAt(j)!=" ")
		break;
	}

	return s.substring(i,++j);
}

function hide(str)
{
	if((str=="")||(str=="div_"))
		return(false);
	var strobj = document.all[str];
	if(strobj!=null) {	
		document.all(str).style.display=(document.all(str).style.display=='none')?'':'none';
	}
	else
		return(false);
}


function CheckText(obj,sPrompt)
{
	if(obj!=null)
	{
	var sValue = del_space(obj.value);
     if (sValue.length == 0)
     {
        alert(sPrompt);
		obj.focus();
		return false;
     }
	 else
	 	return true;
	}
	 else
	 	return true;
}

function CheckFloat(obj,sPrompt)
{
	if(obj!=null)
	{
	var sValue = del_space(obj.value);
     if (sValue.length > 0)
     {
	 	sValue=sValue.replace(/\s/g,"");
		var parttern=/^\d+(\.\d+)?$/;
		if(!parttern.test(sValue))
		{
			alert(sPrompt);
			obj.focus();
			return false;
		}
		else
			return true;
	 }
	 else
	 	return true;
	}
	 else
	 	return true;
}

function CheckNumber(obj,sPrompt)
{
	if(obj!=null)
	{
	var sValue = del_space(obj.value);
     if (sValue.length > 0)
	 {
		if(sValue.match(/\D/)!=null)
		{
			alert(sPrompt);
			obj.focus();
			return false;
		}
		else
			return true;
	 }
	 else
	 	return true;
	}
	 else
	 	return true;
}

function analyzEmailaddr(obj,sPrompt){
  var r = new RegExp("^[a-zA-Z][A-Za-z0-9_.-]+@[a-zA-Z0-9_]+?\.[a-zA-Z]{2,3}$", "g");
	if(obj!=null)
	{
	var sValue = del_space(obj.value);
     if (sValue.length > 0)
	 {
		  if (r.test(sValue))
			return true;
		  else  
			{
				alert(sPrompt);
				obj.focus();
				return false;
			}
	 }
	 else
	 	return true;
	}
	 else
	 	return true;	 
}


var wordWrap = function(bigString, m, b, c){
	var i, j, s, r = bigString.split("\n");     
	if(m > 0) 
		for(i in r){
		for(s = r[i], r[i] = ""; s.length > m;j = c ? m : (j = s.substr(0, m).match(/\S*$/)).input.length - j[0].length|| m,			r[i] += s.substr(0, j) + ((s = s.substr(j)).length ? b : ""));         
		r[i] += s;
		}
		return r.join("\n"); 
}
function openCenterWindow(sUrl,sWindow, nHeight,nWidth){
	var newWindow=null
	  var myLeft = (screen.width-nWidth)/2;
    var myTop = (screen.height-nHeight)/2;
    if (!newWindow || newWindow.closed){
    	newWindow=window.open(sUrl,sWindow,"resizable=1,location=no,height="+nHeight+",width="+nWidth+",left="+myLeft+",top="+myTop);
    	newWindow.focus()
	}else{
		newWindow.focus()
	}
}

function notifyMe(FrameColorID)
{
	var page='/glasses/notifyMe.pge?FrameColorID='+FrameColorID;			
	//window.open(page, "notifyMe", "height=200,width=350");
	openCenterWindow(page,"notifyMe",200,350)
} 




