//-- BEGIN from the external rc.js 

var ext='.html';
var breadCpop = '/modules/bread/breadcrumb';

function gg(url)  { document.location.href= uenosln(url)                    }
function goN($url){ var win =  window.open($url, '_blank','');return false; }


//-- END from the external rc.js

function Go(hasOld,cat_id) {
  var key = document.orderform.orderselect.options[document.orderform.orderselect.selectedIndex].value;
  var ref;
  if(hasOld) {  var showold = document.orderform.showold.value;  }

  // set the correct href
  if (key == "popular") {
    ref = 'reviews.php?id=' + cat_id + '&level=items&sort=popular&page=0';
    if(hasOld){ref += '&showold=' + showold;}
    location.href = ref;
  }
  else if (key == "name") {
    ref = 'reviews.php?id=' + cat_id + '&level=items&sort=name&page=0';
    if(hasOld){ref += '&showold=' + showold;}
    location.href = ref;
  }
  else if(key == "price") {
    ref = 'reviews.php?id=' + cat_id + '&level=items&sort=price&page=0';
    if(hasOld){ref += '&showold=' + showold;}
    location.href = ref;
  }
  else {
    if (key == "rating") {
      ref = 'reviews.php?id=' + cat_id + '&level=items&sort=rank';
      if(hasOld){ref += '&showold=' + showold;}
      location.href = ref;
    }
    else {
      ref = 'reviews.php?id=' + cat_id + '&level=items&attr_type_id='+key;
      if(hasOld){ref += '&showold=' + showold;}
      location.href = ref;
    }
  }
}

function getById(id) { return document.getElementById?document.getElementById(id):(document.all?document.all(id):null); }

function addbookmark(host,url,title){
  var bookmarkurl="http://" + host + url;
  var bookmarktitle="ReviewCentre.com: " + title;
  if (document.all){
    window.external.AddFavorite(bookmarkurl,bookmarktitle);
  }
}

function hideDiv(id) {
  getById(id).style.visibility = "hidden";
  getById(id).style.display = "none";
}

function showDiv(id) {
  getById(id).style.visibility = "visible";
  getById(id).style.display = "inline";
}

function yyz(tag,kwd) {
  var a = 'uk.ask.com/ar?qsrc=999&l=dis&siteid=41627901&gc=1&q=';
  var win = window.open("http://" +a + kwd, '_blank','');
  return false;
}

// decide whether or not to display the images
function showImage(cat_id, sort, ord, page, Img, onBrand, onPrice, onF1, onF2, onF3){
  var ref = '/reviews.php?id=' + cat_id + '&page='+page+'&level=items&sort='+sort+'&ord='+ord;
  if(Img=='1') ref += '&categShowImg=1';
  else ref += '&categShowImg=-1';
  if (onBrand == "" && onPrice== "" && onF1== "" && onF2== "" && onF3== "" )    location.href = ref;
  else {
    if (onBrand != "") ref += '&brand=' + onBrand ;
    if( onPrice != "" )  ref += '&price=' + onPrice ;
    ref += '&filters=';
    if(onF1 != "" ) ref += '/1-' + onF1 ;
    if(onF2 != "" ) ref += '/2-' + onF2 ;
    if(onF3 != "" ) ref += '/3-' + onF3 ;
    location.href = ref;
  }
}


// Links to the page given by a splitted URL.
// The arguments are the tokens forming the splitted URL.
function noslink(){
  var url = '';
  for (i = 0; i < arguments.length; i++) {
    url = url + arguments[i];
  }
  document.location.href= uenosln(url);
}
function noslinknw() {
  var url = '';
  for (i = 0; i < arguments.length; i++) {
    url = url + arguments[i];
  }
  var win = window.open(uenosln(url));
}
function uenosln(url) {
  u = new String(url);
  u = u.replace(/%3D/g,"=");
  u = u.replace(/%26/g,"&");
  u = u.replace(/%3F/g,"?");
  u = u.replace(/%2F/g,"/");
  u = u.replace(/%2C/g,",");
  return u;
}
function recclick(e){
var d= new Date();d.setTime(d.getTime() + 10);
var s=0,y=0,x=0;if(e.pageX){x=e.pageX;y=e.pageY;if(e.clientY){s=y-e.clientY;}}
else if(e.clientX){x=e.clientX+document.body.scrollLeft;if
(document.documentElement.scrollTop){s=document.documentElement.scrollTop;}else{s=document.body.scrollTop;}y=e.clientY+s;}
document.cookie = 'RCCLICK=X'+x+'Y'+y+'S'+s+'P'+encodeURIComponent(window.location.href)+' ;path=/; domain='+rcCfg.COOKIE_HOST+'; ';
}

if (rcCfg.REDIRECT_UNKNOWN){
  if (!location.href.match(/reviewcentre.com/)){ top.location.href = 'http://www.reviewcentre.com';}
}


function unf() {
  tabdataInit();
  if(top.location != location) { top.location.href = location.href;     }
  document.cookie = 'RCCLICK= ;expires=Fri, 27 Jul 2001 02:47:11 UTC ;path=/; domain='+rcCfg.COOKIE_HOST+'; ';
  var a = document.getElementsByTagName('body');
  for (var i=0;a[i];i++){if(a[i].addEventListener){a[i].addEventListener('click',recclick,true);}
    else {a[i].attachEvent('onclick',recclick);}
  }

}


//---------- mouse ver for prices ------//
function tabdataInit() {
  var tables = document.getElementsByTagName('table');
  for (var t=0; t<tables.length; t++) {
    if ('prices'==tables[t].className) {
      var rows = document.getElementsByTagName('tr');
      for (var i = 0; i < rows.length; i++) {
        rows[i].onmouseover = function() {
          this.className += ' hilite';
        }
        rows[i].onmouseout = function() {
          this.className = this.className.replace('hilite', '');
        }
      }
    }
  }
}

function modelPrice(url){
  goN(url);
}

var bdv = null;
var bn_rn = new String (Math.random());
var clk_count = 0;
function bnc(nm) {
  if(nm != null && nm.length > 0 && nm.charAt(0) != '_') {
    clk_count++;
    im = new Image();
    im.src = '/bnc_'+nm+'.gif?i='+bn_rn+'.'+clk_count;
  }
}
function bnd(nm) {
  if(nm != null && nm.length > 0 && nm.charAt(0) != '_') {
    clk_count++;
    imd = new Image();
    imd.src = '/bnd_'+nm+'.gif?i='+bn_rn+'.'+clk_count;
  }
}

function writeReview($topic_id, $topic_name, $cat_id, $cat_name, $item_id, $item_desc){
  window.location =  "/add.php?insert_level=reviews&topic_id="+$topic_id+"&item_id="+$item_id+"&cat_id="+$cat_id+"&topic_name="+$topic_name+"&cat_name="+$cat_name+"&item_desc="+$item_desc;
}


function goTo($link){
  window.location =  $link;
}

function onBrowseSubmit(theForm) {
  var categ=theForm.browse_menu.options[theForm.browse_menu.selectedIndex].value;
   if(categ== "-1"){
     window.alert("Please make a selection from the drop down menu");
     return false;
   }
}
function aHd(n){
  var i,f,t = getById('asrtsl');var e;

  if(!t){ return;  }
  f = true;
  for(i=0;i<n;i++){
    e = getById('asrsl' + i);
    if (e){
      e.style.display = 'none';
    }
    else {
      f = false;
    }
  }
  if (!getById('asrsl' + i)){
    f = false;
  }
  dd = document.createElement('dd');
  for (i=0;i< n;i++){
    n2 = getById('esc_' + (i+4));
    if (n2){
      clNd(dd);
      f = true;
      //set section=1 - RIGHT
      n2.innerHTML= n2.innerHTML.replace(/pos=4/g,"pos=14");
      n2.innerHTML= n2.innerHTML.replace(/pos=5/g,"pos=15");
      n2.innerHTML= n2.innerHTML.replace(/pos=6/g,"pos=16");
      n2.innerHTML= n2.innerHTML.replace(/s=2/g,"s=1");
      for (j=0;j< n2.childNodes.length;j++){
        dd.appendChild(n2.childNodes[j].cloneNode(true));
      }
      dd.style.display = '';
      t.appendChild(dd.cloneNode(true));
    }
  }
  f = false;
  if (!f){getById('ppc-side').style.display = 'none';}
}

function aBt(n){var oit;var tr  = aCT(n);if (!tr){return;}
oit = getById('waffle-ppc');   if (oit){
  tr.className = 'withMPU';
  oit.parentNode.appendChild(tr);showDiv("waffle-mpu");   return;}
oit = getById('tabs_bc');      if (oit){oit.parentNode.insertBefore(tr,oit.nextSibling);return;}
oit = getById('waffle');       if (oit){oit.appendChild(tr);return;}
oit = getById('sh1');          if (oit){oit.parentNode.insertBefore(tr,oit.nextSibling);return;}
oit = getById('fwaffle');      if (oit){oit.appendChild(ctEl('p'));oit.appendChild(tr);return;}
oit = getById('forum');        if (oit){oit.insertBefore(tr,oit.childNodes[2]);return;}
oit = getById('add');          if (oit){oit.parentNode.insertBefore(tr,oit);return;}
oit = getById('mn_ctc');       if (oit){oit.insertBefore(tr,oit.childNodes[2]);return;}

}


function ctEl(n){return document.createElement(n); }
function ctTx(t){return document.createTextNode(t);}
function clNd(n){while (n.firstChild){n.removeChild(n.firstChild);}}

