/************************************************
Opens a new browser window with options
*************************************************/
function uc_openWin(theURL, winName, features) {
    window.open(theURL, winName, features);
}

function loadModule(flag) {
    document.location = flag;
}
function loadModule2(flag) {
    window.open(flag);
}
function rowMouseOver(id) {
    el = document.getElementById(id);
    el2 = document.getElementById('link' + id);
    el.style.backgroundColor = '';
    el.style.color = '';
    el2.style.backgroundColor = '';
    el2.style.color = '';
}
function rowMouseOut(id) {
    el = document.getElementById(id);
    el2 = document.getElementById('link' + id);
    el.style.backgroundColor = '';
    el.style.color = '';
    el2.style.backgroundColor = '';
    el2.style.color = '';
}




/***********************************************
* Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
* Copyright 2002-2007 by Sharon Paine
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* IMPORTANT: Put script after tooltip div or 
put tooltip div just before </BODY>. */

var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true : false;
var ie5 = ((navigator.userAgent.indexOf("MSIE") > -1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tipFollowMouse = true;
// Be sure to set tipWidth wide enough for widest image
var tipWidth = 160;
var offX = 20; // how far from mouse to show tip
var offY = 12;
var tipFontFamily = "Verdana, arial, helvetica, sans-serif";
var tipFontSize = "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor = "#000000";
var tipBgColor = "#FFFFDD";
var tipBorderColor = "#333333";
var tipBorderWidth = 2;
var tipBorderStyle = "solid";
var tipPadding = 4;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
// multi-dimensional arrays containing: 
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip
var index = 0;
messages[0] = new Array('/images/btn_help2.gif', 'A book that describes imaginary people, places or events that did not actually occur, but were created or invented. This typically includes novels, stories, poetry, short stories and plays.', "#FDFDF0");
messages[1] = new Array('/images/btn_help2.gif', 'A book that consists of factual information, true events or people that actually existed or occurred in reality. Not a story from your imagination. If names were changed for privacy or legal reasons, it\'s still considered non-fiction. This typically includes biographies, journals, memoirs, newspaper stories, personal accounts, history, reference, genealogy, textbooks and guides. ', "#FDFDF0");
messages[2] = new Array('/images/btn_help2.gif', 'Still unsure about your title? Select a title that fits your book\'s content and style. Be creative and try to come up with something catchy - it\'s the first line someone reads of your book.', 'FDFDF0');
messages[3] = new Array('/images/btn_help2.gif', 'Depending on your title and type of book, you may or may not need a subtitle. It should expand on the main title and add detail about what the book is about. <p>If your book does not have a subtitle, just leave this field blank.', 'FDFDF0');
messages[4] = new Array('/images/btn_help2.gif', 'Select the language of the main text of your book. If it\'s in multiple languages, pick the language group used by the majority of your targeted audience.', 'FDFDF0');
messages[5] = new Array('/images/btn_help2.gif', 'Choose a password that is easy for you to remember but difficult for someone else to guess. Passwords must be at least 6 to 24 characters and contain at least one letter and at least one number.', 'FDFDF0');
messages[6] = new Array('/images/btn_help2.gif', 'I need help with selecting a book size.', 'FDFDF0');
messages[7] = new Array('/images/btn_help2.gif', 'The template is a Microsoft Word document set to the margins and standards used for the book size you selected. <p>After you click the button to download the template, you will be prompted to either save or open the file. Choose \"save\", then choose where you want to save the file on your computer (anywhere you will be able to easily find it, such as \"My Documents\" or \"Desktop\").', 'FDFDF0');
messages[8] = new Array('/images/btn_help2.gif', 'You must have Adobe Reader installed to view the preview file of the inside of your book. If the file does not open, click the icon on the left to download a free version of Adobe Reader from Adobe\'s Web site', 'FDFDF0');
messages[9] = new Array('/images/btn_help2.gif', 'Enter the name exactly as you would like it to appear as the author of the book. You can publish your book under your real name, a nick name or a pen name. You can enter a first, middle and last name or any combination of initials. It\'s your choice!', 'FDFDF0');
messages[10] = new Array('/images/btn_help2.gif', 'If you worked with a group of authors to write your book, enter their names here exactly as you would like them to appear. If you worked alone, just leave these fields blank.', 'FDFDF0');
messages[11] = new Array('/images/btn_help2.gif', 'We have a wide variety of stock cover designs to fit the genre of your book. <p>Click the link to open a new window and view the stock images. After you select a design, you can preview your choice.', 'FDFDF0');
messages[12] = new Array('/images/btn_help2.gif', 'If you have created your own artwork, simply click the <b>Browse</b> button to locate it on your computer and then <b>UPLOAD</b> it to us!<p> <b>Note:</b> your artwork must be at least 1000px by 1000px and 300dpi, or 300 dpi at the size needed to fill the cover for printing purposes', 'FDFDF0');
messages[13] = new Array('/images/btn_help2.gif', 'We all know the saying: \"Don\'t judge a book by its cover;\" but in reality, people are either attracted to or avoid a book based on the cover design. Let our designers give your cover a professional and creative touch! <p> If you choose this option, you can share your ideas with one of our cover designers who will contact you before the creation process begins.', 'FDFDF0');
messages[14] = new Array('/images/btn_help2.gif', 'Follow the link to open a new window, enter your user name and password, and choose from a rainbow of color combinations.', 'FDFDF0');
messages[15] = new Array('/images/btn_help2.gif', 'Each time you make a change to your cover, click the <b>Update Preview</b> link to refresh the screen.', 'FDFDF0');
messages[16] = new Array('/images/btn_help2.gif', 'The price of your book is determined by a fixed cost for the cover and page count, plus the distribution cost and royalty amount. The cover cost and page count determine the minimum base price for the production of your book. Then the distribution and royalty amounts are displayed after you choose the total selling price.', 'FDFDF0');
messages[17] = new Array('/images/btn_help2.gif', 'The print cost is automatically set based on the type of book you have created.', 'FDFDF0');
messages[18] = new Array('/images/btn_help2.gif', 'The royalty is how much you earn for each copy of your book sold. You will earn the indicated royalty amount based on whether the book is sold through HBF Publishers or through another retailer.', 'FDFDF0');
messages[19] = new Array('/images/btn_help2.gif', 'To get a better understanding of book prices and to see what other authors have used, click here for examples.', 'FDFDF0');
messages[20] = new Array('/images/btn_help2.gif', 'Due to the uncertainty of a book\'s spine width, a full image display is not possible at this time. <p>Any background color you choose will apply to the spine as well.<p>If you wish to have a full color image for your entire cover, click now to learn about our cover design services.', 'FDFDF0');
messages[21] = new Array('/images/btn_help2.gif', 'This text  can be 300 words or less and will be displayed on the back cover. It should captivate and entice people to read the book and is sometimes thought of as a \"teaser\" because it describes key elements of the book but does not reveal the conclusion or give away too much of the story. You can include a review, quotes, or endorsements also. <p>You may leave this area blank if you wish.', 'FDFDF0');
//messages[index++] = new Array('images/Icon_Profile.jpg','Step 1: My Profile. <p>Tell us more about about you, the author.','FDFDF0');
//messages[index++] = new Array('images/Icon_BookInfo.jpg','Step 2: My Book Information. <p>Tell us the basics about your book.','FDFDF0');
//messages[index++] = new Array('images/Icon_Manuscript.jpg','Step 3: My Manuscript. <p>We give you the template and assistance to finalize and upload your manuscript.','FDFDF0');
//messages[index++] = new Array('images/Icon_Cover.jpg','Step 4: My Cover. <p>Build, upload or view other options for your cover.','FDFDF0');
//messages[index++] = new Array('images/Icon_Pricing.jpg','Step 5: My Book Pricing. <p>Use our guide to set the price and royalty','FDFDF0');
//messages[index++] = new Array('images/Icon_Published.jpg','Step 6: My Published Book. <p>Reach this point and you are a published author!','FDFDF0');
//22 not used
messages[22] = new Array('/images/btn_help2.gif', 'In the book\'s final, printed form, we cannot guarantee a 100% color match. There may be discrepancies of varying degrees. <p>Do not completely rely on one source when viewing an image. Try a variety of printers and computer screens to get an idea of the possible variations. For more information, see our FAQ help section on this topic.', 'FDFDF0');
messages[23] = new Array('/images/btn_help2.gif', 'You must have Adobe Reader on your computer to view the cover proof. If the file does not open, click the icon on the left to download free version of Adobe Reader from Adobe\'s Web site', 'FDFDF0');
messages[24] = new Array('/images/btn_help2.gif', 'About the size of notebook, the 8.25" x 11" book lends itself to guides, children\'s books, screenplays, or just about anything that needs more space to spread out.', 'FDFDF0');
messages[25] = new Array('/images/btn_help2.gif', 'Standard novel size, slightly larger size to accommodate pictures and longer manuscripts.', 'FDFDF0');
messages[26] = new Array('/images/btn_help2.gif', 'Standard novel size, slightly smaller to accommodate shorter works. ', 'FDFDF0');
//27 not used
messages[27] = new Array('/images/btn_help2.gif', '', 'FDFDF0');
//28 not used
messages[28] = new Array('/images/btn_help2.gif', 'Passwords must be at least 6 to 24 characters and contain at least one letter and at least one number.', 'FDFDF0');
messages[29] = new Array('/images/btn_help2.gif', 'Taxpayer Identification Number, or TIN, is required for tax purposes by the U.S. government, who requires you pay taxes on the total earnings for your book. If you are publishing your book under your own name or a pen name, your TIN is your Social Security number.  If you do not supply a valid TIN, we are required to withhold 28% of your total royalty earnings.', 'FDFDF0');
//30 not used
messages[30] = new Array('/images/btn_help2.gif', 'Need Text Here.', 'FDFDF0');
messages[31] = new Array('/images/btn_help2.gif', 'You must have Micosoft Word installed to view the preview file of the inside of your book.', 'FDFDF0');
messages[32] = new Array('/images/btn_help2.gif', 'Example help bubble text', 'FDFDF0');
messages[33] = new Array('/images/btn_help2.gif', 'We have a wide variety of color options <p>Click the color option box to open a new window. After you select a design, you can preview your selection.', 'FDFDF0');
messages[34] = new Array('/images/btn_help2.gif', 'Enter a desired retail sale price for your book, then click "Calculate." Your royalty amount will be calculated below.', 'FDFDF0');
messages[35] = new Array('/images/btn_help2.gif', 'The distribution cost is calculated by the costs involved in offering your book for purchase through various channels.', 'FDFDF0');
messages[36] = new Array('/images/btn_help2.gif', 'You must have Adobe Reader on your computer to view the terms of service. If the file does not open, click the icon on the left to download free version of Adobe Reader from Adobe\'s Web site', 'FDFDF0');
messages[37] = new Array('/images/btn_help2.gif', 'You must have Adobe Reader on your computer to view the privacy policy. If the file does not open, click the icon on the left to download free version of Adobe Reader from Adobe\'s Web site', 'FDFDF0');
messages[38] = new Array('/images/btn_help2.gif', 'Create a user ID of letters and/or numbers between 6 and 24 (no spaces or special characters).', 'FDFDF0');
messages[39] = new Array('/images/btn_help2.gif', 'Select one of the available book types to estimate.  Perfect Bound means that the book&#39;s signatures are back to back and glued in place.  This is the most durable method of paperback binding.', 'FDFDF0');
messages[40] = new Array('/images/btn_help2.gif', 'Enter the estimated page count of your work as it fits within the selected binding type.', 'FDFDF0');
messages[41] = new Array('/images/btn_help2.gif', 'Enter the number of copies you would like to cost estimate. Volume discounts begin at a quantity of 25 for author orders.', 'FDFDF0');
messages[42] = new Array('/images/btn_help2.gif', 'Right now we only price in US Dollars ($).  Stay tuned for more currencies.', 'FDFDF0');
messages[43] = new Array('/images/btn_help2.gif', 'Select an address used previously from the drop-down list provided or create a new address by entering the information below. The "use existing" feature is for your convenience only; we do not use additional address profiles in any other way. This information is stored securely.', 'FDFDF0');
messages[44] = new Array('/images/btn_help2.gif', 'Select "same as billing" if applicable, otherwise select an address used previously from the drop-down list provided or create a new address by entering the information below. The "use existing" feature is for your convenience only; we do not use additional address profiles in any other way. This information is stored securely.', 'FDFDF0');
////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
if (document.images) {
    var theImgs = new Array();
    for (var i = 0; i < messages.length; i++) {
        theImgs[i] = new Image();
        theImgs[i].src = messages[i][0];
    }
}

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
    if (nodyn) return;
    tooltip = (ie4) ? document.all['tipDiv'] : (ie5 || ns5) ? document.getElementById('tipDiv') : null;
    tipcss = tooltip.style;
    if (ie4 || ie5 || ns5) {	// ns4 would lose all this on rewrites
        tipcss.width = tipWidth + "px";
        tipcss.fontFamily = tipFontFamily;
        tipcss.fontSize = tipFontSize;
        tipcss.color = tipFontColor;
        tipcss.backgroundColor = tipBgColor;
        tipcss.borderColor = tipBorderColor;
        tipcss.borderWidth = tipBorderWidth + "px";
        tipcss.padding = tipPadding + "px";
        tipcss.borderStyle = tipBorderStyle;
    }
    if (tooltip && tipFollowMouse) {
        document.onmousemove = trackMouse;
    }
}

window.onload = initTip;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
var t1, t2; // for setTimeouts
var tipOn = false; // check if over tooltip link
function doTooltip(evt, num) {
    if (!tooltip) return;
    if (t1) clearTimeout(t1); if (t2) clearTimeout(t2);
    tipOn = true;
    // set colors if included in messages array
    if (messages[num][2]) var curBgColor = messages[num][2];
    else curBgColor = tipBgColor;
    if (messages[num][3]) var curFontColor = messages[num][3];
    else curFontColor = tipFontColor;
    if (ie4 || ie5 || ns5) {
        var tip = startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
        tipcss.backgroundColor = curBgColor;
        tooltip.innerHTML = tip;
    }
    if (!tipFollowMouse) positionTip(evt);
    else t1 = setTimeout("tipcss.visibility='visible'", 100);
}

var mouseX, mouseY;
function trackMouse(evt) {
    standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body //create reference to common "body" across doctypes
    mouseX = (ns5) ? evt.pageX : window.event.clientX + standardbody.scrollLeft;
    mouseY = (ns5) ? evt.pageY : window.event.clientY + standardbody.scrollTop;
    if (tipOn) positionTip(evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
    if (!tipFollowMouse) {
        mouseX = (ns5) ? evt.pageX : window.event.clientX + standardbody.scrollLeft;
        mouseY = (ns5) ? evt.pageY : window.event.clientY + standardbody.scrollTop;
    }
    // tooltip width and height
    var tpWd = (ie4 || ie5) ? tooltip.clientWidth : tooltip.offsetWidth;
    var tpHt = (ie4 || ie5) ? tooltip.clientHeight : tooltip.offsetHeight;
    // document area in view (subtract scrollbar width for ns)
    var winWd = (ns5) ? window.innerWidth - 20 + window.pageXOffset : standardbody.clientWidth + standardbody.scrollLeft;
    var winHt = (ns5) ? window.innerHeight - 20 + window.pageYOffset : standardbody.clientHeight + standardbody.scrollTop;
    // check mouse position against tip and window dimensions
    // and position the tooltip 
    if ((mouseX + offX + tpWd) > winWd)
        tipcss.left = mouseX - (tpWd + offX) + "px";
    else tipcss.left = mouseX + offX + "px";
    if ((mouseY + offY + tpHt) > winHt)
        tipcss.top = winHt - (tpHt + offY) + "px";
    else tipcss.top = mouseY + offY + "px";
    if (!tipFollowMouse) t1 = setTimeout("tipcss.visibility='visible'", 100);
}

function hideTip() {
    if (!tooltip) return;
    t2 = setTimeout("tipcss.visibility='hidden'", 100);
    tipOn = false;
}

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')

function ChangeTabClass(TargetElement, TargetClass) {
    var toChange = document.getElementById(TargetElement);
    toChange.className = TargetClass;

    var toChangeChild = toChange.childNodes[0];
    toChangeChild.className = TargetClass;
}

var remote = null;


function launchCoverRenderingDialog() {

    remote = window.open("CoverRenderingDialog.aspx", "remote", "height=700,width=550,dependent,status=no,location=no,toolbar=no,menubar=no,scrollbars=yes");

    return false;

}

function closeWindow() {

    if (remote && remote.open && !remote.closed) remote.close();

}

function TextCounter(field, cntfield, maxlimit) {
    cntfield.innerHTML = maxlimit - field.value.length;
    if (field.value.length > maxlimit)
        cntfield.style.color = "red";
    else
        cntfield.style.color = "";
}

