// JavaScript Document

// script for shadow
//alert('====>'+window.root+'<====');

var ua = navigator.userAgent.toLowerCase(); 
this.ua= ua;
this.isIE        = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ); 
this.versionMinor = parseFloat(navigator.appVersion); 
document.write ("<style>")
document.write ("#linkHolder {position:relative; margin:0 auto 0 auto; width:771px; height:1px;}")
if (this.isIE && this.versionMinor >= 4) {
    document.write ("#SAlink {position:relative; width:225px; height:40px; left:-175px; top:-25px; cursor:pointer;}") 
    document.write ("#sanofiLeft {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+window.root+"images/sanofiTop_left.png',sizingMethod='scale'); height:29px; position:relative; top:35px  }")
    document.write ("#sanofiLogo {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+window.root+"images/sanofiTop.png',sizingMethod='scale');  width:771px; height:59px; position:relative; top:35px;}")
    document.write ("#sanofiRight {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+window.root+"images/sanofiTop_right.png',sizingMethod='scale'); height:29px; position:relative; top:35px  }")
}	
else
{
    document.write ("#SAlink {position:relative; width:225px; height:40px; left:75px; top:-25px; cursor:pointer;}") 
    document.write ("#sanofiLeft { background-image:url("+window.root+"images/sanofiTop_left.png); height:29px; background-repeat:repeat-x; position:relative; top:35px}")
    document.write ("#sanofiLogo { background-image:url("+window.root+"images/sanofiTop.png); background-repeat:no-repeat; width:771px; height:59px; position:relative; top:35px; margin-left:auto; margin-right:auto}")
    document.write ("#sanofiRight { background-image:url("+window.root+"images/sanofiTop_right.png); height:29px; background-repeat:repeat-x; position:relative; top:35px}")
}	
document.write ("</style>")

// ------------------------------

function openWin( windowURL, windowName, windowFeatures) {
     window.open( windowURL, windowName, windowFeatures ) ;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_findObj(n, d) 
{	//v4.0
  	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 && document.getElementById) x=document.getElementById(n); return x;
}
function showISI() {
	MM_showHideLayers('divFlash','','show')
 	window.document.aravaScroller_Consumer.Play();
}

function confirmExternalLink()
{
	return confirm('You are about to visit a Web site that is not managed by Sanofi-Synthelabo Inc.\nThis link is provided for information purposes only. Sanofi-Synthelabo Inc. is not\nresponsible and disclaims any liability for the contents, links, viruses, or similar\nharmful programs that might be present on any external sites and pages provided\nby this link. Linking to any other page or site is at your own risk.');
}

function exitSite(destination)
{
	openWin(window.root + 'exitsite.aspx?url=' + destination ,'pop_up','width=500,height=530,scrollbars=auto');
}
function interstitial(destination)
{
	openWin(window.root + 'interstitial.aspx?url=' + destination ,'pop_up','width=500,height=375,scrollbars=auto');
}
function confirmHCP()
{
	//openWin('/confirm_professional.aspx?url=' + destination ,'pop_up','width=500,height=450,scrollbars=auto');
	var bln = confirm('This information is intended for U.S. Healthcare Professionals. If you are a Healthcare Professional, click OK to continue. ');

	if (bln)
	{
		window.location.href = window.root + 'hcp/default.aspx';
	}	

}

function BMI()
{
	openWin(window.root + 'apidra_success_stories_tips_tools/Bmi_Calculator.aspx','pop_up','width=550,height=350,scrollbars=auto');
}

function validateAge(source, args) {
    var yearObj = document.getElementById('ctl00_ContentPlaceHolder1_UserDateOfBirthYear');
    
    if(yearObj.selectedIndex == 0) {
        args.IsValid = true;
        return;
    }
    
    var now = new Date();
    var dif = eval (now.getFullYear() + "-" + yearObj.options[yearObj.selectedIndex].value);
    args.IsValid = dif > 17;
}

function validateBirthDate(source, args) {
    var year = document.getElementById('ctl00_ContentPlaceHolder1_UserDateOfBirthYear');
    var month = document.getElementById('ctl00_ContentPlaceHolder1_UserDateOfBirthMonth');
    var day = document.getElementById('ctl00_ContentPlaceHolder1_UserDateOfBirthDay');
    
    if(year.selectedIndex == 0 || month.selectedIndex == 0 || day.selectedIndex == 0) {
        args.IsValid = true;
        return;
    }
    
    var myDate = new Date();
    myDate.setFullYear(year.options[year.selectedIndex].value,month.options[month.selectedIndex-1].value,day.options[day.selectedIndex].value);
    args.IsValid = (myDate.getMonth() == month.options[month.selectedIndex-1].value)
}

function checkMaxLength(obj,length) 
{
    var objLength = document.getElementById('ctl00_ContentPlaceHolder1_'+obj).value.length;
    if (eval(objLength+1) > length)
        window.alert("You have entered " + eval(objLength + 1) + " character(s).\nValid entries are between 4 and " + length + " character(s) for password.");
}
//search stuff
function validateSearchForm(control_id)
{
    var valid = true;
  
    if (document.getElementById(control_id).value.length == 0 ) {
 	    window.alert ("Please enter a search text.");
  		valid = false;
 	}
 	else
 	{
 	    var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
 		for (var i = 0; i < document.getElementById(control_id).value.length; i++) {
  		    if (iChars.indexOf(document.getElementById(control_id).value.charAt(i)) != -1) {
  			    window.alert ("Your search text has special characters. \nThese are not allowed.\nPlease remove them and try again.");
  			    valid = false;
  			    break;
  	        }
        }
     }
     return valid;
}

function submitSearchForm(section)
{
   var control_id = 'ctl00_Top_SearchText';
   if  (section ==  'hcp')
        control_id = 'ctl00_Search_SearchText'
   
    if (validateSearchForm(control_id)) {
        if (section == 'hcp') {
            window.location=window.root + 'hcp/search_results.aspx?q=' + document.getElementById(control_id).value;
        }
        else
            window.location=window.root + 'search_results.aspx?q=' + document.getElementById(control_id).value;
    }
    return false;
}

function validateRebateAge(source, args) {
    var objY = document.getElementById('ctl00_ContentPlaceHolder1_Y');
    args.IsValid = objY.checked;
}





