function popJS(){
	var _args=arguments,_tag=_args[0],_class=_args[1];
	if(document.getElementById){
		var _a=[],_i=0;
		_a=document.getElementsByTagName(_tag);
		for(_i;_i<_a.length;_i++){
			if(_a[_i].className && (_a[_i].className==_args[1])){
				_a[_i].onclick=function(){javascript:w(this.href,_args[1]);return false;};
				_a[_i].onkeypress=function(){javascript:w(this.href,_args[1]);return false;};
			}
		}
	}
}


var win;



function getWindowCenter(_iX,_iY){
 var iWinX=(screen.width - _iX)/2;
 var iWinY=(screen.height - _iY)/2;
 return('top='+iWinY+',left='+iWinX);
}



function createWindowName(_sUrl){

 var _iLastSlash=_sUrl.lastIndexOf('/');

 var _iLastSlashMin=_sUrl.substring(0,(_iLastSlash-1)).lastIndexOf('/');

 return(_sUrl.substr(_iLastSlash,_sUrl.length).indexOf('.')>0)?('file_'+escape(_sUrl.substring(_iLastSlash+1,_sUrl.lastIndexOf('.')))):('file_'+ escape(_sUrl.substring((_iLastSlashMin+1),_iLastSlash)));

}



function createWindow(_sUrl,_sName,_sParams){

 win=window.open(_sUrl,_sName,_sParams);

 if(win){win.focus();}
 return(win);

}

function w(_sUrl,_sType){
  // fix for video_galler
  // all event_webcasts popups of type video will be converted to type webcast (bigger window)
  _sLocation = document.location.toString();
  if( _sLocation.indexOf('video_gallery') >= 0 && _sLocation.indexOf('event_webcasts') >= 0 ){
	  _sType = 'webcast';
  }
	
 var _sParams,_sName,_sWinPos,_iX,_iY;
 switch(_sType){
  case'html':
   _iX=800;
   _iY=600;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=1,status=1';
   _sName='form';
   break;
  case'video': 
   _iX=450;
   _iY=350;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=0,status=1';
   _sName=createWindowName(_sUrl);
   break;
  case'slideshow': 
   _iX=750;
   _iY=410;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=0,status=1';
   _sName=createWindowName(_sUrl);
   break;
  case'webcast':
   _iX=750;
   _iY=550;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=0,status=1';
   _sName=createWindowName(_sUrl);
   break;
  case'colors':
   _iX=600;
   _iY=400;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=0,status=1';
   _sName=createWindowName(_sUrl);
   break;
  case'form':
   _iX=645;
   _iY=440;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=no,location=0;toolbars=0,resizable=0,status=1';
   _sName='form';
   break;
  case'filter_rules':
  case'text':
  case'note':
   _iX=640;
   _iY=500;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=0,status=1'; 
   _sName=createWindowName(_sUrl);
   break;
  case'relatedlinks':
   _iX=600;
   _iY=200;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=0,status=1'; 
   _sName='relatedlinks';
   break;
  case'print':
   _iX=640;
   _iY=550;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,menubar=1,resizable=0,status=1'; 
   _sName='print';
   break;
  case'table':
  case'large':
   _iX=924;
   _iY=600;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0,toolbars=1,resizable=1,status=1';
   _sName=createWindowName(_sUrl);
   break;
  case'word':
  case'xls':
  case'pdf':
   _iX=600;
   _iY=500;
   _sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0,toolbars=1,menubar=1,resizable=1,status=1';
   _sName='file';
   break;
 };

 _sWinPos=getWindowCenter(_iX,_iY);

 _sParams+=','+_sWinPos;

 return(createWindow(_sUrl,_sName,_sParams));

}


/* 2nd popper for more  manual control */
var newWin = null; 
function popUp(strURL, strType, strHeight, strWidth) { 
 if (newWin != null && !newWin.closed) 
   newWin.close(); 
 var strOptions=""; 
 if (strType=="console") 
   strOptions="resizable,height="+ 
     strHeight+",width="+strWidth; 
 if (strType=="fixed") 
   strOptions="status,height="+ 
     strHeight+",width="+strWidth; 
 if (strType=="fixedscroll") 
   strOptions="status,scrollbars,height="+ 
     strHeight+",width="+strWidth; 
 if (strType=="elastic") 
   strOptions="toolbar,menubar,scrollbars,"+ 
     "resizable,location,height="+ 
     strHeight+",width="+strWidth; 
if (strType=="elastic_toolbar") 
   strOptions="toolbar,"+ 
     "resizable,height="+ 
     strHeight+",width="+strWidth; 
 newWin = window.open(strURL, 'newWin', strOptions); 
 newWin.focus(); 
}

function parentNav(_sUrl){if(window.opener != null){window.opener.location=_sUrl;window.opener.focus();}}

function printPage(){window.print();}

function checkEmail(_frm,_el){
 var _o=document.forms[_frm].elements[_el];
 var _rv=false;
 var _regex=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
 if(_o.value && (_o.value.length > 0) && _regex.test(_o.value)){
  _rv=true;
 }else{
  alert('Please enter a valid email address.');
  _o.focus();
 }
 return(_rv);
}



