// *****************************************************************************
// 	Dear Doctor Digital Library DHTML Widget v1.1
//	Developed for DearDoctor Inc. by Advanced Media Productions Inc.
//	Lead Developer: Javier Lerones Gallego javier@advmediaproductions.com
// *****************************************************************************


// Public Variables
DearDoctorWidget.prototype.Horizontal;
DearDoctorWidget.prototype.ShowMainContent;
DearDoctorWidget.prototype.HeaderBackground;
DearDoctorWidget.prototype.HeaderLabelColor;
DearDoctorWidget.prototype.NumberOfCovers;

// If Vertical and No ShowMainContent
DearDoctorWidget.prototype.Width;
DearDoctorWidget.prototype.BorderColor;
DearDoctorWidget.prototype.ButtonText;
DearDoctorWidget.prototype.TitleText;

// Encrypted dentist id
DearDoctorWidget.prototype.DentistID;



// Location of the XML files with the links to the covers and featured pages
//var CoversFile = "http://www.deardoctor.com/library/widget/ddcovers.xml";
//var FeaturedFile = "http://www.deardoctor.com/library/widget/ddfeatured.xml";
var PublicImgFolder = "http://www.deardoctor.com/library/widget/";



// Constructors
function DearDoctorWidget() {
	// Start the object with the default configuration:
	//  Horizontal, show main content, background = 069, 468x150
	this.Horizontal = true;
	this.ShowMaincontent = true;
	this.HeaderBackground = "#069";
	this.HeaderLabelColor = "#FFF";
	this.NumberOfCovers = 3;
	this.Width = -1;
	this.BorderColor = "#000";
	this.ButtonText = "Search";
	this.TitleText = "Find Dental Information";
	this.DentistID = "";
}



// Public Methods

// This method makes sure the user didn't changed any of the numeric/boolean parameters to strings.
DearDoctorWidget.prototype.checkParams = function() {
	//if(!Boolean.parse(this.Horizontal)) {this.Horizontal = true;}	
	//if(!Boolean.parse(this.ShowMaincontent)) {this.ShowMaincontent = true;}	
	if(!parseInt(this.NumberOfCovers)) {this.NumberOfCovers = 3;} else { if(this.NumberOfCovers < 1) this.NumberOfCovers = 1; }
	if(!parseInt(this.Width)) {this.Width = -1;} else {if(this.Width < 200) this.Width = 200;}
}


