function displayInfo(url,title,w,h)
{
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}

function NewWindow(mypage,myname,w,h,scroll)
{
	var win = null;
	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='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
}

// Popup images
function openNewImage(file, imgText) {	 	
	if (file.lang == 'no-popup') return;
	picfile = new Image();
	picfile.src =(file.src);
	width=picfile.width;
	height=picfile.height;
	
	if (imgText!='' && height>0) {
		height += 40;
	}
	else if (height==0) {
		height = screen.height;
	}

	winDef = 'status=no,resizable=yes,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(height).concat(',').concat('width=').concat(width).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - height)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - width)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<style>a:visited{color:blue;text-decoration:none}</style>');
	newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<div style="width:100%;height:100%;overflow:auto;"><a style="cursor:pointer" href="javascript:window.close()"><img src="', file.src, '" border=0></a>');
	if (imgText != '') {
		newwin.document.writeln('<div align="center" style="padding-top:5px;font-weight:bold;font-family:arial,Verdana,Tahoma;color:blue">', imgText , '</div></div>');
	}
	newwin.document.writeln('</body>');
	newwin.document.close();
}

function isEmail( text )
{
	var pattern = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp( pattern );
	return regex.test( text );
}

function SearchOnFocus(field)
{
	if(field.value=='Search')
	{
		field.value = '';
	}
}

function SearchOnBlur(field)
{
	if(field.value=='')
	{
		field.value='Search';
	}
}

function ismaxlen(obj){
  var maxlen=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>maxlen)
	obj.value=obj.value.substring(0,maxlen)
}

function toggleId(id,speed)
{
	var JQuery = jQuery.noConflict();
	JQuery("#"+id).toggle(speed);
}

function loadAjax(type,dataType,dataString,url,targetId,hidden)
{
	var JQuery = jQuery.noConflict();
	if(hidden==1)
	{
		 JQuery.ajax({
			   type:type,
			   dataType:dataType,
			   url:url,
			   data:dataString,
			   success: function(html){
					jQuery("#"+targetId).css({backgroundColor:"#40B220"});
					jQuery("#"+targetId).css({color:"#FFFFFF"});
					jQuery("#"+targetId).html(html)
					.fadeIn(1500,'')
					.fadeOut(2500,'');
				}
		});
	}
	else{
		  jQuery.ajax({
			   type:type,
			   dataType:dataType,
			   url:url,
			   data:dataString,
			   success: function(html){
					jQuery("#"+targetId).html(html)
				}
			});
		}
}

function clear(id)
{
	document.getElementById(id)	.value="";
}

function refreshCaptcha(target_id)
{
	var randomnumber=Math.floor(Math.random()*1001); // generate a random number to add to image url to prevent caching
    document.images[target_id].src = document.images[target_id].src + '&amp;rand=' + randomnumber; // change image src to the same url but with the random number on the end
}