function aCp(){
  var i,tt,dd,li,j,k;
  var o = getById('asrtsl');
  var t = getById('mn_ctc');
  var d2 = ctEl('div');
  var h = ctEl('h3');  var l = ctEl('ul');
  var tm;

  d2.setAttribute('id','ppc-top');
  h.appendChild(ctTx('Sponsored Links'));
  l.setAttribute('id','asc2');

  while (o.childNodes.length > 4){

    dd = o.lastChild;
    li = ctEl('li');
    for (j=0;dd.childNodes[j];j++){
      if (dd.getAttribute('id')){
        var s = dd.getAttribute('id');
        li.setAttribute('id','esc_' + (s.substring(5,s.length)*1 + 1));
      }
      li.appendChild(dd.childNodes[j].cloneNode(true));
    }
    if (l.firstChild){
      l.insertBefore(li,l.firstChild);
    }
    else {
      l.appendChild(li);
    }
    o.removeChild(dd);
  }

  for (i=4;i>0;i--){
    if (o.childNodes[i]){
      dd = o.childNodes[i];
      li = ctEl('li');
      for (j=0;dd.childNodes[j];j++){
        li.appendChild(dd.childNodes[j].cloneNode(true));
      }
      if (l.firstChild){
        l.insertBefore(li,l.firstChild);
      }
      else {
        l.appendChild(li);
      }
    }
  }

  d2.appendChild(h);
  d2.appendChild(l);
  t.appendChild(d2);
  //t.appendChild(n);
}


function aCT(n){
  var m,t1,t2,tm,k,l;
  var n1,n2,n3,i,j;
  d=ctEl('div');
  m=ctEl('div');
  d.setAttribute('id','ppc-top');
  m.setAttribute('id','waffle-ppc');
                                              t2 = ctEl('h3');
                                              t2.setAttribute('id','asc');
  if (n != 1){
    t2.appendChild(ctTx('Sponsored Links'));
  }
  else {
    t2.appendChild(ctTx('Sponsored Link'));
  }
  d.appendChild(t2);

  n1 = getById('asc2');
  n2 = document.createElement('ul');
  if (!n1){return false;}

  for (i=0;i<n && n1.childNodes[i];i++){
    tm = n1.childNodes[i].cloneNode(true);
    for (k=tm.childNodes.length-1;k>-1;k--){
      if (tm.childNodes[k].tagName && tm.childNodes[k].tagName.toLowerCase() == 'a'){
        for (l=tm.childNodes[k].childNodes.length-1;l>-1;l--){
          if (!tm.childNodes[k].childNodes[l].tagName || tm.childNodes[k].childNodes[l].tagName.toLowerCase() !='strong'){
            tm.childNodes[k].removeChild(tm.childNodes[k].childNodes[l]);
          }
        }
      }
    }
    n2.appendChild(n1.childNodes[i].cloneNode(true));
 }
  //set section=5 - CENTRE TOP
  n2.innerHTML= n2.innerHTML.replace(/pos=1/g,"pos=11");
  n2.innerHTML= n2.innerHTML.replace(/pos=2/g,"pos=12");
  n2.innerHTML= n2.innerHTML.replace(/pos=3/g,"pos=13");
  n2.innerHTML= n2.innerHTML.replace(/s=2/g,"s=5");

  d.appendChild(n2);
  m.appendChild(d);
  return m;
}

//decide whether or not to display the images
function showImagePrices(showImg, url){
  ref = url+'&pricesShowImg='+showImg;
  location.href = ref;
}

/*
* if async is false you must call the call back function right after loadXMLDoc returns
*/
function loadXMLDoc(url,callback,data,async) {

  if(window.XMLHttpRequest) {
    try { req = new XMLHttpRequest();
    }
    catch(e) { req = false; }
  }
  else if(window.ActiveXObject) {
    try { req = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
      try { req = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e) {req = false;
      }
    }
  }
  if(req) {
    if (async){
      req.onreadystatechange = callback;
    }
    if (data){
      req.open("POST", url, async);
      req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
      req.send(data);
    }
    else {
      req.open("GET", url, async);
      req.send("");
    }
  }
  return req;// for thread(!) safe work
}

var req   = false;
var pic_max = false;
var pic_prf = false;

function pInit(m,p,n){
  var i,t;
  pic_max = m;
  pic_prf = p;
  if (m == 1){
    return;
  }
  if (n != 1){
    var nm = getById(pic_prf + '_num');
    if (nm){
      nm.value = n;
    }
  }
  for (i=(n+1);i<=m;i++){
    t = getById(p+'sp_'+i);
    if (t){
      t.style.display = 'none';
    }
  }
}

function pSend(){
  var e = getById('email');
  if (e){
    if (!e.value || !e.value.length){
      alert('Email address must be filled in');
      return false;
    }
  }
  return true;
}

function pShow(i){
  var t = getById(pic_prf + 'sp_' + i);
  var n = getById(pic_prf + '_num');
  var j;
  if (t && n){
    t.style.display = '';
    n.value = i;
    for (j=1;j<i;j++){
      t = getById(pic_prf + 'add_' + j);
      if (t){t.style.display = 'none';}
    }
  }
}

function pHide(i){
  var t = getById(pic_prf + 'sp_' + i);
  var n = getById(pic_prf + '_num');
  var a = getById(pic_prf + 'add_' + (i-1));
  var j;
  if (t && n){
    t.style.display = 'none';
    n.value         = i;
    if (a){
      a.style.display = '';
    }

    for (j=i;j<=pic_max;j++){
      t = getById(pic_prf + 'sp_' + j);
      if (t){t.style.display = 'none';}
    }
  }
}


// ---- BEGIN Expand TP2 Shopping Prices ---------

function expandTP2Prices(thisItem, kwd, catID, itemID, itemDesc, sect, isfirst){
  var url = 'http://'+rcCfg.HTTP_HOST+'/modules/prices-merged-html.php?l_items=20&kwd='+encodeURIComponent(kwd)+'&sect=' +sect+'&thisItem=' +thisItem+'&cat_id=' +catID+'&item_id=' +itemID+'&item_desc='+encodeURIComponent(itemDesc)+'&isfirst='+isfirst;
  url = appendTopicToUrl( url, sect );
  req = loadXMLDoc(url, pricesWriteTP2, false, true);
}

function contractTP2Prices(thisItem, kwd,catID, itemID, itemDesc, sect, isfirst){
  var url = 'http://'+rcCfg.HTTP_HOST+'/modules/prices-merged-html.php?l_items=3&kwd='+encodeURIComponent(kwd)+'&sect=' +sect+'&thisItem=' +thisItem+'&cat_id=' +catID+'&item_id=' +itemID+'&item_desc='+encodeURIComponent(itemDesc)+'&isfirst='+isfirst;
  url = appendTopicToUrl( url, sect );
  req = loadXMLDoc(url, pricesWriteTP2, false, true);
}

function appendTopicToUrl( sUrl, sSection ) {
  var oRegExp =/topic(\d)+/;
  if ( oRegExp.test( sSection ) ) {
	  sUrl+="&topic_id="+sSection.replace(/topic/,'');
  }
  return sUrl;
}

function pricesWriteTP2(){
	  if (req.readyState == 4){
	    if (req.status == 200){
	    //   PRdoc = req.responseXML;
//	       pricesTP2FillData(PRdoc);
	      PRdoc = req.responseText;
	      var contentId = 'pr1';
	      
	      var pit = getById(contentId);
	      if(!pit){    
	    	  contentId = 'related-products';
	    	  pit = getById(contentId);
	    	  if(!pit){   
	    		  return;
	    	  }
	      }
	      if ( contentId != 'related-products' ) {
	    	  pit.innerHTML=PRdoc;
	      } else {
	    	  var innerRelatedProducts = $("<div>"+PRdoc+"</div>").find('#related-products');
	    	  if ( innerRelatedProducts.length > 0) {
    	    	  var MinimiseOrMinimiseLinkContainer = $("<div>"+PRdoc+"</div>").find('ul:last>li').html();
	              $('#related-products').html(innerRelatedProducts);
	              $("#related li:contains('more related')").html(MinimiseOrMinimiseLinkContainer);
	              $("#related li:contains('Minimise')").html(MinimiseOrMinimiseLinkContainer);
	    	  } else {
	    		  
	    		  $('#related-products').html( PRdoc );
	    		  var MinimiseOrMinimiseLinkContainerOnPage  = $("#related li:contains('more related')");
	    		  if (MinimiseOrMinimiseLinkContainerOnPage.length == 0) {
	    			  MinimiseOrMinimiseLinkContainerOnPage = $("#related li:contains('Minimise')");
	    		  }
	    		  var MinimiseLinkContainerInResponse  = $('p.more'); 
	    		  MinimiseOrMinimiseLinkContainerOnPage.html( MinimiseLinkContainerInResponse.html() );
	    		  MinimiseLinkContainerInResponse.html('');
	    		  
	    	  }
	          
	      }
	      var objScroll = getById(contentId);
	      scroll(0, objScroll.offsetTop);

	    }
	  }
	}

function getOffsetTop(element) {
  var curtop = 0;
  if(element.offsetParent) {
    do {
      curtop += element.offsetTop;
    } while(element = element.offsetParent);
  }
  return curtop;
}

