function new_goBack(location){
  var browser=navigator.appName;
  if (browser != 'Microsoft Internet Explorer'){
    javascript:history.go(-1);
  } else {
    window.location.href=location;
  }
}
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  if (strEmail.search(validRegExp) == -1){
    return false;
  }
  return true;
}
function myFocus(element) {
  if (element.value == element.defaultValue) {
    element.value = '';
  }
}
function myBlur(element) {
  if (element.value == '') {
    element.value = element.defaultValue;
  }
}

function addReview(){
  var name = document.getElementById('review_name').value;
  var email = document.getElementById('review_email').value;
  var review = document.getElementById('review_content').value;
  var rating = document.getElementById('review_rating').value;
  var has_errors = '';
  if (isValidEmail(email) == false){
    has_errors = 'Please specify a valid email';
  }
  if ((name == '') || (name == 'Your Name')){
    has_errors = 'Please specify your name';
  }
  if ((review == '') || (review == 'Write a review...')){
    has_errors = 'Please specify a review';
  }
  if (rating == '0'){
    has_errors = 'Please select a rating';
  }
  if (has_errors == ''){
    getAXAH('http://www.free-ebooks.net/ajax.php?review=add&id=<!-- PARADISE:EBOOKID -->&name='+escape(name)+'&email='+escape(email)+'&content='+escape(review)+'&rating='+rating,'review_ajax_body');
  } else {
    alert(has_errors);
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function findPos(obj) {
  var curleft = curtop = 0;
  if (obj.offsetParent) {
    do {
  		curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
    } while (obj = obj.offsetParent);
	  return [curleft,curtop];
  }
}

function showDescription(t, type){
  var desc = document.getElementById('description_' + type);
  var coord = findPos(t);
  desc.style.position = 'absolute';
  desc.style.left = coord[0]+'px';
  desc.style.top = (coord[1]+t.offsetHeight-2)+'px';
  desc.style.visibility = 'visible';
  desc.style.zIndex = 999;
}

function hideDescription(t, type){
  var desc = document.getElementById('description_' + type);
  desc.style.visibility = 'hidden';
}



///code for test_template/test.js
function translate(tolang){
  window.location.href='http://www.free-ebooks.net/lang_redir.php?r='+escape('http://translate.google.com/translate?hl=en&ie=UTF9&langpair=en|'+tolang+'&u='+escape(window.location.href));
}
var tr=new Array()
tr[0]="<table width='100%' cellspacing='1' cellpadding='30px'> <tr><td width=\"33%\"><a href=\"javascript:translate('fr');\"><img src=\"/img/lang_icon/fr_img.gif\" border=\"0\"/></a></td>    <td width=\"33%\"><a href=\"javascript:translate('de');\"><img src=\"/img/lang_icon/de_img.gif\"  border=\"0\"/></a></td>    <td><a href=\"javascript:translate('nl')\"><img src=\"/img/lang_icon/fr_img.gif\" border=\"0\"/></a></td>  </tr>  <tr>    <td><a href=\"javascript:translate('it')\"><img src=\"/img/lang_icon/it_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('es')\"><img src=\"/img/lang_icon/es_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('pt')\"><img src=\"/img/lang_icon/pt_img.gif\" border=\"0\"/></a></td>  </tr>  <tr>    <td><a href=\"javascript:translate('hi')\"><img src=\"/img/lang_icon/hi_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('zh-CN')\"><img src=\"/img/lang_icon/zh-CN_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('ar')\"><img src=\"/img/lang_icon/ar_img.gif\" border=\"0\"/></a></td>  </tr>  <tr>    <td><a href=\"javascript:translate('ru')\"><img src=\"/img/lang_icon/ru_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('ja')\"><img src=\"/img/lang_icon/ja_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('ko')\"><img src=\"/img/lang_icon/ko_img.gif\" border=\"0\"/></a></td>  </tr>  <tr>    <td><a href=\"javascript:translate('ro')\"><img src=\"/img/lang_icon/ro_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('pl')\"><img src=\"/img/lang_icon/pl_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('el')\"><img src=\"/img/lang_icon/el_img.gif\" border=\"0\"/></a></td>  </tr>  <tr>    <td><a href=\"javascript:translate('cs')\"><img src=\"/img/lang_icon/cs_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('da')\"><img src=\"/img/lang_icon/da_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('bg')\"><img src=\"/img/lang_icon/bg_img.gif\" border=\"0\"/></a></td>  </tr>  <tr>    <td><a href=\"javascript:translate('no')\"><img src=\"/img/lang_icon/no_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('sv')\"><img src=\"/img/lang_icon/sv_img.gif\" border=\"0\"/></a></td>    <td><a href=\"javascript:translate('fi')\"><img src=\"/img/lang_icon/fi_img.gif\" border=\"0\"/></a></td>  </tr></table>";
var menuwidth='200px';
var disappeardelay=500;
var hidemenu_onclick="no";

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dm"><div id="dmdiv" style="visibility:hidden;width:'+menuwidth+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div></div>')

function getposOffset(what, offsettype){
  var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
  var parentEl=what.offsetParent;
  while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
  }
  return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
  if (ie4||ns6){
    dropmenuobj.style.left=dropmenuobj.style.top="-500px";
  }
  if (menuwidth!=""){
    dropmenuobj.widthobj=dropmenuobj.style;
    dropmenuobj.widthobj.width=menuwidth;
  }
  if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
    obj.visibility=visible;
  }
  else if (e.type=="click"){
    obj.visibility=hidden;
  }
}

