<!-- Start Config Section -->

var showAddToSite = 1;
var showBuyNow = 1;
var baseURL = 'http://www.ewidgetsonline.com/dxreader';
var addToSiteURL;
var buyNow;
var addToSiteURL_Audio;
var buyNow_Audio;
<!-- End Config Section -->

// JavaScript Document
function MM_swapImgRestore() {
  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 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_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];}
}

function loadWidget(isbn, buyNowLink) {
	var s = new String(isbn);
	isbn = s.replace(/\+/g,"%2b");
	if (buyNowLink == undefined || buyNowLink == null) {
		buyNowLink = "";
	}
	buyNowLink = buyNowLink.replace(/\&/g,"%26");
	document.write("<script language='javascript' src='" + baseURL + "/Script.aspx?token=" + isbn + "&buyNowLink=" + buyNowLink + "' ></script>");
}

function showCode(isbn, buyNowLink) {	

		addToSiteURL=document.getElementById("showcode_"+ isbn).href;
		document.getElementById("showcode_"+ isbn).href = "javascript:void(0)";
		
		var s = new String(isbn);
		isbn = s.replace(/\+/g,"%2b");
		var text2Copy = "";
		//text2Copy += "<!-- Add the following only once in the <head> tag of your html page -->\n<script type='text/JavaScript' src='" + baseURL + "/widget.js'></script>\n\n";
		//text2Copy += "<!-- Place the following piece of code in the exact place where you would like the widget to appear -->\n";
		
		//text2Copy += "<script type='text/JavaScript'>loadWidget('" + isbn + "');</script>";

		text2Copy += "&lt;!-- Add the following only once in the &lt;head&gt; tag of your html page --&gt;<br/>&lt;script type='text/JavaScript' src='" + baseURL + "/widget.js'&gt;&lt;/script&gt;<br/><br/>";
		text2Copy += "&lt;!-- Place the following piece of code in the exact place where you would like the widget to appear --&gt;<br/>";
		
		text2Copy += "&lt;script type='text/JavaScript'&gt;loadWidget('" + isbn + "');&lt;/script&gt;";
	    
		if (document.getElementById && document.getElementById("img_"+isbn) ) {
			var imageHeight = document.getElementById("img_"+isbn).height;
			var imageWidth = document.getElementById("img_"+isbn).width;
			document.getElementById("imageWindow_"+ isbn).style.height = imageHeight + "px";
			document.getElementById("imageWindow_"+ isbn).innerHTML = "<table  border='0' cellpadding='0' cellspacing='0' width='100%' height='100%'><tr><td    style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:8pt; color:#a5a5a5;text-align:justify;padding-right:4pt; '>Copy the HTML snippet and paste into your web page.<img src='" + baseURL + "/AddToWebSite.aspx?token="+isbn + "' height='1' width='1' /></td><td>&nbsp;</td><td align='right' valign='top'><a href=javascript:closeCode('" + isbn + "','" + buyNowLink + "') style='text-decoration:none;font-size:20px; color:white;font-weight:bold;'><b>&#0215;</b></a>&nbsp;</td></tr><tr><td colspan='3'><div id='txaCode_" + isbn + "' style='overflow:scroll;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:9pt;color:#333333;text-align:justify;background-color:#FFFFFF; width:" + (imageWidth-4) + "px; height:" + (imageHeight - 32) + "px;'>" + text2Copy + "</div></td></tr></table>";
		}

}

function closeCode(isbn, buyNowLink) {
	var s = new String(isbn);
	isbn = s.replace(/\+/g,"%2b");
	if (document.getElementById) {
        document.getElementById("imageWindow_"+isbn).innerHTML = "<a href='" + baseURL + "/widget.aspx?bookid=" + isbn + "&buyNowLink=" + buyNowLink + "' target='_blank'><img id='img_" + isbn + "' src='" + baseURL + "/GetCoverpage.aspx?token=" + isbn + "' border='0' align='center' alt='View Inside'/></a>";
    }
    document.getElementById("showcode_"+ isbn).href = addToSiteURL;    
}