function pricesTP2FillData(PRdoc){
  var results   = PRdoc.getElementsByTagName('results');
  var kwd       = results[0].getAttribute('kwd');
  var sect      = results[0].getAttribute('sect');
  var type      = results[0].getAttribute('result_type');
  var expanded  = results[0].getAttribute('expanded');
  var thisItem  = results[0].getAttribute('thisItem');
  var featuredItem      = results[0].getAttribute('featuredItem');
  var featuredItemDesc  = results[0].getAttribute('featuredItemDesc');
  var featuredCat       = results[0].getAttribute('featuredCat');

  var items = PRdoc.getElementsByTagName('item');
  var limit  ='';
  if(expanded == 1) limit = items.length;
  else  limit=3;
  if (items && items.length){
    var di = ctEl('div');
    di.className = 'f-o';
    var list = ctEl('ul');

    for (var ni = 0; ni <  limit; ni++) {
      var el = ctEl('li');
      var star = ctEl('div');
      var item_id  = items[ni].getAttribute('item_id');
      if(thisItem>0 &&  item_id > 0 &&  item_id ==thisItem){
        star.className = 't_star';
      }
      el.appendChild(star);

      var dst = ctEl('strong');
      dst.innerHTML = items[ni].getAttribute('pr_name');
      el.appendChild(dst);

      var im = ctEl('img');

  if(items[ni].getAttribute('pr_img')){
    var img = items[ni].getAttribute('pr_img');
    if(img.indexOf('no_image_100X100')>0 ){
      im.setAttribute('src', 'images/rc_no_image_c.gif');
      im.className = 'none';
    }
    else{
      im.setAttribute('src', items[ni].getAttribute('pr_img'));
    }
  }
  im.setAttribute('alt', "");
  el.appendChild(im);

  var offers =  items[ni].getElementsByTagName('offer');
  var ol = ctEl('ol');
  var lim_off = 3;
  if(expanded == 1){
    var lim_off = 5;
  }
  var l_off=  Math.min(lim_off, offers.length);

  var hasBest=0;
  for (var oi = 0; oi < l_off; oi++) {
    var featured = offers[oi].getAttribute('trusted');
    if(featured*1 >0) {}
    else featured  = offers[oi].getAttribute('featured');

    ol.appendChild(PRtp2l(offers[oi], hasBest, featured, featuredCat));
    if(hasBest == 0 && featured*1 > 0){
      hasBest = 1;
    }
  }
  el.appendChild(ol);
  list.appendChild(el);
    }

    di.appendChild(list);

    dp = ctEl('p');
    ap = ctEl('a');

    if(expanded == 1){
      dp.setAttribute('id','less');
      ap.setAttribute('href','#');
      ap.setAttribute('onclick','contractTP2Prices(\''+thisItem+'\',\''+kwd+'\', \''+featuredCat+'\',\''+featuredItem+'\',\''+featuredItemDesc+'\',\''+sect+'\'); return false;');
      ap.innerHTML ='Minimise';
    }
    else {
      dp.setAttribute('id','more');
      ap.setAttribute('onclick','expandTP2Prices(\''+thisItem+'\',\''+kwd+'\',  \''+featuredCat+'\',\''+featuredItem+'\',\''+featuredItemDesc+'\', \''+sect+'\'); return false;');
      ap.setAttribute('href','#');
      ap.innerHTML =  'View '+(items.length-3)+ ' more';
    }
    dp.appendChild(ap);
    di.appendChild(dp);

    var pit = getById('pr1');
    if(!pit){    return;  }
    pit.innerHTML='';
    pit.appendChild(di);
    var objScroll = getById('pr1');
    scroll(0, objScroll.offsetTop);
  }
}

function  PRtp2l(s, hasBest, featured, featuredCat){
  var li = ctEl('li');
  var a  = ctEl('a');

  if(hasBest ==0 &&  featured == 1){
    var sp_star = ctEl('span');
    sp_star.className = 'b_star';
    a.appendChild(sp_star);
  }
  a.setAttribute('href',s.getAttribute('url'));
  a.setAttribute('target','_blank');

  var sp = ctEl('span');
  if (s.getAttribute('price')) {
    var price = 0;
    price = s.getAttribute('price')*1;
    var thePrice = price.toFixed(2);
    if(featuredCat == 8){
      if(price  == 0 ) sp.innerHTML = 'Free handset' ;
      else sp.innerHTML = '&pound;' + thePrice ;

    }
    else {
      sp.innerHTML = '&pound;' + thePrice;
    }
  }
  a.appendChild(sp);
  a.innerHTML=  a.innerHTML + " "+  s.getAttribute('merchant');

  li.appendChild(a);
  return li;
}

// ---- END Expand Right Shopping Prices ------------

/*
----  ajax stuff ------------
_pal_show_form - display price alert form
_pal_create - create price alert
_pal_ch -  on price alert form switch alert type
_pal_display - handles alert ajax return

_rar_show_form -  show the review rating form
_rar_submit -  submit the review rating form
_rar_display - display the ajax return for rating review

-- ajax login - register stuff
pajx_login -- manages ajax login/register stuff
pajx_login_display -- handles ajax login return

-- tell a friend stuff
_taf_show_form - show the tell a friend form
_taf_show_cancel - performs the functionality for exiting
_taf_show_submit - submits the email and displays comfirmation / error
_taf_show_display - handles tell a friend ajax return

-- bookmarks stuff
_bookmarks_show_form - show the bookmarks form
_bookmarks_show_cancel - cancels out of the bookmarks AJAX form
_bookmarks_show_display - handles bookmark AJAX return

*/
var bookmarks_req;
function _bookmarks_show_form_item(level,itemID) {
  getById('bookmarks_details').style.zIndex = '99';
  bookmarks_req = false;
  var get_params = '';
  var get_page = '/modules/ajax/bookmarks.php?level='+level+'&item_id='+itemID;
  bookmarks_req = loadXMLDoc(get_page + get_params, _bookmarks_display, false, false);
  _bookmarks_display();
}

function _bookmarks_show_form_cat(level,topicID) {
  getById('bookmarks_details').style.zIndex = '99';
  bookmarks_req = false;
  var get_params = '';
  var get_page = '/modules/ajax/bookmarks.php?level='+level+'&topic_id='+topicID;
  bookmarks_req = loadXMLDoc(get_page + get_params, _bookmarks_display, false, false);
  _bookmarks_display();
}

function _bookmarks_cancel_item(Level, itemID) {
  getById('bookmarks_details').style.zIndex = '99';
  var get_params = '?do=cancel&level='+Level+'&item_id='+itemID;
  var get_page = '/modules/ajax/bookmarks.php';
  bookmarks_req = false;
  bookmarks_req = loadXMLDoc(get_page + get_params, _bookmarks_display, false, false);
  _bookmarks_display();
}

function _bookmarks_cancel_cat(Level, topicID) {
  getById('bookmarks_details').style.zIndex = '99';
  var get_params = '?do=cancel&level='+Level+'&topic_id='+topicID;
  var get_page = '/modules/ajax/bookmarks.php';
  bookmarks_req = false;
  bookmarks_req = loadXMLDoc(get_page + get_params, _bookmarks_display, false, false);
  _bookmarks_display();
}

function _bookmarks_display() {
  if (bookmarks_req.readyState == 4) {
    if (bookmarks_req.status == 200) {
      result = bookmarks_req.responseText;
      var dv = getById('bookmarks_details');
      dv.innerHTML = null;
      dv.innerHTML = result;

    } else {
      alert('There was a problem with the request.');
    }
  }
}

function _return_false() {
}

var taf_req;
function _taf_show_form(itemID) {
  getById('taf_details').style.zIndex = '99';
  taf_req = false;
  var get_params = '';
  var get_page = '/modules/ajax/tellafriend.php?item_id='+itemID;
  taf_req = loadXMLDoc(get_page + get_params, _taf_display, false, false);
  _taf_display();
}
function _taf_cancel(itemID) {
  getById('taf_details').style.zIndex = '99';
  var el = getById('item_id');
  taf_req = false;
  var get_params = '?do=cancel';
  get_params += '&item_id=' + el.value;
  var get_page = '/modules/ajax/tellafriend.php';
  taf_req = loadXMLDoc(get_page + get_params, _taf_display, false, false);
  _taf_display();
}
function _taf_submit_loggedout(bSave) {
  getById('taf_details').style.zIndex = '99';
  var el = getById('ajx_taf_input');
  var el2 = getById('item_id');
  var get_params = '?do=submit';
  get_params += '&email=' + el.value;
  get_params += '&item_id=' + el2.value;
  taf_req = false;
  var get_page = '/modules/ajax/tellafriend.php';
  taf_req = loadXMLDoc(get_page + get_params, _taf_display, false, false);
  _taf_display();
}
function _taf_submit(bSave) {
  getById('taf_details').style.zIndex = '99';
  var el = getById('ajx_taf_input');
  var el2 = getById('item_id');
  var el3 = getById('ajx_taf_name');
  var get_params = '?do=submit';
  get_params += '&email=' + el.value;
  get_params += '&item_id=' + el2.value;
  get_params += '&user_name=' + el3.value;
  taf_req = false;
  var get_page = '/modules/ajax/tellafriend.php';
  taf_req = loadXMLDoc(get_page + get_params, _taf_display, false, false);
  _taf_display();
}
function _taf_display() {
  if (taf_req.readyState == 4) {
    if (taf_req.status == 200) {
      result = taf_req.responseText;
      var dv = getById('taf_details');
      dv.innerHTML = null;
      dv.innerHTML = result;

    } else {
      alert('There was a problem with the request.');
    }
  }
}


var pal_req;
function _pal_show_form(item_id,aid) {
  getById('pal_details').style.zIndex = '99';
  var get_params = '?do=create_form&item_id=';
  get_params += item_id;
  get_params += '&aid='+aid;
  get_params += '&rnd=' + Math.random();
  var get_page = '/modules/ajax/priceajax.php';
  pal_req = false;
  pal_req = loadXMLDoc(get_page + get_params, _pal_display, false, false);
  _pal_display();
}
function _pal_create(bSave) {
  var el = getById('ajx_pal_chk');
  var el2 = getById('ajx_pal_inp');
  var eli = getById('ajx_pal_item_id');
  var aid = getById('ajx_pal_aid');
  var get_params = '?';
  if(bSave) {
    get_params += 'do=create_alert&on_change=';
    if(el.checked) {
      get_params += 'yes';
    } else {
      get_params += 'no';
    }
    get_params += '&aid=' + aid.value;
    get_params += '&price=' + el2.value;
    get_params += '&item_id=' + eli.value;
  } else {
    get_params += 'do=cancel';
    get_params += '&item_id=' + eli.value;
  }

  get_params += '&rnd=' + Math.random();
  var get_page = '/modules/ajax/priceajax.php';
  pal_req = false;
  pal_req = loadXMLDoc(get_page + get_params, _pal_display, false, false);
  _pal_display();
}
function _pal_ch() {
  var el = getById('ajx_pal_chk');
  var elt = getById('ajx_pal_chk_txt');
  var el2 = getById('ajx_pal_inp');
  var el2t = getById('ajx_pal_inp_txt');
  if(el.checked) {
    el2.disabled = true;
    el2t.className = 'pal_dead';
    elt.className = 'pal_live';
  } else {
    el2.disabled = false;
    el2t.className = 'pal_live';
    elt.className = 'pal_dead';
  }
}
function _pal_display() {
  if (pal_req.readyState == 4) {
    if (pal_req.status == 200) {
      result = pal_req.responseText;
      var dv = getById('pal_details');
      dv.innerHTML = null;
      dv.innerHTML = result;
      focus_price();
    } else {
      alert('There was a problem with the request.');
    }
  }
}


