function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}

}





function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_empty(thisform)
{
with (thisform)
 	{ 
 
if (validate_required(cando,"Please enter your email address!")==false)
  {cando.focus();return false}

if (validate_required(arco,"Please enter your name!")==false)
  {arco.focus();return false}
  
if (validate_required(cambo,"Please enter your message!")==false)
  {cambo.focus();return false}
  
if (validate_required(ebo,"Please seclect where you want to send your query!")==false)
  {ebo.focus();return false}  
  
  if (validate_email(cando,"Not a valid e-mail address!")==false)
  {cando.focus();return false}
 
	}


}







function openWin(URL) {
var openWin = window.open(URL,'','name=order,scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}

function toggleLayer( whichLayer )
{  
var elem, vis;  
if( document.getElementById ) 
// this is the way the standards work    
elem = document.getElementById( whichLayer );  
else if( document.all ) 
// this is the way old msie versions work      
elem = document.all[whichLayer];  
else if( document.layers ) 
// this is the way nn4 works    
elem = document.layers[whichLayer];  
vis = elem.style;  
// if the style.display value is blank we try to figure it out here  
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function toggleFlash( whichLayer )
{  
var elem, vis;  
if( document.getElementById ) 
// this is the way the standards work    
elem = document.getElementById( whichLayer );  
else if( document.all ) 
// this is the way old msie versions work      
elem = document.all[whichLayer];  
else if( document.layers ) 
// this is the way nn4 works    
elem = document.layers[whichLayer];  
vis = elem.style;  
// if the style.display value is blank we try to figure it out here  
if(vis.overflow==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
vis.overflow = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'hidden':'visible';  
vis.overflow = (vis.overflow==''||vis.overflow=='visible')?'hidden':'visible';
}


var doAlerts=false;
function changeSheets(whichSheet){
  whichSheet=whichSheet-1;
  if(document.styleSheets){
    var c = document.styleSheets.length;
    if (doAlerts) alert('Change to Style '+(whichSheet+1));
    for(var i=0;i<c;i++){
      if(i!=whichSheet){
        document.styleSheets[i].disabled=true;
      }else{
        document.styleSheets[i].disabled=false;
      }
    }
  }
}








function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


          <!--
          function isEmailValid(oEmail)
          {
            email = oEmail.value
            r1 = new RegExp('(@.*@)|(\\.\\.)|(@\\.)|(^\\.)')
            r2 = new RegExp('^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$')
            return (!r1.test(email) && r2.test(email))
          }


          function IsPhoneNumber(strString)
             //  check for phone numbers
             {
             var strValidChars = '0123456789';
             var strChar;
             var blnResult = false;

             //  test strString consists of valid characters listed above
             for (i = 0; i < strString.length; i++)
                {
                strChar = strString.charAt(i);
                if (strValidChars.indexOf(strChar) != -1) {
                   return true;
                   }
                }
             return blnResult;
             }

            function checkForm(oFrm)
            {
              if (oFrm.first_name.value=='') {
                alert('Please fill in your first name!')
                oFrm.first_name.focus()
                return false
              }

			  /*if (oFrm.EmailID.value=='') {
                alert('Please choose what you want to subscribe to!')
                oFrm.EmailID.focus()
                return false
              }*/
			  
              if (oFrm.second_name.value=='') {
                alert('Please Fill in your second name!')
                oFrm.second_name.focus()
                return false
              }
			  
              if (oFrm.address_1.value=='') {
                alert('Please Fill in your Address!')
                oFrm.address_1.focus()
                return false
              }
			  if (oFrm.address_5.value=='') {
                alert('Please choose in your County!')
                oFrm.address_5.focus()
                return false
              }

			  
			  if (oFrm.telephone_number.value=='') {
                alert('Please Fill in your telephone number!')
                oFrm.telephone_number.focus()
                return false
              } else if(!IsPhoneNumber(oFrm.telephone_number.value)) {
                alert('Please enter a valid phone number');
                return false;
              }
			  
			  if (oFrm.Email.value=='') {
                alert('Please Fill in your Email address!')
                oFrm.Email.focus()
                return false
              } else if (!isEmailValid(oFrm.Email)) {
                alert('Please enter a valid email address!');
                oFrm.Email.focus()
                return false
              }
              
              
            }
			
			
			

function OpenMediaWin(id){
  width = 400
  height = 600
  url = 'http://www.drugs.ie/media/view_video.php?id=' + id
  xPos = (screen.width - width) / 2
  yPos = (screen.height - height) / 2
  so = window.open(url, '', 'width=' + width + ',height=' + height + ',left=' + 100 + ',top=' + 100)
}


function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}
		
          // -->
        