function loadAudioWidget(isbn, buyNowLink){
    loadWidget(isbn, buyNowLink);
//	var s = new String(isbn);
//	isbn = s.replace(/\+/g,"%2b");
//	if (buyNowLink == undefined || buyNowLink == null) {
//		buyNowLink = "";
//	}
//	
//	document.write("<script language='javascript' src='" + baseURL + "/Script.aspx?bookId=" + isbn + "&buyNowLink=" + buyNowLink + "' ></script>");
}


function showAudioCode(isbn, buyNowLink){
	addToSiteURL_Audio=document.getElementById("showcode_audio_"+ isbn).href;
	document.getElementById("showcode_audio_"+ isbn).href = "javascript:void(0)";
	
	var s = new String(isbn);
	isbn = s.replace(/\+/g,"%2b");
	var text2Copy = "";
	text2Copy += "&lt;!-- Add the following only once in the &lt;head&gt; tag of your html page --&gt;<br/>&lt;script type='text/JavaScript' src='" + baseURL + "/widget.js'&gt;&lt;/script&gt;<br/><br/>";
	text2Copy += "&lt;!-- Place the following piece of code in the exact place where you would like the widget to appear --&gt;<br/>";
	
	text2Copy += "&lt;script type='text/JavaScript'&gt;loadAudioWidget('" + isbn + "');&lt;/script&gt;";
	if (document.getElementById && document.getElementById("img_"+isbn) ) {
		var imageHeight = document.getElementById("img_"+isbn).height;
		var imageWidth = document.getElementById("img_"+isbn).width;
		document.getElementById("imageWindow_"+ isbn).style.height = imageHeight + "px";
		document.getElementById("imageWindow_"+ isbn).innerHTML = "<table  border='0' cellpadding='0' cellspacing='0' width='100%' height='100%'><tr><td    style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:8pt; color:#a5a5a5;text-align:justify;padding-right:4pt; '>Copy the HTML snippet and paste into your web page.<img src='" + baseURL + "/AddToWebSite.aspx?token="+isbn + "' height='1' width='1' /></td><td>&nbsp;</td><td align='right' valign='top'><a href=javascript:closeAudioCode('" + isbn + "','" + buyNowLink + "') style='text-decoration:none;font-size:20px; color:white;font-weight:bold;'><b>&#0215;</b></a>&nbsp;</td></tr><tr><td colspan='3'><div id='txaCode_" + isbn + "' style='overflow:scroll;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:9pt;color:#333333;text-align:justify;background-color:#FFFFFF; width:" + (imageWidth-4) + "px; height:" + (imageHeight - 32) + "px;'>" + text2Copy + "</div></td></tr></table>";
	}
}


function closeAudioCode(isbn, buyNowLink) {
	var s = new String(isbn);
	isbn = s.replace(/\+/g,"%2b");
	if (document.getElementById) {
        document.getElementById("imageWindow_"+isbn).innerHTML = "<a href='" + baseURL + "/AudioWidget.aspx?bookid=" + isbn + "&buyNowLink=" + buyNowLink + "' target='_blank'><img id='img_" + isbn + "' src='" + baseURL + "/GetCoverpage.aspx?token=" + isbn + "' border='0' align='center' alt='Hear Inside'/></a>";
    }

    document.getElementById("showcode_audio_"+ isbn).href = addToSiteURL_Audio;
}


function buyNow(isbn, buyNowLink) {

	var s = new String(isbn);
	isbn = s.replace(/\+/g,"%2b");
	var buyNowURL = baseURL + "/BuyNow.aspx?token=" + isbn + "&buyNowLink=" + buyNowLink +"&isViewInside=false";
	window.location.href = buyNowURL;
}

function showHelp(isbn) {			
	
	document.getElementById("helpcode_"+ isbn).href = "javascript:void(0)";
	
	openNewBrWindow(baseURL + "/GetHelp.aspx?token=" + isbn,'whatsthis','resizable=yes,width=600,height=520');
	

}

function openNewBrWindow(theURL,winName,features) { //v2.0
  	window.open(theURL,winName,features);
  	
}