var watch_req;
function _watch_create(itemID) {

  var get_params = '?';
  if(itemID) {
    get_params += 'do=create_watch&item_id='+itemID;
  }

  var get_page = '/modules/ajax/watchajax.php';
  watch_req = false;
  watch_req = loadXMLDoc(get_page + get_params, _watch_display, false, false);

  getById('watch-this-item').innerHTML = 'This item has been added to <a href="/myreviewcentre.html">your review centre</a></em>';

  _watch_display(false);


}

function _watch_delete(itemID) {

  var get_params = '?';
  if(itemID) {
    get_params += 'do=delete_watch&item_id='+itemID;
  }

  var get_page = '/modules/ajax/watchajax.php';
  watch_req = false;
  watch_req = loadXMLDoc(get_page + get_params, _watch_display, false, false);

  _watch_display(true);
}

function _watch_display(reload) {

  if (watch_req.readyState == 4) {
    if (watch_req.status == 200) {
      if(reload) {
        window.location = un_anchor(window.location);
      } else {
        var dv = getById('__watch_details__');
        dv.innerHTML = null;
        dv.innerHTML = result;
      }
    } else {
      alert('There was a problem with the request.');
    }
  }
}


function editPoll(){
  getById('options').style.zIndex = '99';
  options_req = false;
  var get_params = '';
  var get_page = '/modules/ajax/tellafriend.php';
  options_req = loadXMLDoc(get_page + get_params, _options_display, false, false);
  _options_display();

}

// -----------------------------
var log_req;
function topDraw(lg,ah,myrc_h,myrc_t,lgin,reg,hlp_h,hlp_t){
 var tar = getById('tlogin_details');
 var li  = ctEl('li');
 var hr  = ctEl('a');
 var ul  = ctEl('ul');
 var h2,l2;
 var st  = myrc_t.replace(/&lt;/g,"<");
 st      = st.replace(/&gt;/g,">");
 myrc_t  = st.replace(/&amp;/g,"&");

 if (!tar){ return; }

 li.className = 'fl';
 ul.setAttribute('id','link_r');
 hr.setAttribute('rel','nofollow');

 if (lg){
  if (!ah){
   h2 = hr.cloneNode(true);
   h2.setAttribute('href',myrc_h);
   h2.innerHTML = myrc_t;
   l2 = li.cloneNode(true);
   l2.appendChild(h2);
   ul.appendChild(l2.cloneNode(true));
  }
  else {
   l2 = li.cloneNode(true);
   l2.innerHTML = myrc_t;
   ul.appendChild(l2.cloneNode(true));
  }
 }
 else {
  h2 = hr.cloneNode(true);
  h2.setAttribute('href','javascript:pajx_login(1,\'tlogin_details\',\'toplogin\');');
  h2.appendChild(ctTx(lgin));
  l2 = li.cloneNode(true);
  l2.appendChild(h2);
  ul.appendChild(l2.cloneNode(true));

  h2 = hr.cloneNode(true);
  h2.setAttribute('href','javascript:pajx_login(3,\'tlogin_details\',\'toplogin\');');
  h2.appendChild(ctTx(reg));
  l2 = li.cloneNode(true);
  l2.appendChild(h2);
  ul.appendChild(l2.cloneNode(true));
 }
 h2 = hr.cloneNode(true);
 h2.setAttribute('href',hlp_h);
 h2.className = 'help';
 h2.setAttribute('title','Need help?');
 h2.appendChild(ctTx(hlp_t));
 l2 = li.cloneNode(true);
 l2.appendChild(h2);
 ul.appendChild(l2);
 tar.appendChild(ul);
}



var pajx_active_type = '';
var pajx_display_el_id;
var pajx_extra;
var pajx_first = false;

function pajx_login(state,display_el_id,type) {
        pajx_login2(state,display_el_id,type,'');
}
function pajx_login2(state,display_el_id,type,extra) {
  var get_page = '/modules/ajax/loginajax.php';
  if(pajx_active_type.length > 0 && pajx_active_type != type) {
    /* Another login box is open!
                        we need to close the other login box! */
        var gpr = '?do=cancel';
    gpr += '&ajx_extra='+pajx_extra;
    gpr += '&type='+pajx_active_type;
    gpr += '&tdid='+pajx_display_el_id;
    gpr += '&rnd=' + Math.random();
    log_req = false;
    log_req = loadXMLDoc(get_page + gpr, pajx_login_display, false, false);
    pajx_login_display(); /* box should now be closed */
                              }
  pajx_active_type = type;
  pajx_display_el_id = display_el_id;
  pajx_extra = extra;
  var get_params = '';
  if(state == 1) {
    get_params += '?do=display_login';
    get_params += '&ajx_extra='+extra;

  } else if(state == 2) {
    var un = getById('ajx_pal_un');
    var pw = getById('ajx_pal_pw');
    get_params += '?do=login&un='+un.value+'&pw='+pw.value;
    get_params += '&ajx_extra='+extra;

  } else if(state == 3) {
    if (!pajx_first){
      try {
        pageTracker._trackPageview("/G1/Registration/Registration_Form");
        secondTracker._trackPageview("/G1/Registration/Registration_Form");
      } catch(e) {}
      pajx_first = true;
    }
    get_params += '?do=display_register&un=';
    get_params += '&ajx_extra='+extra;

  } else if(state == 4) {
    var un = getById('user_name');
    var pw = getById('passwd');
    var em = getById('email');
    var agree = getById('consent');
    get_params += '?do=register&un=' + un.value;
    get_params += '&pw=' + pw.value;
    get_params += '&em=' + em.value;
    //get_params += '&emcf='+emcf.value;
    //  get_params += '&loc='+loc.value;
    //if(nwsl.checked){get_params += '&newsl=1';}else{get_params += '&newsl=0';}
    //if(remb.checked){get_params += '&remb=1';}else{get_params += '&remb=0';}
    if(agree.checked){get_params += '&agree=1';}else{get_params += '&agree=0';}
    get_params += '&ajx_extra='+extra;
  }
 else if(state == 5) {
    get_params += '?do=display_reminder';
    get_params += '&ajx_extra='+extra;
  } else if(state == 6) {
    var email = getById('ajx_rem_email');
    get_params += '?do=send_reminder';
    get_params += '&email=' + email.value;
    get_params += '&ajx_extra='+extra;
  } else {
    get_params += '?do=cancel';
    get_params += '&ajx_extra='+extra;
  }
  get_params += '&type='+type;
  get_params += '&tdid='+display_el_id;
  get_params += '&rnd=' + Math.random();
  log_req = false;

  log_req = loadXMLDoc(get_page + get_params, pajx_login_display, false, false);
  pajx_login_display();
}
function pajx_login_display() {
  if (log_req.readyState == 4) {
    if (log_req.status == 200) {
      result = log_req.responseText;
      if(result == 'RRELOAD') {
        try {
          pageTracker._trackPageview("/G1/Registration/Registration_Complete");
          secondTracker._trackPageview("/G1/Registration/Registration_Complete");
        } catch (e) {}
        window.location = un_anchor(window.location);
      }
      else if (result == 'RELOAD') {
        window.location = un_anchor(window.location);
      }
      else if(result.slice(0,11) == 'RATE_REVIEW') {
        rajx_review(result.slice(14),result.slice(11,13));
      }
      else if(result.slice(0,5) == 'OTHER') {
        window.location = result.slice(6);
      }

      else {
        var dv = getById(pajx_display_el_id);
        dv.innerHTML = '';
        dv.innerHTML = result;
        focus_login();
      }
    } else {
      alert('There was a problem with the request.');
    }
  }
}
// Submit: TNG.
var sub_opened = false;
var sub_req    = false;
var sub_sub    = false;

function rev_sub(src){ common_sub(src,'/modules/add_rev.php'); }
function com_sub(src){ common_sub(src,'/modules/add_com.php'); }
function rte_sub(src){ common_sub(src,'/modules/add_rte.php'); }

function common_sub(src,tar){
  var req;
  var f = getById(src);
  if (f){
    var t = sub_collect(f,'');

    if (sub_sub){
      t += 'override_submit='+encodeURIComponent(sub_sub);
    }
    sub_sub = false;
    req = loadXMLDoc(tar,common_sub_ret, t, false);
    if (!req){
      f.submit();
      return;
    }
    if (req && req.status && req.status == 200){
      //      try
 {
        if(req.getResponseHeader && req.getResponseHeader('X-SubmissionCat') && req.getResponseHeader('X-SubmissionCat').length){
          pageTracker._trackEvent(req.getResponseHeader('X-SubmissionCat'), req.getResponseHeader('X-SubmissionAct'), req.getResponseHeader('X-SubmissionLabel'));
          // alert('++'+req.getResponseHeader('X-SubmissionCat')+req.getResponseHeader('X-SubmissionAct')+req.getResponseHeader('X-SubmissionLabel'));

        }
 } //catch(e) {}

      if(req.getResponseHeader && req.getResponseHeader('X-Register') && req.getResponseHeader('X-Register').length){
        try {
          pageTracker._trackPageview(req.getResponseHeader('X-Register'));
          secondTracker._trackPageview(req.getResponseHeader('X-Register'));
          alert(req.getResponseHeader('X-Register'));
        } catch(e2) {}
      }
      if(req.responseText == 'RELOAD') {
        window.location = un_anchor(window.location);
      }
      else if(req.responseText.slice(0,5) == 'OTHER') {
        window.location = req.responseText.slice(6);
      }
      else if (req.responseText.slice(0,6) == 'CLOSE'){
        sub_close();

      }
      else {
        if (!sub_open(req.responseText,tar)){
            // If we can't open the div, coz' something's not right, give up and
            // submit the form..
          f.submit();
          return;
        }
      }
      req = false;
    }
  }
  return false;
}

function common_sub_ret(){}

