function popImage(imageTarget)
{
	var imgWin = window.open('','_blank','scrollbars=no,width=1,height=1,left=0,right=0');
	if (!imgWin) return true;
		
	
	imgWin.document.write('<html><head><title>Image<\/title> \n'+
						  '<script type="text\/javascript"> \n'+
						  'function resizeWinTo() \n'+
						  '{ \n'+
						  'var imObj = (document.images.length)?document.images[0]:document.layers[0].images[0]; \n'+
						  'oW = imObj.width; oH = imObj.height; \n'+
						  'win = window; win.resizeTo(oW,oH); \n'+
						  'myW=0; myH=0; docObj=win.document.documentElement; bodObj=win.document.body; \n'+
						  'if (win.innerWidth) {myW = win.innerWidth;myH=win.innerHeight;} \n'+ 
						  'else if(docObj.clientWidth) {myW=docObj.clientWidth; myH=docObj.clientHeight;} \n'+
						  'else if(bodObj.clientWidth) {myW=bodObj.clientWidth; myH=bodObj.clientHeight;}  \n'+
						  'win.resizeTo( oW+(oW-myW),oH+(oH-myH) ) \n'+
						  'scW = (screen.availWidth)?screen.availWidth:screen.width; \n'+
						  'scH = (screen.availHeight)?screen.availHeight:screen.height; \n'+
						  'win.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); \n'+
						  '} \n'+
						  '<\/script> \n'+
						  '<\/head> \n'+
						  '<body onload="resizeWinTo()"> \n'+
						  (document.layers?('<layer top=0 left=0>'):('<div style="position:absolute;left:0px;top:0px;">'))+
						  '<img src='+imageTarget+' onload="resizeWinTo();" \/> \n'+
						  (document.layers?'<\/layer><\/body><\/html>':'<\/div><\/body><\/html>'));
						  imgWin.document.close();
}

function isDate(strValue)
{
	var regExp = /^\d{4}\-\d{2}\-\d{2}$/;
	if (regExp.test(strValue))
	return true;

	return false;
}

function isEmail(strValue)
{
	var regExp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3})$/;

	if (regExp.test(strValue))
	return true;

	return false;
}

function isFloat(strValue)
{
	var regExp = /^([\d]+)(.[\d]+)?$/;
	
	if (regExp.test(strValue))
	return true;

	return false;
}

function match2RegExp(strValue,pattern)
{
	var regExp = pattern;
	
	if (eval(regExp).test(strValue))
	return true;

	return false;
}

function validateForm(theForm)
{
	var i;		
	var errorString="";
	
	for(i=0; i<theForm.elements.length; i++)
	{
		if (theForm.elements[i].getAttribute("required"))
		{
			if (theForm.elements[i].value=="")
				errorString+= theForm.elements[i].getAttribute("required")+"\n";
		}
		
		if (theForm.elements[i].getAttribute("reg_exp"))
		{
			if (theForm.elements[i].value!="" && !match2RegExp(theForm.elements[i].value,theForm.elements[i].getAttribute("pattern")))
				errorString+= theForm.elements[i].getAttribute("reg_exp")+"\n";
		}
		
		if (theForm.elements[i].getAttribute("numeric"))
		{
			if (theForm.elements[i].value!="" && /*isNaN(theForm.elements[i].value)*/ !isFloat(theForm.elements[i].value))
				errorString+= theForm.elements[i].getAttribute("numeric")+"\n";
		}
		
		if (theForm.elements[i].getAttribute("date"))
		{
			if (theForm.elements[i].value!="" && !isDate(theForm.elements[i].value))
				errorString+= theForm.elements[i].getAttribute("date")+"\n";
		}
		
		if (theForm.elements[i].getAttribute("email"))
		{
			if (theForm.elements[i].value!="" && !isEmail(theForm.elements[i].value))
				errorString+= theForm.elements[i].getAttribute("email")+"\n";
		}
		
		if (theForm.elements[i].getAttribute("s_required"))
		{
			if (theForm.elements[i].options.length > 0)
			{
				var myindex = theForm.elements[i].selectedIndex;
				
				if (theForm.elements[i].options[myindex].value==0)
					errorString+= theForm.elements[i].getAttribute("s_required")+"\n";
			}
			else
				errorString+= theForm.elements[i].getAttribute("s_required")+"\n";
		}
		
		if (theForm.elements[i].getAttribute("ch_required"))
		{
			if (theForm.elements[i].checked==false)
				errorString+= theForm.elements[i].getAttribute("ch_required")+"\n";
		}
		
		
		if (theForm.elements[i].getAttribute("rd_required"))
		{
				
				if (errorString.indexOf(theForm.elements[i].getAttribute("rd_required")) == -1)
				{
					var radiobtn = eval('theForm.'+(theForm.elements[i].getAttribute('name')).toString());
					var k;
					var checked=false;
								
					//for(k=radiobtn.length-1; k > -1; k--)
					for(k=0; k<radiobtn.length; k++)
					{
						if (radiobtn[k].checked==true)
						{
							checked=true;
							break;
						}
					}
				
					if (checked==false)
					errorString+= theForm.elements[i].getAttribute("rd_required")+"\n";
				}
		}
		
		if(theForm.elements[i].getAttribute("grch_required"))
		{
			if (errorString.indexOf(theForm.elements[i].getAttribute("grch_required")) == -1)
			{
				var grpCHBname = theForm.elements[i].name
				var checkboxes = document.getElementsByName(grpCHBname);
				var checked2=false;
				var y;
			
				for(y=0; y<checkboxes.length; y++)
				{
					if (checkboxes[y].checked==true)
					{
						checked2=true;
						break;
					}
				}
			
				if (checked2==false)
				errorString+= theForm.elements[i].getAttribute("grch_required")+"\n";
			}	
		}
		
	}
		
	if (errorString!="")
	{
		alert(errorString);
		return false;
	}
}