var GSection = "";
function toggleSection(section)
{
	//alert(section + " section");
	GSection = section;
}

function getPrinterURL(val)
{
	var ret = "";
	if(val=="about01") ret = "print-about-restylane.html";
	if(val=="about02") ret = "print-about-restylane-work.html";
	if(val=="about03") ret = "print-about-restylane-used.html";
	if(val=="about04") ret = "print-about-restylane-do.html";
	if(val=="about05") ret = "print-about-restylane-safe.html";

	if(val=="getstarted01") ret = "print-get-started.html";
	if(val=="getstarted02") ret = "print-get-started1.html";
	if(val=="getstarted03") ret = "print-get-started2.html";
	if(val=="getstarted04") ret = "print-get-started3.html";
	if(val=="getstarted05") ret = "print-get-started4.html";

	return ret;
}

function clearField()
{
	//pass as many fields as you need
	for(var i=0; i<arguments.length; i++){
		arguments[i].value = "";
	}
}

function openPrintPage(url)
{
	if(GSection!=""){
		url2 = getPrinterURL(GSection);
		if(url2!="")
			popWindow('print/'+url2,'PrinterFriendly','612','500');
		else
			popWindow(url,'PrinterFriendly','612','500');
		
	} else {
		popWindow(url,'PrinterFriendly','612','500');
	}
}


function printPage(){
  if (window.print){
	window.print();
  } else {
	alertPrint();
	//setTimeout("goToURL();", 3000);
  }
}

function m_showHide(lyrId, prop, xoff, yoff) {
	var lyrObj = (d.layers)?d[lyrId]:d.all?d.all[lyrId].style:d.getElementById(lyrId).style;
	lyrObj.left = xcoord-xoff+"px";
	lyrObj.top = ycoord+yoff+"px";
	lyrObj.display = prop;
}

function m_showHideDiv(a) {
	if(d.getElementById(a).style.display=='block')
		m_hideDiv(a);
	else
		m_showDiv(a);
}

function m_showDiv(a) {
	d.getElementById(a).style.display='block';
}

function m_hideDiv(a) {
	d.getElementById(a).style.display='none';
}

function m_toggleLyr(lyrID,lyrState) // 1 visible, 0 hidden
{

  if(lyrID=='doctorlyr'){
	if(document.getElementById('state')) m_toggleLyrReal('state',(lyrState==0?1:0));
	//if(document.getElementById('radius')) m_toggleLyrReal('radius',(lyrState==0?1:0));
  }
  m_toggleLyrReal(lyrID,lyrState);
}

function trackdoctorclick()
{
	//alert('in here');
     var click1 = new Image();
     var axel = Math.random()+"";
     var a = axel * 10000000000000;
     click1.src = 'http://ad.doubleclick.net/activity;src=2028991;type=searc250;cat=finda121;ord='+ a + '?' ;
}

function m_toggleLyrReal(lyrID,lyrState){
   var obj = document.layers ? document.layers[lyrID] :
   document.getElementById ?  document.getElementById(lyrID).style :
   document.all[lyrID].style;
   obj.visibility = document.layers ? (lyrState ? "show" : "hide") :
   (lyrState ? "visible" : "hidden");

   //track opening of dr layer
   if(lyrID=='doctorlyr' && lyrState==1){
	trackdoctorclick();
   }
}

function m_toggleAllOff()
{
	var q = 1;
	while (q <= 14)
	{
		document.getElementById("q" + q).style.visibility='hidden';
		q++;
	}

	m_toggleLyr('horizontal1',1);
	m_toggleLyr('horizontal2',1);
}


function dhtml_createDIVElement(newid,html){
	var newDiv = document.createElement("DIV");
	newDiv.id  = newid;
	document.body.appendChild(newDiv);
	newDiv.innerHTML = html;
}

function dhtml_removeDIVElement(id){
        var d = document.getElementById(id);
	d.parentNode.removeChild(d);
}

function so_testFlashVersion(reqver){
	if(disableFlash) return false; //for testing purposes only

	var version = deconcept.SWFObjectUtil.getPlayerVersion();
	var versionOK = false;
	if (document.getElementById && version["major"] >= reqver) {
		versionOK = true;
	}
	return versionOK;
}

function m_getpos(el) {
	//alert("page being resized" + obj);
    var left = el.offsetLeft;
    var top = el.offsetTop;
    if ( el.offsetParent && el.offsetParent.clientLeft || el.offsetParent.clientTop ) {
        left += el.offsetParent.clientLeft;
        top += el.offsetParent.clientTop;
    }
    while ( el = el.offsetParent ) {
        left += el.offsetLeft;
        top += el.offsetTop;
    }
    return { x:left, y:top };
}

function m_overlapDiv(el,elto, xadj, yadj){ //this function overlaps div(el) over div(elto) then adjusts by x/y

	var d = document.getElementById(elto);
	var pos = m_getpos(d);

	var x = (pos.x + xadj);
	var y = (pos.y + yadj);

		//alert('x='+x+', y='+y);

	document.getElementById(el).style.left = x+"px";
	document.getElementById(el).style.top = y+"px";
}



/*Popup Functions for Printer Friendly Pages*/

oHTMLWin = null;

function centerWindow(url, name, w, h, scroll, menu, resizable, all)
{
	if (window.screen)
	{
		var chasm = screen.availWidth;
		var mount = screen.availHeight;
		var allprops = "";

	      if(all=="1") allprops = ",directories=yes,location=yes,status=yes,toolbar=yes";

		winprops = 'width=' + w + ',height=' + h + ',left=' + ((chasm - w - 10) * .5) + ',top=' + ((mount - h - 30) * .5) + ',scrollbars=' + scroll + ',menubar=' + menu + ',resizable=' + resizable + allprops;
		
		oHTMLWin = window.open(url, name, winprops);
		oHTMLWin.window.focus();
	}
}

function popWindowMenus(url,title,width,height){
		centerWindow(url, title, width, height, "yes", "yes", "yes", "1");
}

function popWindow(url,title,width,height){
		centerWindow(url, title, width, height, "yes", "no", "no", "0");
}

function popWindowResizeable(url,title,width,height){
		centerWindow(url, title, width, height, "yes", "no", "yes", "0");
}

function popWindowNoScroll(url,title,width,height){
		centerWindow(url, title, width, height, "no", "no", "no", "0");
}

function popWindowNoScrollResizeable(url,title,width,height){
		centerWindow(url, title, width, height, "no", "no", "yes", "0");
}