function sub_open(txt,tar){
  var ajxD = getById('ajax_add');
  var ajxH = getById('ajax_hlp');

  if (window.scroll) { window.scroll(0,0);  }
  else if (document.body && (document.body.scrollLeft || document.body.scrollTop)){  document.body.scrollTop=0;  }
  else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){  document.documentElement.scrollTop=0;  }

  if (!sub_opened){
    hideDropDowns('');
    var fdeH,divW,divH,zInd = 100000;
    var fdeD,ajxW = 600;
    var ajxWH = 200;//the width of help window
    var ajxT = 25;
    var ajxHL = 30; // help left
    var hTxt = '';

    if (window.scroll) { window.scroll(0,0);  }
    else if (document.body && (document.body.scrollLeft || document.body.scrollTop)){  document.body.scrollTop=0;  }
    else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){  document.documentElement.scrollTop=0;  }
    else { return false;  }

    if (window.innerHeight && window.scrollMaxY) { fdeH = window.innerHeight + window.scrollMaxY; }
    else if (document.body.scrollHeight > document.body.offsetHeight) {fdeH = document.body.scrollHeight;}
    else { fdeH = document.body.offsetHeight; }

    if (window.innerWidth){  divH = window.innerHeight;  divW = window.innerWidth;   }
    else if (document.all){ divH = document.body.clientHeight; divW = document.body.clientWidth;  }
    else { return false;  }
    if(divW<900) divW=900;
    fdeD = getById('fadeout');
    if (!fdeD || !ajxD || !ajxH){
      return false;
    }
    hTxt = sub_get_help(tar);

    fdeD.style.display    = 'block';
    ajxD.style.width      = ajxW + 'px';
    ajxD.style.top        = ajxT + 'px';
    ajxD.style.zIndex     = (zInd+110);
    ajxD.style.visibility = 'visible';
    ajxD.style.display    = 'block';
    fdeD.style.height     = fdeH + 'px';
    if (hTxt){
      ajxH.style.left       = ajxHL+'px';
      ajxD.style.left       = Math.round((divW  - ajxW +ajxWH +ajxHL)/2) + 'px';
      ajxH.style.width      = ajxWH+'px';
      ajxH.style.top        = ajxT + 'px';
      ajxH.style.zIndex     = (zInd+110);
      ajxH.style.visibility = 'visible';
      ajxH.style.display    = 'block';
    }
    else {
      ajxD.style.left       = Math.round((divW - ajxW)/2) + 'px';
    }
    sub_opened      = true;
  }
  ajxD.innerHTML        = txt;

  return true;
}

function sub_close(){
  var fdeD = getById('fadeout');
  var ajxD = getById('ajax_add');
  var ajxH = getById('ajax_hlp');
  while (ajxD.childNodes.length){ajxD.removeChild(ajxD.firstChild);}
  while (ajxH.childNodes.length){ajxH.removeChild(ajxH.firstChild);}
  fdeD.style.display = 'none';
  ajxD.style.display = 'none';
  ajxH.style.display = 'none';
  sub_opened = false;
  showDropDowns('') ;
}

function sub_get_help(tar){
  sub_req = loadXMLDoc(tar,sub_get_help_add,'help=help', true);
  if (sub_req){
    return true;
  }
  return false;
}

function sub_get_help_add(){
  if (sub_req && sub_req.readyState && sub_req.readyState == 4){
    if (sub_req.status && sub_req.status == 200){
      getById('ajax_hlp').innerHTML = sub_req.responseText;
    }
    sub_req = false;
  }
}



// get all the inputs from the form (element object) src
function sub_collect(src,inp){
  if (src.childNodes && src.childNodes.length > 0){
    for (var i = 0;i<src.childNodes.length;i++){
      if (src.childNodes[i] && src.childNodes[i].tagName){
        inp = sub_collect(src.childNodes[i],inp);
      }
    }
  }
  if (src.tagName){
    var t = src.tagName.toLowerCase();
    if (t == 'select'){
      inp += src.name + '=' + encodeURIComponent(src.options[src.selectedIndex].value) + '&';
    }
    else if (t == 'textarea'){
      inp += src.name + '=' + encodeURIComponent(src.value) + '&';
    }
    else if (t == 'input'){
      if (src.type == 'radio' || src.type == 'checkbox'){
        if (src.checked){
          inp += src.name + '=' + encodeURIComponent(src.value) + '&';
        }
      }
      else {
        inp += src.name + '=' + encodeURIComponent(src.value) + '&';
      }
    }

  }
  return inp;
}

  /*if we are refreshing a page that has been sub-navved with a
   #hash we cannot do window.location = window.location, we must
   do window.location = location - hash;
  */
function un_anchor(location) {
  var http_val = location.href;
  var hpos = http_val.indexOf('#');
  if(hpos != -1) {
    http_val = http_val.substr(0,hpos);
  }
  return http_val;
}
 /*
  Focus on user name if present [i.e. showing login]
  Need to cope with login, reminder and register screens
  with same element names - so order of testing is delicate
*/
function focus_login() {
  var fel = getById('ajx_rem_email');
  if(fel != null) {
    fel.focus();
  } else {
    fel = getById('ajx_pal_un');
    if(fel != null) {
      fel.focus();
    } else {
      fel = getById('username');
      if(fel != null) {
        fel.focus();
      }
    }
  }
}
/* focus price alert on price input*/
function focus_price() {
  var iel = getById('ajx_pal_inp');
  if(iel != null && ! iel.disabled) {
    iel.focus();
  } else {
    var cel = getById('ajx_pal_chk');
    if(cel != null && ! cel.disabled) {
      cel.focus();
    }
  }
}

var rr_req;
function request_review(ID, level) {
  getById('req_div').style.display = 'none';
  getById('req_div2').style.zIndex = '99';
  var get_page = '/modules/ajax/requestreview.php';
  var get_params = '?id='+ID+'&level='+level;
  rr_req = false;
  rr_req = loadXMLDoc(get_page + get_params, rr_display, false, false);
  rr_display();
}

function rr_display() {
  if (rr_req.readyState == 4) {
    if (rr_req.status == 200) {
      result = rr_req.responseText;
      if(result == 'RELOAD') { window.location = un_anchor(window.location); }
      else {
        var dv = getById('req_div2');
        dv.innerHTML = null;
        dv.innerHTML = result;
        focus_login();
      }
    }
    else { alert('There was a problem with the request.'); }
  }
}

function rr_submit(topicID, catID) {
  getById('req_div2').style.zIndex = '99';
  var el = getById('txtItem').value;
  var get_params = '?do=submit&topic_id='+topicID+'&cat_id='+catID+'&item_desc='+el;
  var get_page = '/modules/ajax/requestreview.php';
  rr_req = false;
  rr_req = loadXMLDoc(get_page + get_params, rr_display, false, false);
  rr_display();
}

function rr_cancel() {
  getById('req_div').style.display = '';
  getById('req_div2').style.zIndex = '99';
  rr_req = false;
  var get_params = '?do=cancel';
  var get_page = '/modules/ajax/requestreview.php';
  rr_req = loadXMLDoc(get_page + get_params, rr_display, false, false);
  rr_display();
}

function validate_required(field){
  with(field){
    if(value == null || value == ''){
      var el = getById('topic_id').value;
      var el2 = getById('cat_id').value;
      var get_params = '?do=invalid&topic_id='+el+'&cat_id='+el2;
      var get_page = '/modules/ajax/requestreview.php';
      rr_req = loadXMLDoc(get_page + get_params, rr_display, false, false);
      rr_display();
      //alert('Please enter an Item Description');
      //return false;
    }
    else{ return true; }
  }
}

function validate_req_review_form(form){
  with(form){
    if(validate_required(txtItem) == false){
      txtItem.focus();
      return false;
    }
  }
}


window.onload = unf;

// ---- END Price alerts ajax stuff ------------




// ---- New search form  ------------
function chTxtSearch(wh){
  for (var id = 1;id < 3;id++){
    var div = getById('search-radio'+id+wh);
    var adv = getById('search-advance' + id);
    var ss  = getById('search-section' + id);
    if (adv && wh == 2){
      adv.innerHTML = '<a href="/forum2/search-v3.php">Advanced</a></span>';
    }
    else if (wh == 1 && adv){
      var tt = getById('sti_top' + id); var ts = getById('sti_sel' + id);
      var tx = '<input id="this_topic" name="search_topic_id' + id + '" type="checkbox" ';
      if (ts){ tx += 'checked="checked" '; }
      if (tt){ adv.innerHTML = tx + ' value="' + tt.value + '" />&nbsp;this&nbsp;topic'; }
      else { adv.innerHTML = ''; }
    }
    else if (adv){
      adv.innerHTML = '';
    }
    for(i=1; getById('search-radio'+id+i); i++){
      if (i!=3){
      var elem = getById('search-radio'+id+i);
      if (elem){
        elem.checked = (i == wh);
        elem.parentNode.className = (i == wh) ? 'on' : '';
      }
      }
    }
    if (ss){
      ss.value = wh;
    }
  }
}

function displaySearchRadios(sect,id,inc4){
  var lon = '<label class="on">';
  var lof = '<label>';
  var chk = 'checked="checked" ';
  var txt ='';
  txt  = '<fieldset>';
  txt += (sect == 1) ? lon : lof;
  txt += '<span></span><input type="radio" id="search-radio'+id+'1" name="find-what" value="radio" onclick="chTxtSearch(1)" ';
  txt += (sect == 1) ? chk : '';
  txt += '>Reviews</label>';

  txt += (sect == 2) ? lon : lof;
  txt += '<input type="radio"  id="search-radio'+id+'2" name="find-what" value="radio" onclick="chTxtSearch(2)" ';
  txt += (sect == 2) ? chk : '';
  txt += '>Forums</label>';

  //txt += '<label><input type="radio" id="search-radio'+id+'3"  name="find-what" value="radio" onclick="chTxtSearch(3)">Prices</label>';

  if (inc4 == 1){
    txt += (sect == 4) ? lon : lof;
    txt += '<input type="radio"  id="search-radio'+id+'4" name="find-what" value="radio" onclick="chTxtSearch(4)" ';
    txt += (sect == 4) ? chk : '';
    txt += '>Web</label>';
  }
  txt += '</fieldset>';
  getById('search-radios' + id).innerHTML = txt;
}