function iecompattest(){
  return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function clearbrowseredge(obj, whichedge){
  var edgeoffset=0;
  if (whichedge=="rightedge"){
    var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15;
    dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;
    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure){
      edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth;
    }
  }
  else{
    var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset;
    var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
    dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
      edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight;
      if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) {
        edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge;
      }
    }
  }
  return edgeoffset;
}

function populatemenu(what){
  if (ie4||ns6){
    dropmenuobj.innerHTML=what.join("");
  }
}


function dd(obj, e, menucontents, menuwidth){
  if (window.event) event.cancelBubble=true;
  else if (e.stopPropagation) e.stopPropagation();
  clearhidemenu();
  dropmenuobj=document.getElementById? document.getElementById("dmdiv") : dmdiv;
  populatemenu(menucontents);

  if (ie4||ns6){
    showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth);
    dropmenuobj.x=getposOffset(obj, "left");
    dropmenuobj.y=getposOffset(obj, "top");
    dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px";
    dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px";
  }

  return clickreturnvalue()
}

function clickreturnvalue(){
  if (ie4||ns6) return false;
  else return true;
 }

function contains_ns6(a, b) {
  while (b.parentNode){
    if ((b = b.parentNode) == a){
      return true;
    }
  }
  return false;
}

function dynamichide(e){
  if (ie4&&!dropmenuobj.contains(e.toElement)){
    dh();
  }
  else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)){
    dh();
  }
}

function hidemenu(e){
  if (typeof dropmenuobj!="undefined"){
    if (ie4||ns6){
      dropmenuobj.style.visibility="hidden";
    }
  }
}

function dh(){
  if (ie4||ns6){
    delayhide=setTimeout("hidemenu()",disappeardelay);
  }
}

function clearhidemenu(){
  if (typeof delayhide!="undefined"){
    clearTimeout(delayhide);
  }
}

if (hidemenu_onclick=="yes"){
  document.onclick=hidemenu;
}
function open_popup(page_name)
{
  window.open("/" + page_name,"newWin","top=5,left=5,toolbars=no,maximize=no,resizable=no,width=440,height=400,location=no,scrollbars=yes");
}


$(document).ready(function(){
	function checkPass(){
		if($('#password').val() !='')
			$('#password').css('background-image', 'url(/img/bg_login_textbox.gif)');
		else
			$('#password').css('background-image', 'url(/img/pass_tbox_back.gif)');
	}
	
	$('#email').blur(function(){
		if($(this).val() == '')
			$('#email').css('background-image', 'url(/img/uname_tbox_back.gif)');
		else
			$('#email').css('background-image', 'url(/img/bg_login_textbox.gif)');		
		checkPass();
	});

	$('#password').blur(function(){checkPass()});
	
	$('#email, #password').focus(function(){$(this).css('background-image', 'url(/img/bg_login_textbox.gif)');});
	
    if(!$('#stbox').val()) $('#stbox').css('background-image', 'url(/img/search_tbox_back.gif)');
    $("#stbox").focus(function () {
       $('#stbox').css('background-image', 'none');
    });

    $("#stbox").blur(function () {
      if(!$('#stbox').val()) $('#stbox').css('background-image', 'url(/img/search_tbox_back.gif)');
    });

     $("#stbox").click(function() {
              if($(this).val())
       {
        $(this).focus();
        $(this).select();
       }
          });

    if(!$('#email').val()) $('#email').css('background-image', 'url(/img/uname_tbox_back.gif)');
    if(!$('#password').val()) $('#password').css('background-image', 'url(/img/pass_tbox_back.gif)');




});
jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}

$(document).ready(function() {
    $("a.fe_popup").click(function() {
      $("#feIframe").html('<iframe frameborder="0" width="635" height="355" src="'+$(this).attr('href')+'" ></iframe>');
      $("#feWindow").center();
      $("#feWindow").fadeIn(1000);
    });
    $("span#closeFEWindow").click(function() {
      $("#feWindow").fadeOut(700);
    });
})

