function showVideoOverlay(){
    getObj('liVideoOverlay').style.display = 'none';
    getObj('cmdVideoOverlay').style.display = 'none';
    getObj('objVideoOverlayPos').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="500" height="282" id="send2flash" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="flash/player_flv_maxi.swf" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" /><param name="FlashVars" value="configxml=flash/config.xml" /><embed src="flash/player_flv_maxi.swf" loop="false" menu="false" quality="high" bgcolor="#ffffff" wmode="transparent" width="500" height="282" name="send2flash" align="middle" FlashVars="configxml=flash/config.xml" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
    getObj('objVideoOverlay').style.display = 'block';
}

function hideVideoOverlay(){
    getObj('liVideoOverlay').style.display = 'block';
    getObj('cmdVideoOverlay').style.display = 'block';
    getObj('objVideoOverlayPos').innerHTML = '&#160;';
    getObj('objVideoOverlay').style.display = 'none';
}

function getObj(strID){
    return document.getElementById(strID);
}

function getCookie(NameOfCookie){

	if (document.cookie.length > 0){ 

	begin = document.cookie.indexOf(NameOfCookie+"="); 
	if (begin != -1){ 

	begin += NameOfCookie.length+1; 
	end = document.cookie.indexOf(";", begin);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(begin, end)); } 
	}
	return ''; 

}

function setCookie(NameOfCookie, value, expiredays){

	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

	document.cookie = NameOfCookie + "=" + escape(value) + 
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie){

	if (getCookie(NameOfCookie)) {
	document.cookie = NameOfCookie + "=" +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

$(document).ready(
    function() {
        if (getCookie('didPageLoad') == '1') {
            // do nothing, we're already done watching this
            
        } else {
            // write 'didPageLoad'='1' cookie
            setCookie('didPageLoad', '1', 1);
            
            // autoplay video
            showVideoOverlay();
        }
    }    
);


function goBack() {

    if (document.referrer) {
       var prevPage = document.referrer;
       window.location.href = prevPage;
    }
}

// before and after download selections displayed in lightbox
//author:Marc Scarlatella
// functions retrieveFiles(),findFirstIndex(),boxesChecked(start)
function retrieveFiles() {
  var start=findFirstIndex()
  var count=boxesChecked(start);
   if(document.getElementById('terms').checked != true) {
       alert("Please certify that you have read the terms and conditions before downloading.");
    }
    else if(count==0) {
       alert("Please make at least one selection.");
     }
    else {
     tb_show('Download Before &amp; After Files', "#TB_inline?height=400&width=400&inlineId=myOnPageContent", null);
    var inputs=document.getElementsByTagName("input");
    for(i=start; i<start+13; i++) {
        temp=inputs[i].id.toString();
        listid = temp.replace("c","m");
        document.getElementById(listid).style.display="none"; 
        if(inputs[i].checked) {
         document.getElementById(listid).style.display="block";
        }// end if
    }// end for
    }
}

// certify user made at least one entry, hide and display headers
function boxesChecked(start) {
var count=0;
//reset main headers
document.getElementById('main1').style.display="none";
document.getElementById('main2').style.display="none";
document.getElementById('main3').style.display="none";
document.getElementById('main4').style.display="none";
var inputs=document.getElementsByTagName("input");
    for(i=start; i<start + 12; i++) {
        if(inputs[i].checked) {
        // activate main headers, increase count
            if(i>start-1 && i<start+3) {
             document.getElementById('main1').style.display="block";
            }
            if(i>start+2 && i<start+6) {
             document.getElementById('main2').style.display="block";
            }
            if(i>start+5 && i<start+9) {
             document.getElementById('main3').style.display="block";
            }
            if(i>start+8 && i<start+12) {
             document.getElementById('main4').style.display="block";
            }
        count++;
        }
    }// end for
return count;
}

// finds the array index of the first user input element.
function findFirstIndex() {
  var inputs=document.getElementsByTagName("input");
  var index=0;
   for(i=0; inputs[i].id!='c1'; i++) {
     index++;
    }// end for
return index;
}

function bailOut(href) {
var x=window.confirm("By clicking “OK,” you will leave the Juvéderm&reg; Web site to go to another Web site that is neither owned nor controlled by Allergan, Inc. Allergan, Inc. is not responsible for the content or services on this site.")
if (x){
window.open(href)
}
}

/// bdm form validation

function validate()
    {
        if (document.getElementById("ctl00_mycontent_txtFirstName").value=="")
      {
                 alert("Please enter your First Name");
                 document.getElementById("ctl00_mycontent_txtFirstName").focus();
                 return false;
      }
       if (document.getElementById("ctl00_mycontent_txtLastName").value=="")
      {
                 alert("Please enter your Last Name ");
                 document.getElementById("ctl00_mycontent_txtLastName").focus();
                 return false;
      }
      if (document.getElementById("ctl00_mycontent_txtMailingAdd").value=="")
      {
                 alert("Please enter your Mailing Address ");
                 document.getElementById("ctl00_mycontent_txtMailingAdd").focus();
                 return false;
      }     
       if (document.getElementById("ctl00_mycontent_txtCity").value=="")
      {
                 alert("Please enter your City");
                 document.getElementById("ctl00_mycontent_txtCity").focus();
                 return false;
      }
      if (document.getElementById("ctl00_mycontent_ddlState").value== 0 )
      {                 
                  alert("Please select your State");                  
                  return false
      }
      if(document.getElementById("ctl00_mycontent_txtZipCode").value=="")
      {
                
                 alert("Please enter your Zip Code");
                document.getElementById("ctl00_mycontent_txtZipCode").focus();
                return false;
      }
      var reZip =/(^\d{5}$)|(^\d{5}-\d{4}$)/;
            if (!reZip.test(document.getElementById("ctl00_mycontent_txtZipCode").value)) {
                 alert("Please enter a valid Zip Code.");
                  return false;
             }
       if(document.getElementById("ctl00_mycontent_txtEmailAdd").value=="")
      {
                 alert("Please enter your Email Address.");
                document.getElementById("ctl00_mycontent_txtEmailAdd").focus();
                return false;
      }
     var emailPat = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,3})$/;
     var emailid=document.getElementById("ctl00_mycontent_txtEmailAdd").value;
     var matchArray = emailid.match(emailPat);
     if (matchArray == null)
        {
               alert("Please enter a valid Email Address.");
               document.getElementById("ctl00_mycontent_txtEmailAdd").focus();
               return false;
        }
        if(document.getElementById('ctl00_mycontent_txtEnteredText').value=="")
      {
                 alert("Please enter validation text below.");
                document.getElementById("ctl00_mycontent_txtEnteredText").focus();
                return false;
      }
      return true;
    
    }
    