// ---- BEGIN New breadcrumb trail  ------------
var brnav_req;
function BreadCRNav(onMenu, menu_id,
                    onTopic, topic_id,
                    onCat, cat_id,
                    onItem, item_id, item_tabs, thisTab,
                    review_id, reviewer, onComment, sPage, sPageID){

return;

  var u = breadCpop+'-write4ajax.php';

  if(onComment == 'undefined')  onComment=0;
  if(sPage == 'undefined')      sPage   = '';
  if(sPageID == 'undefined')    sPageID = 0;
  brnav_req = false;
  return brnav_req = loadXMLDoc(u+'?onMenu='+onMenu+'&menu_id='+menu_id+'&onTopic='+onTopic+'&topic_id='+topic_id+'&onCat='+onCat+'&cat_id='+cat_id+'&onItem='+onItem+'&item_id='+item_id+'&item_tabs='+encodeURIComponent(item_tabs)+'&thisTab=' +encodeURIComponent(thisTab)+'&review_id='+review_id+'&reviewer=' + encodeURIComponent(reviewer)+'&onComment=' + encodeURIComponent(onComment)+'&sPage=' +encodeURIComponent(sPage)+'&sPageID=' +encodeURIComponent(sPageID), writeBreadNav, false, true);
}

function writeBreadNav(){
  brText='';
  var br = getById('bct_new');
  if (brnav_req.readyState == 4){
    if (brnav_req.status == 200){
      brText = brnav_req.responseText;
      br.innerHTML = brText;
    }
  }
}

var  brPop_req;
var  brCache = new Array();
function BreabCr(type, type_id, thisID, nextID, onPage, cssID, forumCatID, forumID){
  BreabCrCom(cssID);
  return brPop_req = loadXMLDoc(breadCpop + '-pop.php?type='+encodeURIComponent(type)+'&type_id=' + type_id+'&thisID=' + encodeURIComponent(thisID)+'&nextID='+encodeURIComponent(nextID)+'&onPage='+encodeURIComponent(onPage)+'&forumCatID='+encodeURIComponent(forumCatID)+'&forumID='+encodeURIComponent(forumID), writeBreadPop, false, true);
}
function BreabNCr(cssId,level,menuId, topId,catId){
  BreabCrCom(cssId);
  return brPop_req = loadXMLDoc(breadCpop + '-news.php?l=' + level + '&m=' + menuId + '&t='+topId+'&c='+catId, writeBreadPop, false, true);
}
function BreabCrCom(cssID){
  var u = breadCpop+'-pop.php';
  if (brCache[cssID] && brCache[cssID].length){
    writeBreadPop(0,brCache[cssID]);
    return;
  }
  getById('breadCr').setAttribute('tar',cssID);
  return u;
}
function writeBreadPop(f,t){
  if (f == 0 && t != false){
    getById('breadCr').innerHTML = t;
    return;
  }
  brText='';
  var br = getById('breadCr');
  br.innerHTML = '<div class="shade-r"><div class="border"><div class="content"><img src="'+rcCfg.CORE_IMG_BASE+'/loading.gif" /><div class="both"/></div></div></div></div>';
  if (req.readyState == 4){
    if (req.status == 200){
         br.innerHTML =  req.responseText;
         brCache[br.getAttribute('tar')] = req.responseText;
         br.removeAttribute('tar');
    }
  }
}


//------------------
var disappeardelay=50;
var hidemenu_onclick="yes";

var ie4=document.all;
var ns6=getById&&!document.all;

function expandBCT(obj, e, cssID,  type, type_id, thisID, nextID, onPage, forumCatID, forumID ){
  var b = expandBRtop(obj,e);
  if (ie4||ns6){
    expandBRcom(obj,e,b);
    BreabCr(type, type_id, thisID,  nextID, onPage, cssID, forumCatID, forumID);
  }
  return clickreturnvalue();
}

function expandNBCT(obj, e, cssID, level, menuId, topId, catId){
  var b = expandBRtop(obj,e);
  if (ie4||ns6){
    expandBRcom(obj,e,b);
    BreabNCr(cssID,level, menuId, topId, catId);
  }
  return clickreturnvalue();
}

function expandBRtop(obj,e){
  if (window.event) {
    event.cancelBubble=true;
  }
  else if (e.stopPropagation) e.stopPropagation();
  clearhidemenu();
  breadpopobj= getById('breadCr');
  breadpopobj.innerHTML = '';
  breadpopobj.style.display='block';
  return breadpopobj;
}

function expandBRcom(obj,e,breadpopobj){
  if (e.type=="click" && breadpopobj.visibility=="hidden" || e.type=="mouseover"){
    breadpopobj.style.visibility="visible";
  }
  else if (e.type=="click"){
    breadpopobj.style.visibility="hidden";
  }

  breadpopobj.y=getposOffset(obj, "top");
  breadpopobj.x=getposOffset(obj, "left");
  breadpopobj.style.top=(obj.offsetParent.offsetTop+obj.offsetHeight+5)+'px';
  // alert( breadpopobj.y+' '+obj.offsetParent.offsetTop);
  //  breadpopobj.style.top=( breadpopobj.y+obj.offsetHeight)+'px';
  breadpopobj.style.left=(breadpopobj.x-clearbrowseredge(obj, "rightedge"))+"px";
}


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 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
breadpopobj.contentmeasure=breadpopobj.offsetWidth
if (windowedge-breadpopobj.x < breadpopobj.contentmeasure)
edgeoffset=breadpopobj.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
breadpopobj.contentmeasure=breadpopobj.offsetHeight
if (windowedge-breadpopobj.y < breadpopobj.contentmeasure){ //move up?
edgeoffset=breadpopobj.contentmeasure+obj.offsetHeight
if ((breadpopobj.y-topedge)<breadpopobj.contentmeasure) //up no good either?
edgeoffset=breadpopobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

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&&!breadpopobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
    if (typeof breadpopobj!="undefined"){
        if (ie4||ns6)
            breadpopobj.style.visibility="hidden";
    }

    for(i = 1; i <=5; i++)      {
        if(getById("menu" + i)){
          getById("menu" + i).className = "bct";
        }
    }
}



function delayhidemenu(){
  if (ie4||ns6){
    delayhide=setTimeout("hidemenu()",disappeardelay);
  }
  //showDropDowns('sel-cat');
}

function clearhidemenu(){
    if (typeof delayhide!="undefined")
        clearTimeout(delayhide);
}

if (hidemenu_onclick=="yes")
    document.onclick=hidemenu;

function resetBCT(Not){
    for(i = 1; i <=5; i++){
      if(i != Not){
        if(getById("menu" + i)){
            getById("menu" + i).className = "bct";
        }
      }
    }
}

// ---- END New breadcrumb trail  ------------

function goH(){  gg('/');}
function goST(id){ var u =  '/sreviews'+id;        gg(u+ext);}
function  goT(id){ var u =  '/consumer_reviews'+id;gg(u+ext);}
function  goC(id){ var u =  '/products'+id;        gg(u+ext);}
function  goI(id){ var u =  '/reviews'+id;         gg(u+ext);}
function  goR(id){ var u =  '/review'+id;          gg(u+ext);}
function goto_expert_shop(kwds) { gg('http://reviewcentre.expertshoppingguide.com/index.php?_ESI=search&kwds='+kwds); }

function show_recent(mouse){
  var div1 = getById('div1').style;
  var divOverall = getById('div_overall').style;
  if(mouse == 'up'){
    div1.display = 'none';
    divOverall.display = '';
  }
  else if(mouse == 'over'){
    div1.display = '';
    divOverall.display = 'none';
  }
}
function sliderGo(base_nm, idx) {
  for(i = 10; i >= 0; i--) {
    el = getById(base_nm+'_'+i);
    if(i <= idx) {
      el.className = 'pipe';
    }
    else {
      el.className = 'pipeend';
    }
    if (getById(base_nm + '_val_' +i)){
      getById(base_nm + '_val_' +i).checked = (i == idx);
    }
    if (getById(base_nm + '_' +i)){
      getById(base_nm + '_' +i).checked = (i == idx);
    }

  }
}


function showDropDowns(id) {
  if(id==''){
    if( document.getElementById('f-filter')) {
      var sort_by = document.getElementById('f-filter');
      sort_by.style.display = 'block';
    }
    if(document.getElementById('sel-cat')){
      var sel_cat = document.getElementById('sel-cat');
      sel_cat.style.display = 'block';
    }
  }
  else{
    if(document.getElementById(id)){
      var sel_cat = document.getElementById(id);
      //      sel_cat.style.display = 'block';
      sel_cat.style.zIndex = 1;
    }
  }
}

function hideDropDowns(id){
 if(id==''){
   if( document.getElementById('f-filter')) {
     var sort_by = document.getElementById('f-filter');
    sort_by.style.display = 'none';
   }
   if(document.getElementById('sel-cat')){
     var sel_cat = document.getElementById('sel-cat');
     sel_cat.style.display = 'none';
   }
 }
 else{
   //   alert('ooo'+id);
   if(document.getElementById(id)){
     var sel_cat = document.getElementById(id);
     // sel_cat.style.display = 'none';
     sel_cat.style.zIndex = 0;
   }
 }
}


function formCollect(src,inp){
  if (src.childNodes && src.childNodes.length > 0){
    for (var i = 0;i<src.childNodes.length;i++){
      if (src.childNodes[i] && src.childNodes[i].tagName){
        inp = formCollect(src.childNodes[i],inp);
      }
    }
  }
  if (src.tagName){
    var t = src.tagName.toLowerCase();
    if (t == 'select'){
      inp += src.name + '=' + encodeURIComponent(src.options[src.selectedIndex].value) + '&';
    }
    else if (t == 'textarea'){
      inp += src.name + '=' + encodeURIComponent(src.value) + '&';
    }
    else if (t == 'input'){
      if (src.type == 'radio' || src.type == 'checkbox'){
        if (src.checked){
          inp += src.name + '=' + encodeURIComponent(src.value) + '&';
        }
      }
      else {
        inp += src.name + '=' + encodeURIComponent(src.value) + '&';
      }
    }
  }
  return inp;
}

var flagsAsc = new Array();

function setAscFlag(name,val){
  for (var i = 0;i<flagsAsc.length;i++){
    if (flagsAsc[i][0] == name){
      flagsAsc[i][1] = val;
      return;
    }
  }
  flagsAsc[flagsAsc.length] = new Array(name,val);
}