/// This method renders the code for the widget using document.write
DearDoctorWidget.prototype.show = function() {
	// First of all, parse the params, make sure numbers are numbers.
	this.checkParams();
	
	// The common code strings 
	var jq = '<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>';
	var enc = '<script type="text/javascript" src="encdec.js"></script>';
	
	var popup = '<script language="javascript">function ddpopup(url){var win_w, win_h;win_w = screen.availWidth; win_h = screen.availHeight; myWindow = window.open(url, "", "top=1, left=1, width=" + win_w + ", height=" + win_h + ", toolbar=no,location=no,location=0, directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");if (!myWindow.opener) myWindow.opener = self;}</script>';
	
	var se = 'function s() { if(document.getElementById("wSearchBox").value !== "Search Dental Terms") { var url = "http://www.deardoctor.com/library/' + this.DentistID + '/?process=search&data=" + document.getElementById("wSearchBox").value; ddpopup(url);  } }';

	var cv = 'var covers = [];'
	cv += 'covers[0] = "http://www.deardoctor.com/library/images/deardoctor-cover10.jpg";';
	cv += 'covers[1] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue10";';
	cv += 'covers[2] = "http://www.deardoctor.com/library/images/deardoctor-cover9.jpg";';
	cv += 'covers[3] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue9";';
	cv += 'covers[4] = "http://www.deardoctor.com/library/images/tim-conway-dear-doctor.jpg";';
	cv += 'covers[5] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue8";';
	cv += 'covers[6] = "http://www.deardoctor.com/library/images/christie-brinkley-magazine.jpg";';
	cv += 'covers[7] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue7";';
	cv += 'covers[8] = "http://www.deardoctor.com/library/images/mario-lopez-dear-doctor.jpg";';
	cv += 'covers[9] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue6";';
	cv += 'covers[10] = "http://www.deardoctor.com/library/images/jessica-simpson-dear-doctor.jpg";';
	cv += 'covers[11] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue5";';
	cv += 'covers[12] = "http://www.deardoctor.com/library/images/carrie-underwood-magazine.jpg";';
	cv += 'covers[13] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue4";';
	cv += 'covers[14] = "http://www.deardoctor.com/library/images/sheryl-crow-dear-doctor.jpg";';
	cv += 'covers[15] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue3";';
	cv += 'covers[16] = "http://www.deardoctor.com/library/images/dear-doctor-magazine-2.jpg";';
	cv += 'covers[17] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue2";';
	cv += 'covers[18] = "http://www.deardoctor.com/library/images/dear-doctor-magazine-1.jpg";';
	cv += 'covers[19] = "http://www.deardoctor.com/library/' + this.DentistID + '/?&issue=issue1";';
			
	var ft = 'var featured = [];';
	ft += 'featured[0] = "http://www.deardoctor.com/library/images/abcnews-dear-doctor.gif";';
	ft += 'featured[1] = "http://www.deardoctor.com/press/";';
	ft += 'featured[2] = "http://www.deardoctor.com/library/images/good-morning-america.gif";';
	ft += 'featured[3] = "http://www.deardoctor.com/press/";';
	ft += 'featured[4] = "http://www.deardoctor.com/library/images/usatoday-dear-doctor.gif";';
	ft += 'featured[5] = "http://www.deardoctor.com/press/";';
	ft += 'featured[6] = "http://www.deardoctor.com/library/images/msnbc-dear-doctor.gif";';
	ft += 'featured[7] = "http://www.deardoctor.com/press/";';
	ft += 'featured[8] = "http://www.deardoctor.com/library/images/glamour-dear-doctor.gif";';
	ft += 'featured[9] = "http://www.deardoctor.com/press/";';
	
	// IMPORTANT VARIABLE, TELLS DE WIDGET HOW MANY FEATURED IMAGES ARE INCLUDED
	var featuredCount = 5;

	// The width of the magazine images in pixels
	var mWidth = 95;

	// Is it horizontal or vertical?
	if(this.Horizontal)
	{
		if(this.ShowMainContent)
		{
			// calculate the width available for the magazines:
			var Width = (this.NumberOfCovers * mWidth) + 160;
			var Height = 140;
			
			var availWidth = Width - 160;
			var pixelsPerPage = (this.NumberOfCovers * mWidth);

			document.write('<LINK REL=StyleSheet HREF="' + PublicImgFolder + 'ddwstyles.css" TYPE="text/css" MEDIA=screen>');

			document.write(jq);
			document.write(enc);
			document.write(popup);
			
			document.write('<script language="javascript" type="text/javascript">');	

			document.write('var sL = 0; var pN = 0; var tC = 0; var pS = ' + pixelsPerPage + '; var fsel = 0;');	
			
			document.write(cv);
			document.write(ft);
						
			document.write('function ddrot() {');
			document.write('	if(fsel < ' + (featuredCount - 1) + ') {');
			document.write('		fsel += 1;');
			document.write('		f(fsel);');
			document.write('	}');
			document.write('	else {');
			document.write('		fsel = 0;');
			document.write('		f(fsel);');
			document.write('	}');
			document.write('	setTimeout(\'ddrot();\', 5000);');
			document.write('}');
			
			document.write('function checkEnter(e){ if(e && e.which){ e = e; characterCode = e.which; } else{ e = event; characterCode = e.keyCode; } if(characterCode == 13){ s(); return false; } else{ return true; }  } ');
			
			document.write('function loaddd() { setTimeout("rxc();rxf();",1000); setTimeout("ddrot();",5000);}');
			document.write('function rxc() {');
			document.write('	for(var i = 0; i < covers.length; i+=2)');
			document.write('	{');
			document.write('		document.getElementById(\'wMain_H_cfull\').innerHTML += \'<div class="wMain_H_mag"><a href="javascript:void(0);" onclick="javascript:ddpopup(\\\'\' + covers[i+1] + \'\\\');" ><img src="\' + covers[i] + \'" style="border: none;" /></a></div>\';');
			document.write('		tC += 1;}');
			document.write('		pN = Math.ceil((tC * '+mWidth+') / pS);} 	');
			document.write('function rxf() {');
			document.write('	for(var i = 0; i < featured.length; i+=2)');
			document.write('	{');
			document.write('		if(i == 0)');
			document.write('			document.getElementById(\'wMain_List\').innerHTML += \'<div id="wMain_H_F\' + (i / 2) + \'"><a href="\' + featured[i+1] + \'" target="_blank"><img src="\' + featured[i] + \'" style="border: none; width: 100px; height: 80px;" /></a></div>\';');
			document.write('		else');
			document.write('			document.getElementById(\'wMain_List\').innerHTML += \'<div id="wMain_H_F\' + (i / 2) + \'" style="display: none;"><a href="\' + featured[i+1] + \'" target="_blank"><img src="\' + featured[i] + \'" style="border: none; width: 100px; height: 80px;" /></a></div>\';');
			document.write('	}');
			document.write('} 	');


			document.write('function sLeft() {');	
			document.write('	if(sL < 0){');	
			document.write('		sL += pS;');	
			document.write('		$("#wMain_H_cfull").animate({left: sL + "px"}, 500);');	
			document.write('	}');	
			document.write('}');	
			document.write('function sRight() {');	
			document.write('	if(sL > -((pN - 1) * pS)){');	
			document.write('		sL -= pS;');	
			document.write('		$("#wMain_H_cfull").animate({left: sL + "px"}, 500);');	
			document.write('	}');	
			document.write('}');	
			document.write('var fID = "0";');				
			document.write('function f(id) {');	
			document.write('	if(id != "prev" && id != "next") {');	
			document.write('		$("#wMain_H_F" + fID).fadeOut("fast", function() {$("#wMain_H_F" + id).fadeIn("fast");});	');	
			document.write('		$("#fi" + id).attr("class","wMain_H_ces");	');
			document.write('		$("#fi" + fID).attr("class","wMain_H_ce");	');
			document.write('		fID = id; fsel = parseInt(id);');	
			document.write('	}');	
			document.write('	else {');	
			document.write('		if(id == "prev" && parseInt(fID) > 0) {');	
			document.write('			nID = parseInt(fID) - 1;');	
			document.write('			$("#wMain_H_F" + fID).fadeOut("fast", function() {$("#wMain_H_F" + nID).fadeIn("fast");});	');	
			document.write('			$("#fi" + nID).attr("class","wMain_H_ces");	');
			document.write('			$("#fi" + fID).attr("class","wMain_H_ce");	');
			document.write('			fID = nID; fsel = parseInt(nID);');	
			document.write('		} else if(id == "next" && parseInt(fID) < '+(featuredCount - 1)+') {');	
			document.write('			nID = parseInt(fID) + 1;');	
			document.write('			$("#wMain_H_F" + fID).fadeOut("fast", function() {$("#wMain_H_F" + nID).fadeIn("fast");});	');	
			document.write('			$("#fi" + nID).attr("class","wMain_H_ces");	');
			document.write('			$("#fi" + fID).attr("class","wMain_H_ce");	');
			document.write('			fID = nID; fsel = parseInt(nID);');	
			document.write('		}');	
			document.write('	}');	
			document.write('}');	
			document.write('function fc() {');	
			document.write('	if($("#wSearchBox").attr("value") == "Search Dental Terms") {');	
			document.write('		$("#wSearchBox").attr("value","");');	
			document.write('		$("#wSearchBox").attr("class","wSearch_Box_Act");');	
			document.write('	}');	
			document.write('}');	
			document.write('function bl() {');	
			document.write('	if($("#wSearchBox").attr("value") == "") {');	
			document.write('		$("#wSearchBox").attr("class","wSearch_Box_InAct");');	
			document.write('		$("#wSearchBox").attr("value","Search Dental Terms");');	
			document.write('	}');	
			document.write('}');	
			document.write(se);	
						
			document.write('</script>');
			
			document.write('<style type="text/css">');
			document.write('	.b { clear: both; font-size: 1px; }');
			document.write('	#wContainer_H { width: ' + (Width + 14) + 'px; height: ' + (Height + 70) + 'px; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 12px; }');
			document.write('	#wSearch_H { -moz-border-radius-topleft: 11px;-moz-border-radius-topright: 11px; -webkit-border-top-left-radius: 11px;-webkit-border-top-right-radius: 11px; background-color: ' + this.HeaderBackground + '; border: solid 1px ' + this.BorderColor + '; color: ' + this.HeaderLabelColor + '; text-align:center; width: ' + (Width - 10) + 'px;  padding: 0px 10px 0px 10px; }');
			document.write('	#wSearch_Title { font-size: 14px; font-weight: bold; line-height: 31px;  }');
			document.write('	#wSearch_TBox {   }');
			document.write('	#wSearch_Search {  }');
			document.write('	#wSearchBox { font-size: 12px; padding: 1px 3px 1px 3px; width: 150px; }');
			document.write('	#wSearchBtn { font-size: 12px; }');
			document.write('	.wSearch_Box_Act { color: #333333; }');
			document.write('	.wSearch_Box_InAct { color: #999999; }	');
			document.write('	#wMain_H { -moz-border-radius-bottomleft: 11px;-moz-border-radius-bottomright: 11px;-webkit-border-bottom-left-radius: 11px;-webkit-border-bottom-right-radius: 11px; width: ' + (Width + 10) + 'px; height: 151px; background: #fff url("'+PublicImgFolder+'cs_grad_slider.gif") top center repeat-x; border: solid 1px #ccc; border-top: none; }');
			document.write('	#wMain_H_la { background: url("' + PublicImgFolder + 'dd_left.bmp") 0px center no-repeat; cursor: pointer; float: left; width: 14px; height: 130px; margin: 10px 1px 0px 4px;   }');
			document.write('	#wMain_H_cc { float: left; width: ' + (Width - 161) + 'px; height: 131px; overflow: hidden; position: relative; padding: 15px 0px 5px 0px;  }	');
			document.write('	#wMain_H_cfull { width: 10000px; height: 136px; position: absolute; }');
			document.write('	.wMain_H_mag { float: left; width: 91px; height: 115px; margin: 0px 2px 0px 2px; }');
			document.write('	#wMain_H_ra { background: url("'+PublicImgFolder+'dd_right.bmp") 0px center no-repeat;cursor: pointer; float: left; width: 14px; height: 130px; margin: 10px 1px 0px 1px;  }');
			document.write('	#wMain_H_sep { float: left; height: 151px; margin: 0px 3px 0px 3px; background-color: #ccc; width: 1px;}');
			document.write('	#wMain_H_Feat { float: left; height: 136px; width: 125px; padding: 10px 0px 5px 0px; text-align:center; }');
			document.write('	.wMain_H_le {float: left; margin: 0px 1px 0px 1px; width: 10px; height: 12px; background: url("'+PublicImgFolder+'dd_f_left.bmp") 0px center no-repeat;cursor: pointer;} ');
			document.write('	.wMain_H_re {float: left; margin: 0px 1px 0px 1px; width: 10px; height: 12px; background: url("'+PublicImgFolder+'dd_f_right.bmp") 0px center no-repeat;cursor: pointer;} ');
			document.write('	.wMain_H_ce {float: left; margin: 0px 1px 0px 1px; width: 10px; height: 12px; background: url("'+PublicImgFolder+'dd_f_center.bmp") 0px center no-repeat;cursor: pointer;} ');
			document.write('	.wMain_H_ces {float: left; margin: 0px 1px 0px 1px; width: 10px; height: 12px; background: url("'+PublicImgFolder+'dd_f_center_selected.bmp") 0px center no-repeat;cursor: pointer;} ');
			document.write('	.blink { color: #999; font-size: 10px; text-decoration: none; } .blink:hover { color: #999; text-decoration: underline; } .blink:visited { color: #999;  } ');
			document.write('</style>');
			
			document.write('<div id="wContainer_H">');
			document.write('	<div id="wSearch_H">');
			document.write('    	<span id="wSearch_Title">' + this.TitleText + ':&nbsp;</span>');
			document.write('        <span id="wSearch_TBox"><input class="wSearch_Box_InAct" type="text" id="wSearchBox" value="Search Dental Terms" onblur="bl()" onfocus="fc()" onKeyPress="checkEnter(event)"/></span>&nbsp;');
			document.write('        <span id="wSearch_Search"><input type="button" id="wSearchBtn" value="' + this.ButtonText + '" onclick="s();"/></span>&nbsp;');
			document.write('    </div>');
			document.write('    <div id="wMain_H">');
			document.write('    	<div id="wMain_H_la" onclick="sLeft();"></div>');
			document.write('    	<div id="wMain_H_cc">');
			document.write('        	<div id="wMain_H_cfull">');
			document.write('            </div>');
			document.write('        </div>');     
			document.write('    	<div id="wMain_H_ra" onclick="sRight();"></div>');
			document.write('        <div id="wMain_H_sep"></div>');
			document.write('        <div id="wMain_H_Feat">');
			document.write('        	<div style="font-size: 13px; text-align: center; margin-bottom: 4px;"><strong>As Featured on:</strong></div>');
			document.write('        		<div id="wMain_List">');
			document.write('        		</div>');
			document.write('            <div style="width: ' + (featuredCount * 18) + 'px; margin: 10px auto 0px auto;">');
			document.write('            	<div class="wMain_H_le" onclick="f(\'prev\');"></div>');	
			
			for(var fti = 0; fti < featuredCount; fti += 1)
			{
				if(fti === 0) {
					document.write('<div id="fi' + fti + '" class="wMain_H_ces" onclick="f(\'' + fti + '\');"></div>');
				}
				else {					
					document.write('<div id="fi' + fti + '" class="wMain_H_ce" onclick="f(\'' + fti + '\');"></div>');
				}
			}
			
			document.write('<div class="wMain_H_re" onclick="f(\'next\');"></div><div class="b"></div>');			
			document.write('            </div>');
			document.write('        </div>');
			document.write('    </div>');
			document.write('	<div style="margin-top: 5px; height: 10px; color: #999; font-size: 10px; text-align:center;">Powered by <a class="blink" target="_blank" href="http://www.deardoctor.com">Dear Doctor Magazine</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="blink" target="_blank" href="http://www.deardoctor.com/subscribe">Subscribe</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="blink" target="_blank" href="http://www.deardoctor.com/makeover">Win a Dental Makeover</a></div>');
			document.write('</div>');	
			
			document.write('<script language="javascript">loaddd();</script>');
		}
		else
		{
			// Only search box
			var Width = this.Width;
			var Height = 31;
			
			document.write(jq);
			document.write(enc);
			document.write(popup);

			document.write('<LINK REL=StyleSheet HREF="' + PublicImgFolder + 'ddwstyles.css" TYPE="text/css" MEDIA=screen>');
			
			document.write('<script language="javascript" type="text/javascript">');	
			document.write('function fc() {');	
			document.write('	if($("#wSearchBox").attr("value") == "Search Dental Terms") {');	
			document.write('		$("#wSearchBox").attr("value","");');	
			document.write('		$("#wSearchBox").attr("class","wSearch_Box_Act");');	
			document.write('	}');	
			document.write('}');	
			document.write('function bl() {');	
			document.write('	if($("#wSearchBox").attr("value") == "") {');	
			document.write('		$("#wSearchBox").attr("class","wSearch_Box_InAct");');	
			document.write('		$("#wSearchBox").attr("value","Search Dental Terms");');	
			document.write('	}');	
			document.write('}');	
			document.write(se);	
			document.write('function checkEnter(e){ if(e && e.which){ e = e; characterCode = e.which; } else{ e = event; characterCode = e.keyCode; } if(characterCode == 13){ s(); return false; } else{ return true; }  } ');
			document.write('</script>');
			
			document.write('<style type="text/css">');
			document.write('	.b { clear: both; font-size: 1px; }');
			document.write('	#wContainer_H { width: ' + Width + 'px; height: ' + (Height + 20) + 'px; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 12px; }');
			document.write('	#wSearch_H { -moz-border-radius: 11px; -webkit-border-radius: 11px; background-color: ' + this.HeaderBackground + ';border: solid 1px ' + this.BorderColor + '; color: ' + this.HeaderLabelColor + '; text-align:center; width: ' + (Width - 20) + 'px; padding: 0px 10px 0px 10px; }');
			document.write('	#wSearch_Title { font-size: 14px; font-weight: bold; line-height: 31px;  }');
			document.write('	#wSearch_TBox {  }');
			document.write('	#wSearch_Search {  }');
			document.write('	#wSearchBox { font-size: 12px; padding: 1px 3px 1px 3px; width: 150px; }');
			document.write('	#wSearchBtn { font-size: 12px; }');
			document.write('	.wSearch_Box_Act { color: #333333; }');
			document.write('	.wSearch_Box_InAct { color: #999999; }	');
			document.write('	.blink { color: #999; font-size: 10px; text-decoration: none; } .blink:hover { color: #999; text-decoration: underline; } .blink:visited { color: #999;  } ');
			document.write('</style>');
			
			document.write('<div id="wContainer_H">');
			document.write('	<div id="wSearch_H">');
			document.write('    	<span id="wSearch_Title">' + this.TitleText + ':&nbsp;</span>');
			document.write('        <span id="wSearch_TBox"><input class="wSearch_Box_InAct" type="text" id="wSearchBox" value="Search Dental Terms" onblur="bl()" onfocus="fc()" onKeyPress="checkEnter(event)" /></span>&nbsp;');
			document.write('        <span id="wSearch_Search"><input type="button" id="wSearchBtn" value="' + this.ButtonText + '" onclick="s();"/></span>&nbsp;');
			document.write('    </div>');
			document.write('	<div style="height: 10px; color: #999; font-size: 10px; text-align:center;">Powered by <a class="blink" target="_blank" href="http://www.deardoctor.com">Dear Doctor Magazine</a></div>');
			document.write('</div>');						
		}		
		
	}
	else
	{
		// Vertical Layout
		if(this.ShowMainContent)
		{
			// With Main Content
			
			// calculate the width available for the magazines:
			var Width = (1 * mWidth) + 69;
			var Height = 430;
			
			var availWidth = Width - 40;
			var pixelsPerPage = (1 * mWidth);

			document.write(jq);
			document.write(enc);
			document.write(popup);

			document.write('<LINK REL=StyleSheet HREF="' + PublicImgFolder + 'ddwstyles.css" TYPE="text/css" MEDIA=screen>');
			
			document.write('<script language="javascript" type="text/javascript">');	

			document.write('var sL = 0; var pN = 0; var tC = 0; var pS = ' + pixelsPerPage + '; var fsel = 0;');	

			document.write(cv);
			document.write(ft);
 
 			document.write('function checkEnter(e){ if(e && e.which){ e = e; characterCode = e.which; } else{ e = event; characterCode = e.keyCode; } if(characterCode == 13){ s(); return false; } else{ return true; }  } ');

			document.write('function loaddd() { setTimeout("rxc();rxf();",1000); setTimeout("ddrot();",5000);}');
			document.write('function rxc() {');
			document.write('	for(var i = 0; i < covers.length; i+=2)');
			document.write('	{');
			document.write('		document.getElementById(\'wMain_H_cfull\').innerHTML += \'<div class="wMain_H_mag"><a  href="javascript:void(0);" onclick="javascript:ddpopup(\\\'\' + covers[i+1] + \'\\\');" ><img src="\' + covers[i] + \'" style="border: none;" /></a></div>\';');
			document.write('		tC += 1;}');
			document.write('		pN = Math.ceil((tC * '+mWidth+') / pS);} 	');
			document.write('function rxf() {');
			document.write('	for(var i = 0; i < featured.length; i+=2)');
			document.write('	{');
			document.write('		if(i == 0)');
			document.write('			document.getElementById(\'wMain_List\').innerHTML += \'<div id="wMain_H_F\' + (i / 2) + \'"><a href="\' + featured[i+1] + \'" target="_blank"><img src="\' + featured[i] + \'" style="border: none;width: 100px; height: 80px;" /></a></div>\';');
			document.write('		else');
			document.write('			document.getElementById(\'wMain_List\').innerHTML += \'<div id="wMain_H_F\' + (i / 2) + \'" style="display: none;"><a href="\' + featured[i+1] + \'" target="_blank"><img src="\' + featured[i] + \'" style="border:  none;width: 100px; height: 80px;" /></a></div>\';');
			document.write('	}');
			document.write('} 	');

			document.write('function ddrot() {');
			document.write('	if(fsel < ' + (featuredCount - 1) + ') {');
			document.write('		fsel += 1;');
			document.write('		f(fsel);');
			document.write('	}');
			document.write('	else {');
			document.write('		fsel = 0;');
			document.write('		f(fsel);');
			document.write('	}');
			document.write('	setTimeout(\'ddrot();\', 5000);');
			document.write('}');
			
			document.write('function sLeft() {');	
			document.write('	if(sL < 0){');	
			document.write('		sL += pS;');	
			document.write('		$("#wMain_H_cfull").animate({left: sL + "px"}, 500);');	
			document.write('	}');	
			document.write('}');	
			document.write('function sRight() {');	
			document.write('	if(sL > -((pN - 1) * pS)){');	
			document.write('		sL -= pS;');	
			document.write('		$("#wMain_H_cfull").animate({left: sL + "px"}, 500);');	
			document.write('	}');	
			document.write('}');	
			document.write('var fID = "0";');	
			document.write('function f(id) {');	
			document.write('	if(id != "prev" && id != "next") {');	
			document.write('		$("#wMain_H_F" + fID).fadeOut("fast", function() {$("#wMain_H_F" + id).fadeIn("fast");});	');	
			document.write('		$("#fi" + id).attr("class","wMain_H_ces");	');
			document.write('		$("#fi" + fID).attr("class","wMain_H_ce");	');
			document.write('		fID = id; fsel = parseInt(id);');	
			document.write('	}');	
			document.write('	else {');	
			document.write('		if(id == "prev" && parseInt(fID) > 0) {');	
			document.write('			nID = parseInt(fID) - 1;');	
			document.write('			$("#wMain_H_F" + fID).fadeOut("fast", function() {$("#wMain_H_F" + nID).fadeIn("fast");});	');	
			document.write('			$("#fi" + nID).attr("class","wMain_H_ces");	');
			document.write('			$("#fi" + fID).attr("class","wMain_H_ce");	');
			document.write('			fID = nID; fsel = parseInt(nID);');	
			document.write('		} else if(id == "next" && parseInt(fID) < '+(featuredCount - 1)+') {');	
			document.write('			nID = parseInt(fID) + 1;');	
			document.write('			$("#wMain_H_F" + fID).fadeOut("fast", function() {$("#wMain_H_F" + nID).fadeIn("fast");});	');	
			document.write('			$("#fi" + nID).attr("class","wMain_H_ces");	');
			document.write('			$("#fi" + fID).attr("class","wMain_H_ce");	');
			document.write('			fID = nID; fsel = parseInt(nID);');	
			document.write('		}');	
			document.write('	}');	
			document.write('}');	
			document.write('function fc() {');	
			document.write('	if($("#wSearchBox").attr("value") == "Search Dental Terms") {');	
			document.write('		$("#wSearchBox").attr("value","");');	
			document.write('		$("#wSearchBox").attr("class","wSearch_Box_Act");');	
			document.write('	}');	
			document.write('}');	
			document.write('function bl() {');	
			document.write('	if($("#wSearchBox").attr("value") == "") {');	
			document.write('		$("#wSearchBox").attr("class","wSearch_Box_InAct");');	
			document.write('		$("#wSearchBox").attr("value","Search Dental Terms");');	
			document.write('	}');	
			document.write('}');	
			document.write(se);	
						
			document.write('</script>');

			document.write('<style type="text/css">');
			document.write('	.b { clear: both; font-size: 1px; }');
			document.write('	#wContainer_H { width: ' + (Width ) + 'px; height: ' + (Height) + 'px; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 12px; }');
			document.write('	#wSearch_H {  -moz-border-radius-topleft: 11px;-moz-border-radius-topright: 11px; -webkit-border-top-left-radius: 11px;-webkit-border-top-right-radius: 11px; background-color: ' + this.HeaderBackground + '; border: solid 1px ' + this.BorderColor + '; color: ' + this.HeaderLabelColor + '; text-align:center; width: ' + (Width) + 'px; padding: 5px 0px 5px 0px;  }');
			document.write('	#wSearch_Title { font-size: 13px; font-weight: bold; margin-bottom: 5px;  }');
			document.write('	#wSearch_TBox {  margin-bottom: 5px; }');
			document.write('	#wSearch_Search {  margin-bottom: 5px; }');
			document.write('	#wSearchBox { font-size: 12px; padding: 1px 3px 1px 3px; width: ' + (Width - 30) + 'px; }');
			document.write('	#wSearchBtn { font-size: 12px; }');
			document.write('	.wSearch_Box_Act { color: #333333; }');
			document.write('	.wSearch_Box_InAct { color: #999999; }');
			document.write('	#wMain_H { -moz-border-radius-bottomleft: 11px;-moz-border-radius-bottomright: 11px;-webkit-border-bottom-left-radius: 11px;-webkit-border-bottom-right-radius: 11px; width: ' + (Width) + 'px;  background: #fff url("'+PublicImgFolder+'cs_grad_slider.gif") top center repeat-x; border: solid 1px #ccc; border-top: none; }');
			document.write('	#wMain_H_Ma { width: ' + (Width - 35) + 'px; height: 130px; margin: 0px auto 0px auto; }');
			document.write('	#wMain_H_la { background: url("' + PublicImgFolder + 'dd_left.bmp") 0px center no-repeat; cursor: pointer; float: left; width: 14px; height: 130px; margin: 10px 1px 0px 4px;   }');
			document.write('	#wMain_H_cc { float: left; width: ' + (Width - 70) + 'px; height: 130px;overflow: hidden; position: relative; padding: 15px 0px 5px 0px;  }	');
			document.write('	#wMain_H_cfull { width: 10000px; position: absolute }');
			document.write('	.wMain_H_mag { float: left; width: 91px; height: 120px;  margin: 0px 2px 0px 2px; }');
			document.write('	#wMain_H_ra { background: url("'+PublicImgFolder+'dd_right.bmp") 0px center no-repeat;cursor: pointer; float: left; width: 14px; height: 130px; margin: 10px 1px 0px 1px;  }');
			document.write('	#wMain_H_Feat { clear:both; height: 136px; width: ' + (Width) + 'px; padding: 5px 0px 5px 0px; text-align:center; }');
			document.write('	.wMain_H_le {float: left; margin: 0px 1px 0px 1px; width: 10px; height: 12px; background: url("'+PublicImgFolder+'dd_f_left.bmp") 0px center no-repeat;cursor: pointer;} ');
			document.write('	.wMain_H_re {float: left; margin: 0px 1px 0px 1px; width: 10px; height: 12px; background: url("'+PublicImgFolder+'dd_f_right.bmp") 0px center no-repeat;cursor: pointer;} ');
			document.write('	.wMain_H_ce {float: left; margin: 0px 1px 0px 1px; width: 10px; height: 12px; background: url("'+PublicImgFolder+'dd_f_center.bmp") 0px center no-repeat;cursor: pointer;} ');
			document.write('	.wMain_H_ces {float: left; margin: 0px 1px 0px 1px; width: 10px; height: 12px; background: url("'+PublicImgFolder+'dd_f_center_selected.bmp") 0px center no-repeat;cursor: pointer;} ');
			document.write('	.blink { color: #999; font-size: 10px; text-decoration: none; } .blink:hover { color: #999; text-decoration: underline; } .blink:visited { color: #999;  } ');
			document.write('</style>');
			
			document.write('<div id="wContainer_H">');
			document.write('	<div id="wSearch_H">');
			document.write('    	<div id="wSearch_Title">' + this.TitleText + ':</div>');
			document.write('        <div id="wSearch_TBox"><input class="wSearch_Box_InAct" type="text" id="wSearchBox" value="Search Dental Terms" onblur="bl()" onfocus="fc()" onKeyPress="checkEnter(event)"/></div>');
			document.write('        <div id="wSearch_Search"><input type="button" id="wSearchBtn" value="' + this.ButtonText + '" onclick="s();"/></div>');
			document.write('    </div>');
			document.write('    <div id="wMain_H"><div id="wMain_H_Ma">');
			document.write('    	<div id="wMain_H_la" onclick="sLeft();"></div>');
			document.write('    	<div id="wMain_H_cc">');
			document.write('        	<div id="wMain_H_cfull">');
			document.write('            </div>');
			document.write('        </div>');     
			document.write('    	<div id="wMain_H_ra" onclick="sRight();"></div>');
			document.write('        </div><div id="wMain_H_Feat">');
			document.write('        	<div style="font-size: 13px; text-align: center; margin-bottom: 4px;"><strong>As Featured on:</strong></div>');
			document.write('        		<div id="wMain_List">');
			document.write('        		</div>');
			document.write('            <div style="width: ' + (featuredCount * 18) + 'px; margin: 10px auto 0px auto;">');
			document.write('            	<div class="wMain_H_le" onclick="f(\'prev\');"></div>');	
			
			for(var fti = 0; fti < featuredCount; fti += 1)
			{
				if(fti === 0) {
					document.write('<div id="fi' + fti + '" class="wMain_H_ces" onclick="f(\'' + fti + '\');"></div>');
				}
				else {					
					document.write('<div id="fi' + fti + '" class="wMain_H_ce" onclick="f(\'' + fti + '\');"></div>');
				}
			}
			
			document.write('<div class="wMain_H_re" onclick="f(\'next\');"></div><div class="b"></div>');	
			document.write('            </div>');
			document.write('        </div>');
			document.write('    </div>');
			document.write('	<div style="margin-top: 5px; height: 10px; color: #999; font-size: 10px; text-align:center;"><a class="blink" target="_blank" href="http://www.deardoctor.com/subscribe">Subscribe</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="blink" target="_blank" href="http://www.deardoctor.com/makeover">Win a Dental Makeover</a><br>Powered by <a class="blink" target="_blank" href="http://www.deardoctor.com">Dear Doctor Magazine</a></div>');
			document.write('</div>');	
			
			document.write('<script language="javascript">loaddd();</script>');
			
		}
		else
		{
			// No Main Content
			// Only search box, vertical layout with or without border
			if(this.Width < 200)
				this.Width = 200; // Minimum width to ensure CSS compatibility is 200 pixels;			

			document.write(jq);
			document.write(enc);
			document.write(popup);

			document.write('<LINK REL=StyleSheet HREF="' + PublicImgFolder + 'ddwstyles.css" TYPE="text/css" MEDIA=screen>');

			document.write('<script language="javascript" type="text/javascript">');	
			document.write('function fc() {');	
			document.write('	if($("#wSearchBox").attr("value") == "Search Dental Terms") {');	
			document.write('		$("#wSearchBox").attr("value","");');	
			document.write('		$("#wSearchBox").attr("class","wSearch_Box_Act");');	
			document.write('	}');	
			document.write('}');	
			document.write('function bl() {');	
			document.write('	if($("#wSearchBox").attr("value") == "") {');	
			document.write('		$("#wSearchBox").attr("class","wSearch_Box_InAct");');	
			document.write('		$("#wSearchBox").attr("value","Search Dental Terms");');	
			document.write('	}');	
			document.write('}');	
			document.write(se);	
			document.write('function checkEnter(e){ if(e && e.which){ e = e; characterCode = e.which; } else{ e = event; characterCode = e.keyCode; } if(characterCode == 13){ s(); return false; } else{ return true; }  } ');
			document.write('</script>');
			
			document.write('<style type="text/css">');
			document.write('	.b { clear: both; font-size: 1px; }');
			document.write('	#wContainer_H { width: ' + this.Width + 'px; height: auto;  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 12px; }');
			document.write('	#wSearch_H { -moz-border-radius: 11px; -webkit-border-radius: 11px;  background-color: ' + this.HeaderBackground + '; border: solid 1px ' + this.BorderColor + '; color: ' + this.HeaderLabelColor + '; text-align:center; width: ' + (this.Width - 20) + 'px; padding: 5px; }');
			document.write('	#wSearch_Title { font-size: 15px; font-weight: bold; margin-bottom: 5px;  }');
			document.write('	#wSearch_TBox {  margin-bottom: 5px; }');
			document.write('	#wSearch_Search {  margin-bottom: 5px; }');
			document.write('	#wSearchBox { font-size: 12px; padding: 1px 3px 1px 3px; width: ' + (this.Width - 40) + 'px; }');
			document.write('	#wSearchBtn { font-size: 12px; }');
			document.write('	.wSearch_Box_Act { color: #333333; }');
			document.write('	.wSearch_Box_InAct { color: #999999; }');
			document.write('	.blink { color: #999; font-size: 10px; text-decoration: none; } .blink:hover { color: #999; text-decoration: underline; } .blink:visited { color: #999;  } ');
			document.write('</style>');
			
			document.write('<div id="wContainer_H">');
			document.write('	<div id="wSearch_H">');
			document.write('    	<div id="wSearch_Title">' + this.TitleText + ':</div>');
			document.write('        <div id="wSearch_TBox"><input class="wSearch_Box_InAct" type="text" id="wSearchBox" value="Search Dental Terms"  onblur="bl()" onfocus="fc()" onKeyPress="checkEnter(event)"/></div>');
			document.write('        <div id="wSearch_Search"><input type="button" id="wSearchBtn" value="' + this.ButtonText + '" onclick="s();"/></div>');
			document.write('		<div style="height: 14px; color: #999; font-size: 10px; text-align:center;">Powered by <a class="blink" target="_blank" href="http://www.deardoctor.com">Dear Doctor Magazine</a></div>');
			document.write('    </div>');
			document.write('</div>');					
		}
	}
	

}