function r_on(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/" + i + "_over.gif"; 
    }
  }
}

function r_off(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/" + i + ".gif"; 
    }
  }
}
function en_r_on(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/en/" + i + "_over.gif"; 
    }
  }
}

function en_r_off(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/en/" + i + ".gif"; 
    }
  }
}

function p_on(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/en/products/home/p_" + i + "-over.gif"; 
      document["billboard"].src = "images/en/products/home/billboard-" + i + ".gif";
    }
  }
}

function p_off(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/en/products/home/p_" + i + ".gif"; 
      document["billboard"].src = "images/en/products/home/billboard.gif";
    }
  }
}

function s_on(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/en/products/" + i + "_over.gif"; 
    }
  }
}

function s_off(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/en/products/" + i + ".gif"; 
    }
  }
}

function createCookie(name,days) {
	if (days) {
		var expires = days;
	} else {
		var expires = "Mon, 31 Dec 2099 23:59:59 GMT";
	}
	document.cookie = name+"="+"yes"+expires+"; path=/";
}

function writeDate() {
  var today = new Date();
  var year = today.getFullYear();
  document.write(year);
}

function leaveSite(site) {
  if (confirm('You are now leaving this web site.\nIf you do not wish to leave this site, click Cancel. Click OK to leave.') == 1) {
    window.open(site, 'Untitled','toolbar=yes,width=750,height=500,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes')
  }
}

function leaveSite2(site) {
  if (confirm('Your existing outstanding orders will be removed, if you do want to keep your outstanding orders, click Cancel. Click OK to change your recurring order.') == 1) {
    window.open(site, 'Untitled','toolbar=yes,width=750,height=500,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes')
  }
}

function popUp(page) {
  popup_window = window.open(page,'popup','location,menubar,resizable,scrollbars=no,status,toolbar,width=500,height=300');
}

function popUpColleague(page) {
  popup_window = window.open(page,'popup','location,menubar,resizable,scrollbars=no,status,toolbar,width=500,height=450');
}

function popUpScrollbar(page) {
  popup_window = window.open(page,'popup','location,menubar,resizable,scrollbars=yes,status,toolbar,width=500,height=300');
}

function popUp2(page) {
  popup_window = window.open(page,'popup','location,menubar,resizable,scrollbars,status,toolbar,width=500,height=200');
}