function getAscFlag(name){
  for (var i = 0;i<flagsAsc.length;i++){
    if (flagsAsc[i][0] == name){
      return flagsAsc[i][1];
    }
  }
  return false;
}

function clrAllAscFlags(){
  flagsAsc = new Array();
}

function newWatchCB(){}

function newWatch(id){
 if (!getById('watch-this-item')){
   return true;
 }
 var req = loadXMLDoc('/modules/ajax/new_watch.php?id='+id,newWatchCB,false,false);
 if (req && req.status && req.status == 200 && req.readyState && req.readyState == 4){
   if (req.responseText != 'error'){
     getById('watch-this-item').innerHTML = req.responseText;
     return false;
   }
 }
 return true;
}

// Reg form validation

var regFormReqs = new Array();

function regFormValid(name){
  var u = '/modules/ajax/register-valid.php';
  var p = 'nm=' + encodeURIComponent(name) + '&' + formCollect(getById('submit_review'),u);
  for (var i = 0;i < regFormReqs.length;i++){
    if (regFormReqs[i][1] == name){
      regFormReqs[i][2] = false;
    }
  }
  var req = loadXMLDoc(u,regFormValidCallback,p,true);
  regFormReqs[regFormReqs.length] = new Array(req,name,true);
}

function regFormValidCallback(){
  var c;
  for (var i = 0;i < regFormReqs.length; i++){
    try {
      c = false;
      if (regFormReqs[i] && regFormReqs[i][0] && regFormReqs[i][0].readyState){
        c = true;
        if (regFormReqs[i][0].readyState == 4){
          c = false;
          if (regFormReqs[i][0].status == 200){
            regFormValidExec(regFormReqs[i][1],regFormReqs[i][0].responseXML);
          }
        }
      }
      regFormReqs[i][2] = c;
    }
    catch(e){
      regFormReqs[i][2] = false;
    }
  }
  c = true;
  while (c){
    c = false;
    for (var i = 0;i< regFormReqs.length;i++){
      if (!regFormReqs[i][2]){
        if (regFormReqs[i][0] && regFormReqs[i][0].abort){
          regFormReqs[i][0].abort();
        }
        c = true;
        regFormReqs.splice(i,1);
        i = regFormReqs.length + 999;
      }
    }
  }
}

function regFormValidExec(name,xml){
  if (xml && xml.documentElement){
    for (var i = 0;i< xml.documentElement.childNodes.length;i++){
      var c = xml.documentElement.childNodes[i];
      var t = c.nodeName;
      var e = (c.attributes[0] && c.attributes[0].nodeValue) ? c.attributes[0].nodeValue : 'noerror';
      if (e == 'noerror'){
        regFormClearError(t);
      }
      else {
        regFormOneError(t,e);
      }
    }
  }
}

function regFormClearRow(t,e){
  var d = getById(t + '_row');
  if (d){
    while (d.className.indexOf('error-row') != -1){
      d.className = d.className.replace(/error-row/,'');
    }
  }
  getById(t + '_error').className = 'sdn error';
  getById(t + '_ok').className = 'sdn';
  getById(t + '_err').innerHTML = '';
}



function regFormOneError(t,e){
  var d = getById(t + '_row');
  if (d.className.indexOf('error-row') == -1){
    getById(t + '_row').className += ' error-row';
  }
  getById(t + '_error').className = 'error';
  getById(t + '_ok').className = 'sdn';
  getById(t + '_err').innerHTML = e;
}

function regFormClearError(t){
  var d = getById(t + '_row');
  if (d){
    while (d.className.indexOf('error-row') != -1){
      d.className = d.className.replace(/error-row/,'');
    }
  }
  getById(t + '_error').className = 'sdn error';
  getById(t + '_ok').className = '';
}

function regFormCheck(id,err){
  var c = getById(id);
  if (c && err){
    if (c.checked){
      regFormClearError(id);
    }
    else {
      regFormOneError(id,err);
    }
  }
}
/*
 ### jQuery Star Rating Plugin v3.10 - 2009-03-23 ###
 * Home: http://www.fyneworks.com/jquery/star-rating/
 * Code: http://code.google.com/p/jquery-star-rating-plugin/
 *
        * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 ###
*/

/*# AVOID COLLISIONS #*/
;if(window.jQuery) (function($){
/*# AVOID COLLISIONS #*/

        // IE6 Background Image Fix
        if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { }
        // Thanks to http://www.visualjquery.com/rating/rating_redux.html

        // plugin initialization
        $.fn.rating = function(options){
                if(this.length==0) return this; // quick fail

                // Handle API methods
                if(typeof arguments[0]=='string'){
                        // Perform API methods on individual elements
                        if(this.length>1){
                                var args = arguments;
                                return this.each(function(){
                                        $.fn.rating.apply($(this), args);
    });
                        };
                        // Invoke API method handler
                        $.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);
                        // Quick exit...
                        return this;
                };

                // Initialize options for this call
                var options = $.extend(
                        {}/* new object */,
                        $.fn.rating.options/* default options */,
                        options || {} /* just-in-time options */
                );
                // Allow multiple controls with the same name by making each call unique
                $.fn.rating.calls++;

                // loop through each matched element
                this
                 .not('.star-rating-applied')
                        .addClass('star-rating-applied')
                .each(function(){

                        // Load control parameters / find context / etc
                        var control, input = $(this);
                        var eid = (this.name || 'unnamed-rating').replace(/\[|\]/g, '_').replace(/^\_+|\_+$/g,'');
                        var context = $(this.form || document.body);
                       	var raters = context.data('rating');
                        if(!raters || raters.call!=$.fn.rating.calls) raters = { count:0, call:$.fn.rating.calls };
                        var raters = context.data('rating') || { count:0 };
                        var rater = raters[eid];

                        // if rater is available, verify that the control still exists
                        if(rater) control = rater.data('rating');

                        if(rater && control){
                                // add star to control if rater is available and the same control still exists
                                control.count++;

                        }
                        else{
                                // create new control if first star or control element was removed/replaced

                                // Initialize options for this raters
                                control = $.extend(
                                        {}/* new object */,
                                        options || {} /* current call options */,
                                        ($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options */
                                        { count:0, stars: [], inputs: [] }
                                );

                                // increment number of rating controls
                                control.serial = raters.count++;

                                // create rating element
                                rater = $('<span class="star-rating-control"/>');
                                input.before(rater);

                                // Mark element for initialization (once all stars are ready)
                                rater.addClass('rating-to-be-drawn');

                                // Accept readOnly setting from 'disabled' property
                                if(input.attr('disabled')) control.readOnly = true;

                                // Create 'cancel' button
                                rater.append(
                                        control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel + '">' + control.cancelValue + '</a></div>')
                                        .mouseover(function(){
                                                $(this).rating('drain');
                                                $(this).addClass('star-rating-hover');
                                                //$(this).rating('focus');
                                        })
                                        .mouseout(function(){
                                                $(this).rating('draw');
                                                $(this).removeClass('star-rating-hover');
                                                //$(this).rating('blur');
                                        })
                                        .click(function(){
                                         $(this).rating('select');
                                        })
                                        .data('rating', control)
                                );

                        }; // first element of group

                        // insert rating star
                        var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="' + (this.title || this.value) + '">' + this.value + '</a></div>');
                        rater.append(star);

                        // inherit attributes from input element
                        if(this.id) star.attr('id', this.id);
                        if(this.className) { star.addClass(this.className); star.removeClass('flash'); }

                        // Half-stars?
                        if(control.half) control.split = 2;

                        // Prepare division control
                        if(typeof control.split=='number' && control.split>0){
                                var stw = ($.fn.width ? star.width() : 0) || control.starWidth;
                                var spi = (control.count % control.split), spw = Math.floor(stw/control.split);
                                star
                                // restrict star's width and hide overflow (already in CSS)
                                .width(spw)
                                // move the star left by using a negative margin
                                // this is work-around to IE's stupid box model (position:relative doesn't work)
                                .find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' })
                        };

                        // readOnly?
                        if(control.readOnly)//{ //save a byte!
                                // Mark star as readOnly so user can customize display
                                star.addClass('star-rating-readonly');
                        //}  //save a byte!
                        else//{ //save a byte!
                         // Enable hover css effects
                                star.addClass('star-rating-live')
                                 // Attach mouse events
                                        .mouseover(function(){
                                                $(this).rating('fill');
                                                $(this).rating('focus');
                                        })
                                        .mouseout(function(){
                                                $(this).rating('draw');
                                                $(this).rating('blur');
                                        })
                                        .click(function(){
                                                $(this).rating('select');
                                        })
                                ;
                        //}; //save a byte!

                        // set current selection
                        if(this.checked)        control.current = star;

                        // hide input element
                        input.hide();

                        // backward compatibility, form element to plugin
                        input.change(function(){
    $(this).rating('select');
   });

                        // attach reference to star to input element and vice-versa
                        star.data('rating.input', input.data('rating.star', star));

                        // store control information in form (or body when form not available)
                        control.stars[control.stars.length] = star[0];
                        control.inputs[control.inputs.length] = input[0];
                        control.rater = raters[eid] = rater;
                        control.context = context;

                        input.data('rating', control);
                        rater.data('rating', control);
                        star.data('rating', control);
                        context.data('rating', raters);
  }); // each element

                // Initialize ratings (first draw)
                $('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');

                return this; // don't break the chain...
        };

        /*--------------------------------------------------------*/

        /*
                ### Core functionality and API ###
        */
        $.extend($.fn.rating, {

                focus: function(){
                        var control = this.data('rating'); if(!control) return this;
                        if(!control.focus) return this; // quick fail if not required
                        // find data for event
                        var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
   // focus handler, as requested by focusdigital.co.uk
                        if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
                }, // $.fn.rating.focus

                blur: function(){
                        var control = this.data('rating'); if(!control) return this;
                        if(!control.blur) return this; // quick fail if not required
                        // find data for event
                        var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
   // blur handler, as requested by focusdigital.co.uk
                        if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
                }, // $.fn.rating.blur

                fill: function(){ // fill to the current mouse position.
                        var control = this.data('rating'); if(!control) return this;
                        // do not execute when control is in read-only mode
                        if(control.readOnly) return;
                        // Reset all stars and highlight them up to this element
                        this.rating('drain');
                        this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover');
                },// $.fn.rating.fill

                drain: function() { // drain all the stars.
                        var control = this.data('rating'); if(!control) return this;
                        // do not execute when control is in read-only mode
                        if(control.readOnly) return;
                        // Reset all stars
                        control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');
                },// $.fn.rating.drain

                draw: function(){ // set value and stars to reflect current selection
                        var control = this.data('rating'); if(!control) return this;
                        // Clear all stars
                        this.rating('drain');
                        // Set control value
                        if(control.current){
                                control.current.data('rating.input').attr('checked','checked');
                                control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on');
                        }
                        else
                         $(control.inputs).removeAttr('checked');
                        // Show/hide 'cancel' button
                        control.cancel[control.readOnly || control.required?'hide':'show']();
                        // Add/remove read-only classes to remove hand pointer
                        this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');
                },// $.fn.rating.draw

                select: function(value){ // select a value
                        var control = this.data('rating'); if(!control) return this;
                        // do not execute when control is in read-only mode
                        if(control.readOnly) return;
                        // clear selection
                        control.current = null;
                        // programmatically (based on user input)
                        if(typeof value!='undefined'){
                         // select by index (0 based)
                                if(typeof value=='number')
                         return $(control.stars[value]).rating('select');
                                // select by literal value (must be passed as a string
                                if(typeof value=='string')
                                        //return
                                        $.each(control.stars, function(){
                                                if($(this).data('rating.input').val()==value) $(this).rating('select');
                                        });
                        }
                        else
                                control.current = this[0].tagName=='INPUT' ?
                                 this.data('rating.star') :
                                        (this.is('.rater-'+ control.serial) ? this : null);

                        // Update rating control state
                        this.data('rating', control);
                        // Update display
                        this.rating('draw');
                        // find data for event
                        var input = $( control.current ? control.current.data('rating.input') : null );
                        // click callback, as requested here: http://plugins.jquery.com/node/1655
                        if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event
                },// $.fn.rating.select

                readOnly: function(toggle, disable){ // make the control read-only (still submits value)
                        var control = this.data('rating'); if(!control) return this;
                        // setread-only status
                        control.readOnly = toggle || toggle==undefined ? true : false;
                        // enable/disable control value submission
                        if(disable) $(control.inputs).attr("disabled", "disabled");
                        else                            $(control.inputs).removeAttr("disabled");
                        // Update rating control state
                        this.data('rating', control);
                        // Update display
                        this.rating('draw');
                },// $.fn.rating.readOnly

                disable: function(){ // make read-only and never submit value
                        this.rating('readOnly', true, true);
                },// $.fn.rating.disable

                enable: function(){ // make read/write and submit value
                        this.rating('readOnly', false, false);
                }// $.fn.rating.select

 });

        /*--------------------------------------------------------*/

        /*
                ### Default Settings ###
                eg.: You can override default control like this:
                $.fn.rating.options.cancel = 'Clear';
        */
        $.fn.rating.options = { //$.extend($.fn.rating, { options: {
                        cancel: 'Cancel Rating',   // advisory title for the 'cancel' link
                        cancelValue: '',           // value to submit when user click the 'cancel' link
                        split: 0,                  // split the star into how many parts?

                        // Width of star image in case the plugin can't work it out. This can happen if
                        // the jQuery.dimensions plugin is not available OR the image is hidden at installation
                        starWidth: 16//,

                        //NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!
                        //half:     false,         // just a shortcut to control.split = 2
                        //required: false,         // disables the 'cancel' button so user can only select one of the specified values
                        //readOnly: false,         // disable rating plugin interaction/ values cannot be changed
                        //focus:    function(){},  // executed when stars are focused
                        //blur:     function(){},  // executed when stars are focused
                        //callback: function(){},  // executed when a star is clicked
 }; //} });

        /*--------------------------------------------------------*/

        /*
                ### Default implementation ###
                The plugin will attach itself to file inputs
                with the class 'multi' when the page loads
        */
        $(function(){ 
                      $('#inner-product-rating input[type=radio].star').rating({callback: function(l,v){document.getElementById('prf-1').submit();}});
                      $('input[type=radio].star').rating();
                   });
       $(function(){ 
                      $('#wrap-ratings .sub-row .star label').css('display', 'none');
                      $('#wrap-ratings .sub-row .big-star label').css('display', 'none');
                      $('#inner-product-rating .star label').css('display','none');
                             
                    });


/*# AVOID COLLISIONS #*/
})(jQuery);
/*# AVOID COLLISIONS #*/



function scrollBoxObj(){ this.timer = ''; this.scrollWindow = 'scrollWindow'; }
scrollBoxObj.prototype.up = function(){ var ajaxLeft = document.getElementById(this.scrollWindow);  ajaxLeft.scrollTop = ajaxLeft.scrollTop - 5; }
scrollBoxObj.prototype.down = function(){  var ajaxLeft = document.getElementById(this.scrollWindow);   ajaxLeft.scrollTop = ajaxLeft.scrollTop + 5; }
scrollBoxObj.prototype.startScroll= function(direction){ this.timer = setInterval("scrollBox." + direction + "()", 1); }
scrollBoxObj.prototype.stopScroll = function(){    clearInterval(this.timer);}
function imageAjaxObj(){ this.xmlHttpRequestObj = '';  this.ajaxImageBox = 'ajaxImage';}
imageAjaxObj.prototype.getAjaxRequestObj = function(){
 try{
  this.xmlHttpRequestObj = new XMLHttpRequest();
 }catch(e){
  try{
   this.xmlHttpRequestObj = new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
   try{
    this.xmlHttpRequestObj = new ActiveXObject("Microsoft.XMLHTTP");
   }catch(e){
    return false;
   }
  }
 }
}

imageAjaxObj.prototype.getImg = function(item,image){
    with(document){
        this.getAjaxRequestObj();
    
        getElementById(this.ajaxImageBox).innerHTML =  '<div id="ajaxLoading"><img  src="images/ajaxLoader.gif" alt="" /><br/>Loading Image</div>';
    
        this.xmlHttpRequestObj.onreadystatechange=handleAjaxResponse= function(){
        
            if((imageAjax.xmlHttpRequestObj.readyState==4) && (imageAjax.xmlHttpRequestObj.status==200)){
                getElementById(imageAjax.ajaxImageBox).innerHTML =  imageAjax.xmlHttpRequestObj.responseText;
            
            }else if((imageAjax.xmlHttpRequestObj.readyState==4) && (imageAjax.xmlHttpRequestObj.status!=200)){
            
            getElementById(imageAjax.ajaxImageBox).innerHTML = 'Error';
            }
        };
        this.xmlHttpRequestObj.open('get','modules/ajax/imagegallery.php?itemid='+ parseInt(item) +'&imageid='+parseInt(image),true);
    
        this.xmlHttpRequestObj.send(null);//send null coz ie is bad
    }
}
//Object instantiation

var scrollBox = new scrollBoxObj();
var imageAjax = new imageAjaxObj();



// we actually count on characters (excluding spaces) rather than words now.
// leaving the word count in there in case it is needed at a later point in time.
function doWordCount(id,txt){

  var numWords = document.getElementById(id).value.split(" ").length; 

  // copy the current string
  var currentString = document.getElementById(id).value;

  // remove all blanks from it
  currentString = currentString.replace(/\s*/g, ""); // replace all blanks

  // count the chars
  var numChars = currentString.length;

  if( numChars >= 500  ){
    $("span#progress-bar").removeClass().addClass('excellent').html('excellent');
    $("#review-hints-help").html("Top reviewer! <i>Hint: Have you included the product or service name in the review?</i>");
  }
  
  if( numChars <= 499 ){
    $("span#progress-bar").removeClass().addClass('good').html('good');
    $("#review-hints-help").html("That's great. <i>Hint: What would you have liked to know before you made your purchase?</i>");
  }
              
  if( numChars <= 249 ){
    $("span#progress-bar").removeClass().addClass('average').html('average');
    $("#review-hints-help").html("You're getting there. <i>Hint: Think about what you liked and didn't like about it</i>");
  }          
  
  if( numChars <= 99 ){
    $("span#progress-bar").removeClass().addClass('poor').html('poor');
    $("#review-hints-help").html("Keep writing. <i>Hint: How would you describe the product or service to family and friends?</i>");
  }
           
  if( numChars < 1 ){
    $("span#progress-bar").removeClass().html('no ' + txt + ' has been entered');
    $("#review-hints-help").text("");
  }

}

$(function(){
    //hides the default label for non-js viewers
    $("div#wrap-question-details .inner-row>label").addClass('rm');
    
    //appends the html for the word count bar to the end of the inner row div
    if (document.getElementById('your-thoughts')){
      $("div#wrap-question-details .inner-row").append("<div id='word-count'><span>Length of review:</span><span id='progress-bar'>no words have been entered</span></div>"); 
      $("#word-count").append('<div id="review-hints-help"></div>');
           
      $("textarea#your-thoughts").keyup(function() { doWordCount('your-thoughts','review'); });
      setTimeout('doWordCount(\'your-thoughts\',\'review\')',10);
    }
    // Don't need word count on comments
    // else if(document.getElementById('your-thoughts-comm')){
    //  $("div#wrap-question-details .inner-row").append("<div id='word-count'><span>Length of comment:</span><span id='progress-bar'>no words have been entered</span></div>");
    //  $("textarea#your-thoughts-comm").keyup(function() { doWordCount('your-thoughts-comm','comment'); });
    //  setTimeout('doWordCount(\'your-thoughts-comm\',\'comment\')',10);
    //}
              
    


});

$('html').addClass('js');

$(window).ready(function() {
 var y,x = window.location.hash.replace(/#/,'');
 if (x && x.length && getById(x)){
  y = $('#'+x).offset();
  window.scrollTo(0,y.top);
 }
});


$(document).ready(function(){ 	
	
	   
	   $("#related-products .clearfix .priceLink").click(function(event){
		   event.stopPropagation();
		   });
           $("#related-products .clearfix h4 a").click(function(event){
		   event.stopPropagation();
		   });
           $("#related-products .clearfix").click(function(event){	   	  
	           window.open($(this).find(".priceLink").attr("href"));
	           });

});