function popupRss(url){
     windowRss = window.open(url, 'winRsspop', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=790,height=515');
}

function openFlashWindow(page) {
  popup_window = window.open(page,'popup','location,menubar,resizable,scrollbars,status,toolbar,width=550,height=458');
}

function openWin2(page) {
  popup_window = window.open(page,'popup','location,menubar,resizable,scrollbars,status,toolbar,width=300,height=315');
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function cqp(page) {
  popup_window = window.open(page,'popup','location,menubar,resizable,scrollbars,status,toolbar,width=700,height=550');
}

function jumpBackFromAnchor() {

      var thisUrl = new String();

      var thisUrl = document.location.hash;

      //alert(thisUrl);

      //alert(thisUrl.indexOf("#"));

      if (thisUrl.indexOf("#")) {

            goBack = -1;

      } else {

            goBack = -2;

      }

      //alert(goBack);

      history.go(goBack);

}

 

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 MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

   //MM_swapImage('imageName','','image/address',1);

}

 

function SwitchPDFPreviewTextColor(val)

{

     var div = document.getElementById('divLine1');

     var div2 = document.getElementById('divLine2');

     var div3 = document.getElementById('divLine3');

     

     div.style.color = val;

     div2.style.color = val;

     div3.style.color = val;

}

 

function SwitchPDFPreviewBackColor(val)

{

    var div = document.getElementById('divPDFPreview');

    div.style.backgroundColor = val;

}

 

function GetDefaultVal(val,defaultVal)

{

    if (val == null)

    {

        val = defaultVal;

    }    

    return val;

}

function GetField(id)
{
	return document.getElementById(id);
}

function SwitchText(aValues)

{

     aValues = GetValues(aValues);

     var line1 = document.getElementById('divLine1');

     var line2 = document.getElementById('divLine2');

     var line3 = document.getElementById('divLine3');

     

     var line1Format = new String("{title} {first} {last} {suffix}");

     var line2Format = new String("{address1}  &middot  {city}, {state} {zip}");

     var line2AltFormat = new String("{address1} {address2}   &middot  {city}, {state} {zip}");

     var line3Format = new String("{phone}  &middot  {fax}  &middot  {website}");

     var line3AltFormat = new String("{phone}  &middot  {webSite}");

     

     var title = GetDefaultVal(aValues[0],'Dr');

     var firstName = GetDefaultVal(aValues[1],'John');

     var lastName = GetDefaultVal(aValues[2],'Smith');

     var suffix = GetDefaultVal(aValues[3],'');

     var address1 = GetDefaultVal(aValues[4],'123 Street Address');

     var address2 = GetDefaultVal(aValues[5],'');

     var city = GetDefaultVal(aValues[6],'Pittsburgh');

     var state = GetDefaultVal(aValues[7],'PA');

     var zip1 = GetDefaultVal(aValues[8],'12345');

     var phone = GetDefaultVal(aValues[9],'123-456-7890');

     var fax = GetDefaultVal(aValues[10],'');

     var webSite = GetDefaultVal(aValues[11],'');

     var otherName = GetDefaultVal(aValues[12],'');
     
     var zip2 = '';

     

     if (otherName == '')

     {
        if(title.toString().length > 3)
            line1Format = line1Format.replace(/{title}/gi,'');
        else
            line1Format = line1Format.replace(/{title}/gi,title);

        line1Format = line1Format.replace(/{first}/gi,firstName);

        line1Format = line1Format.replace(/{last}/gi,lastName);

        line1Format = line1Format.replace(/{suffix}/gi,suffix);

        line1.innerHTML = line1Format;

     }

     else

     {

        line1.innerHTML = otherName;

     }

     

     if (address2 == '')

     {

        line2Format =  line2Format.replace(/{address1}/gi,address1);

        line2Format =  line2Format.replace(/{city}/gi,city);

        line2Format =  line2Format.replace(/{state}/gi,state);

        if (zip2 == '')

        {

            line2Format =  line2Format.replace(/{zip}/gi,zip1);

        }

        else

        {

            line2Format =  line2Format.replace(/{zip}/gi, zip1 + '-' + zip2);

        }

        line2.innerHTML = line2Format;

     }

     else

     {

        line2AltFormat =  line2AltFormat.replace(/{address1}/gi,address1);

        line2AltFormat =  line2AltFormat.replace(/{address2}/gi,address2);

        line2AltFormat =  line2AltFormat.replace(/{city}/gi,city);

        line2AltFormat =  line2AltFormat.replace(/{state}/gi,state);

        if (zip2 == '')

        {

            line2AltFormat =  line2AltFormat.replace(/{zip}/gi,zip1);

        }

        else

        {

            line2AltFormat =  line2AltFormat.replace(/{zip}/gi, zip1 + '-' + zip2);

        }

        line2.innerHTML = line2AltFormat;

     }

     

     if (fax == '')

     {

        line3AltFormat = line3AltFormat.replace(/{phone}/gi,phone);

        line3AltFormat = line3AltFormat.replace(/{website}/gi,webSite);

        line3.innerHTML = line3AltFormat;

     }

     else

     {

        line3Format = line3Format.replace(/{phone}/gi,phone);

        line3Format = line3Format.replace(/{fax}/gi,fax);

        line3Format = line3Format.replace(/{website}/gi,webSite);

        line3.innerHTML = line3Format;

     }

     

     //alert(line1.innerHTML);

    

}

 

function GetValues(aControlIds)

{

 

    //string js = string.Format("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}'"

            //, this.cboTitle.ClientID,this.txtFirstName.ClientID,this.txtLastName.ClientID,

            //this.txtSuffix.ClientID,this.txtAddress1.ClientID,this.txtAddress2.ClientID,this.txtCity.ClientID,

            //this.cboState.ClientID,this.txtZipCode1.ClientID,this.txtZipCode2.ClientID,this.txtPhone.ClientID,

            //this.txtFax.ClientID,this.txtWebSite.ClientID,this.txtOtherName.ClientID);

            

            

    var aValues = new Array();

    

    //title

    var val = document.getElementById(aControlIds[0]);

    aValues[0] = val.options[val.selectedIndex].text;

    

    //first

    val =  document.getElementById(aControlIds[1]);

    aValues[1] = val.value;

    

    //last

    val =  document.getElementById(aControlIds[2]);

    aValues[2] = val.value;

    

    //suffix

    val =  document.getElementById(aControlIds[3]);

    aValues[3] = val.value;

    

    //address1

    val =  document.getElementById(aControlIds[4]);

    aValues[4] = val.value;

    

    //address2

    val =  document.getElementById(aControlIds[5]);

    aValues[5] = val.value;

    

    //city

    val =  document.getElementById(aControlIds[6]);

    aValues[6] = val.value;

    

    //state

    val =  document.getElementById(aControlIds[7]);

    aValues[7] = val.options[val.selectedIndex].text;

    

    //zip1

    val =  document.getElementById(aControlIds[8]);

    aValues[8] = val.value;

    

    //phone

    val =  document.getElementById(aControlIds[9]);

    aValues[9] = val.value;

    

    //fax

    val =  document.getElementById(aControlIds[10]);

    aValues[10] = val.value;

    

    //website

    val =  document.getElementById(aControlIds[11]);

    aValues[11] = val.value;

    

    //other name

    val =  document.getElementById(aControlIds[12]);

    aValues[12] = val.value;
    

    return aValues;

}
