";strHTML+="";strHTML+=indicator_img_html;strHTML+="
";strHTML+="";var docBody=document.getElementsByTagName("body")[0];var ibox=document.createElement("div");ibox.setAttribute("id","ibox");ibox.style.display='';ibox.innerHTML=strHTML;elem.appendChild(ibox);}
var ibox_w_height=0;showIbox=function(url,title,params){doSomethingWithClasses('flash_container', 'visibility', 'hidden');var ibox=getElem('ibox_wrapper');var ibox_type=0;var ibox_footer=getElem('ibox_footer');if(title!=""){ibox_footer.innerHTML=title;}else{ibox_footer.innerHTML=" ";}
var urlString=/\.jpg|\.jpeg|\.png|\.gif|\.html|\.htm|\.php|\.cfm|\.asp|\.aspx|\.jsp|\.jst|\.rb|\.rhtml|\.txt/g;var urlType=url.match(urlString);if(urlType=='.jpg'||urlType=='.jpeg'||urlType=='.png'||urlType=='.gif'){ibox_type=1;}else if(url.indexOf("#")!=-1){ibox_type=2;}else if(urlType=='.htm'||urlType=='.html'||urlType=='.php'||urlType=='.asp'||urlType=='.aspx'||urlType=='.jsp'||urlType=='.jst'||urlType=='.rb'||urlType=='.txt'||urlType=='.rhtml'||urlType=='.cfm'){ibox_type=3;}else{if(params['type']){ibox_type=parseInt(params['type']);}
else{hideIbox();return false;}}
ibox_type=parseInt(ibox_type);switch(ibox_type){case 1:showIndicator();imgPreloader=new Image();imgPreloader.onload=function(){imgPreloader=resizeImageToScreen(imgPreloader);hideIndicator();var strHTML=" ";if(loadCancelled==false){ibox.style.height=imgPreloader.height+'px';ibox.style.width=imgPreloader.width+'px';ibox.style.display="";ibox.style.visibility="hidden";posToCenter(ibox);ibox.style.visibility="visible";setIBoxContent(strHTML);}}
loadCancelled=false;imgPreloader.src=url;break;case 2:var strHTML="";if(params['height']){ibox.style.height=params['height']+'px';}
else{ibox.style.height='280px';}
if(params['width']){ibox.style.width=params['width']+'px';}
else{ibox.style.width='450px';}
ibox.style.display="";ibox.style.visibility="hidden";posToCenter(ibox);ibox.style.visibility="visible";getElem('ibox_content').style.overflow="auto";var elemSrcId=url.substr(url.indexOf("#")+1,1000);var elemSrc=getElem(elemSrcId);if(elemSrc){strHTML=elemSrc.innerHTML;}
setIBoxContent(strHTML);break;case 3:showIndicator();http.open('get',url,true);http.onreadystatechange=function(){if(http.readyState==4){hideIndicator();if(params['height']){ibox.style.height=params['height']+'px';}
else{ibox.style.height='280px';}
if(params['width']){ibox.style.width=params['width']+'px';}
else{ibox.style.width='450px';}
ibox.style.display="";ibox.style.visibility="hidden";posToCenter(ibox);ibox.style.visibility="visible";getElem('ibox_content').style.overflow="auto";var response=http.responseText;setIBoxContent(response);}}
http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");http.send(null);break;default:}
ibox.style.opacity=0;ibox.style.filter='alpha(opacity=0)';var ibox_op_level=10;setIboxOpacity=setOpacity;for(var i=0;i<=ibox_op_level;i++){setTimeout("setIboxOpacity('ibox_wrapper',"+i+")",30*i);}
if(ibox_type==2||ibox_type==3){ibox.onclick=null;getElem("ibox_close_a").onclick=function(){hideIbox();}}else{ibox.onclick=hideIbox;getElem("ibox_close_a").onclick=null;}
return true;}
setOpacity=function(elemid,value){var e=getElem(elemid);e.style.opacity=value/10;e.style.filter='alpha(opacity='+value*10+')';}
resizeImageToScreen=function(objImg){var pagesize=new getPageSize();var x=pagesize.width-100;var y=pagesize.height-100;if(objImg.width>x){objImg.height=objImg.height*(x/objImg.width);objImg.width=x;if(objImg.height>y){objImg.width=objImg.width*(y/objImg.height);objImg.height=y;}}
else if(objImg.height>y){objImg.width=objImg.width*(y/objImg.height);objImg.height=y;if(objImg.width>x){objImg.height=objImg.height*(x/objImg.width);objImg.width=x;}}
return objImg;}
maintPos=function(){var ibox=getElem('ibox_wrapper');var box_w=getElem('ibox_w');var pagesize=new getPageSize();var scrollPos=new getScrollPos();var ua=navigator.userAgent;if(ua.indexOf("MSIE ")!=-1){box_w.style.width=pagesize.width+'px';}
if(ua.indexOf("Opera/9")!=-1){box_w.style.height=document.body.scrollHeight+'px';}
else{box_w.style.height=pagesize.height+scrollPos.scrollY+'px';}
posToCenter(ibox);}
hideIbox=function(){doSomethingWithClasses('flash_container', 'visibility', 'visible'); hideBG();var ibox=getElem('ibox_wrapper');ibox.style.display="none";clearIboxContent();window.onscroll=null;}
posToCenter=function(elem){var scrollPos=new getScrollPos();var pageSize=new getPageSize();var emSize=new getElementSize(elem);var x=Math.round(pageSize.width/2)-(emSize.width/2)+scrollPos.scrollX;var y=Math.round(pageSize.height/2)-(emSize.height/2)+scrollPos.scrollY;elem.style.left=x+'px';elem.style.top=y+'px';}
getScrollPos=function(){var docElem=document.documentElement;this.scrollX=self.pageXOffset||(docElem&&docElem.scrollLeft)||document.body.scrollLeft;this.scrollY=self.pageYOffset||(docElem&&docElem.scrollTop)||document.body.scrollTop;}
getPageSize=function(){var docElem=document.documentElement
this.width=self.innerWidth||(docElem&&docElem.clientWidth)||document.body.clientWidth;this.height=self.innerHeight||(docElem&&docElem.clientHeight)||document.body.clientHeight;}
getElementSize=function(elem){this.width=elem.offsetWidth||elem.style.pixelWidth;this.height=elem.offsetHeight||elem.style.pixelHeight;}
setIBoxContent=function(str){clearIboxContent();var e=getElem('ibox_content');e.style.overflow="auto";e.innerHTML=str;}
clearIboxContent=function(){var e=getElem('ibox_content');e.innerHTML="";}
getElem=function(elemId){return document.getElementById(elemId);}
parseQuery=function(query){var Params=new Object();if(!query)return Params;var Pairs=query.split(/[;&]/);for(var i=0;i= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = createRequestObject();
function updateDiv(div,scriptURL,queryVars,type,notifyBool) { 
  if (connectComplete == 1){
          if (notifyBool == 1) {
            document.getElementById(div).innerHTML = '
";if(loadCancelled==false){ibox.style.height=imgPreloader.height+'px';ibox.style.width=imgPreloader.width+'px';ibox.style.display="";ibox.style.visibility="hidden";posToCenter(ibox);ibox.style.visibility="visible";setIBoxContent(strHTML);}}
loadCancelled=false;imgPreloader.src=url;break;case 2:var strHTML="";if(params['height']){ibox.style.height=params['height']+'px';}
else{ibox.style.height='280px';}
if(params['width']){ibox.style.width=params['width']+'px';}
else{ibox.style.width='450px';}
ibox.style.display="";ibox.style.visibility="hidden";posToCenter(ibox);ibox.style.visibility="visible";getElem('ibox_content').style.overflow="auto";var elemSrcId=url.substr(url.indexOf("#")+1,1000);var elemSrc=getElem(elemSrcId);if(elemSrc){strHTML=elemSrc.innerHTML;}
setIBoxContent(strHTML);break;case 3:showIndicator();http.open('get',url,true);http.onreadystatechange=function(){if(http.readyState==4){hideIndicator();if(params['height']){ibox.style.height=params['height']+'px';}
else{ibox.style.height='280px';}
if(params['width']){ibox.style.width=params['width']+'px';}
else{ibox.style.width='450px';}
ibox.style.display="";ibox.style.visibility="hidden";posToCenter(ibox);ibox.style.visibility="visible";getElem('ibox_content').style.overflow="auto";var response=http.responseText;setIBoxContent(response);}}
http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");http.send(null);break;default:}
ibox.style.opacity=0;ibox.style.filter='alpha(opacity=0)';var ibox_op_level=10;setIboxOpacity=setOpacity;for(var i=0;i<=ibox_op_level;i++){setTimeout("setIboxOpacity('ibox_wrapper',"+i+")",30*i);}
if(ibox_type==2||ibox_type==3){ibox.onclick=null;getElem("ibox_close_a").onclick=function(){hideIbox();}}else{ibox.onclick=hideIbox;getElem("ibox_close_a").onclick=null;}
return true;}
setOpacity=function(elemid,value){var e=getElem(elemid);e.style.opacity=value/10;e.style.filter='alpha(opacity='+value*10+')';}
resizeImageToScreen=function(objImg){var pagesize=new getPageSize();var x=pagesize.width-100;var y=pagesize.height-100;if(objImg.width>x){objImg.height=objImg.height*(x/objImg.width);objImg.width=x;if(objImg.height>y){objImg.width=objImg.width*(y/objImg.height);objImg.height=y;}}
else if(objImg.height>y){objImg.width=objImg.width*(y/objImg.height);objImg.height=y;if(objImg.width>x){objImg.height=objImg.height*(x/objImg.width);objImg.width=x;}}
return objImg;}
maintPos=function(){var ibox=getElem('ibox_wrapper');var box_w=getElem('ibox_w');var pagesize=new getPageSize();var scrollPos=new getScrollPos();var ua=navigator.userAgent;if(ua.indexOf("MSIE ")!=-1){box_w.style.width=pagesize.width+'px';}
if(ua.indexOf("Opera/9")!=-1){box_w.style.height=document.body.scrollHeight+'px';}
else{box_w.style.height=pagesize.height+scrollPos.scrollY+'px';}
posToCenter(ibox);}
hideIbox=function(){doSomethingWithClasses('flash_container', 'visibility', 'visible'); hideBG();var ibox=getElem('ibox_wrapper');ibox.style.display="none";clearIboxContent();window.onscroll=null;}
posToCenter=function(elem){var scrollPos=new getScrollPos();var pageSize=new getPageSize();var emSize=new getElementSize(elem);var x=Math.round(pageSize.width/2)-(emSize.width/2)+scrollPos.scrollX;var y=Math.round(pageSize.height/2)-(emSize.height/2)+scrollPos.scrollY;elem.style.left=x+'px';elem.style.top=y+'px';}
getScrollPos=function(){var docElem=document.documentElement;this.scrollX=self.pageXOffset||(docElem&&docElem.scrollLeft)||document.body.scrollLeft;this.scrollY=self.pageYOffset||(docElem&&docElem.scrollTop)||document.body.scrollTop;}
getPageSize=function(){var docElem=document.documentElement
this.width=self.innerWidth||(docElem&&docElem.clientWidth)||document.body.clientWidth;this.height=self.innerHeight||(docElem&&docElem.clientHeight)||document.body.clientHeight;}
getElementSize=function(elem){this.width=elem.offsetWidth||elem.style.pixelWidth;this.height=elem.offsetHeight||elem.style.pixelHeight;}
setIBoxContent=function(str){clearIboxContent();var e=getElem('ibox_content');e.style.overflow="auto";e.innerHTML=str;}
clearIboxContent=function(){var e=getElem('ibox_content');e.innerHTML="";}
getElem=function(elemId){return document.getElementById(elemId);}
parseQuery=function(query){var Params=new Object();if(!query)return Params;var Pairs=query.split(/[;&]/);for(var i=0;i= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = createRequestObject();
function updateDiv(div,scriptURL,queryVars,type,notifyBool) { 
  if (connectComplete == 1){
          if (notifyBool == 1) {
            document.getElementById(div).innerHTML = ' 
';
          }	  
	  connectComplete = 0;
	  divName = div;
	  handleType = type;
	  http.open("GET", scriptURL + "?" + queryVars, true); 
	  http.send(null); 
	  http.onreadystatechange = handleHttpResponse; 
  } 
}
function addEvent(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType,fn);return r;}else{return false;}}
addEvent(window,'load',init_ibox);
/////////////////////////////////////////////////////////////////////////////////////
// Calendar
function calendarPop(triggerObj, inputBoxId, calType) {
  var inputBox = document.getElementById(inputBoxId);
  var triggerX = findPosX(triggerObj) + 0;
  var triggerY = findPosY(triggerObj) + 20;
  var calendarObj = document.createElement('div');
  var calendarId = 'calendar_pop_' + inputBoxId;
  if (calType == 'monthyear')
    calendarObj.setAttribute('class','calendar_pop_container calendar_pop_monthyear');
  else
    calendarObj.setAttribute('class','calendar_pop_container');
  if (!document.getElementById(calendarId)) {    
    calendarObj.setAttribute('id', calendarId);
    calendarObj.setAttribute('style','left:' + triggerX + 'px;top:' + triggerY + 'px;');
  
    inputBox.parentNode.appendChild(calendarObj);  
    updateDiv(calendarId, 'start.php', 'page_type=calendar_modal&cal_type=' + calType + '&type=modal&input_box=' + inputBoxId, 'html', 0);
  } 
}
function calendarPopDestroy(objId) {
  if (typeof(document.getElementById(objId)) != 'undefined') {
    var obj = document.getElementById(objId);
    obj.parentNode.removeChild(obj);
  }
}
function calenderPopSelect(inputBoxId, day, month, year) {
  var inputBox = document.getElementById(inputBoxId);
  var calendarId = 'calendar_pop_' + inputBoxId;
  var calendarObj = document.getElementById(calendarId);
  inputBox.value = day + '/' + month + '/' + year;
  inputBox.focus();
  window.setTimeout('calendarPopDestroy(\'' + calendarId + '\')', 100);
}
function calendarPopUpdate(calId, action, calType) {
  if (action == 'next') 
    var m = parseInt(document.getElementById('calendar_pop_month').value) + 1;
  else if (action == 'prev') 
    var m = parseInt(document.getElementById('calendar_pop_month').value) - 1;
  else m = document.getElementById('calendar_pop_month').value;
  var y = document.getElementById('calendar_pop_year').value;
  
  if (m > 12) { 
    m = 1;
    y ++;
  }
  else if (m < 1) {
    m = 12;
    y --;
  }
  var inputBoxId = calId.replace('calendar_pop_', '');
  var qs = '&m=' + m + '&y=' + y;
  updateDiv(calId, 'start.php', 'page_type=calendar_modal&cal_type=' + calType + '&type=modal&input_box=' + inputBoxId + qs, 'html', 0);
}
function calendarPopSubmitMY(inputBoxId) {
  var allMonths = new Array(' ', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
  var thisMonth = document.getElementById('calendar_pop_month').value;
  var inputBox = document.getElementById(inputBoxId);
  inputBox.value =  allMonths[parseInt(thisMonth)] + ' ' + document.getElementById('calendar_pop_year').value;
  calendarPopDestroy('calendar_pop_' + inputBoxId);
}
function calendar_show_time_slots(timestamp,type) {
  location.href='#calendar_days';
  updateDiv('calendar_times_container', 'start.php', 'page_type=calendar_times&action=book×tamp=' + timestamp + '&type=' + type, 'html', 1);
}
function update_calendar(action,type) {
  if (action == 'next') m = parseInt(document.getElementById('calendar_list_months').value) + 1;
  else if (action == 'prev') m = parseInt(document.getElementById('calendar_list_months').value) - 1;
  else m = document.getElementById('calendar_list_months').value;
  y = document.getElementById('calendar_list_years').value;
  if (m > 12) { 
    m = 1;
    y ++;
  }
  else if (m < 1) {
    m = 12;
    y --;
  }
  var qs = '&m=' + m + '&y=' + y;
  updateDiv('calendar_container', 'start.php', 'page_type=calendar&action=book&' + 'type=' + type + qs, 'html', 1);
}
function calendar_book(timestamp,type) {
  
  var chosen_date = new Date();
  chosen_date.setTime(timestamp + '000');
  
  chosen_hour = chosen_date.getHours();
  if (chosen_hour > 12) chosen_hour -= 12;
  else if (chosen_hour == 0) chosen_hour = 12;
  
  if (chosen_hour > 11) chosen_suffix = 'AM';
  else chosen_suffix = 'PM';
  
  chosen_mins = chosen_date.getMinutes();
  if (chosen_mins < 10) chosen_mins = '0' + chosen_mins;
  
  var chosen_date_formatted = chosen_date.getDate() + '/' + (chosen_date.getMonth() + 1) + '/' + chosen_date.getFullYear() + ' at ' + chosen_hour + ":" + chosen_mins + ' ' + chosen_suffix;
  if (confirm("You have requested a booking for " + chosen_date_formatted +".\n\nAre you sure you wish to proceed?\n\n ")) {
    updateDiv('calendar_container', 'start.php', 'page_type=calendar&type=' + type + '&action=bookslot&slottime=' + timestamp, 'html', 1);
  }
}
/////////////////////////////////////////////////////////////////////////////////////
// Product review submission
/////////////////////////////////////////////////////////////////////////////////////
// Product review submission
function shopRatingChange(rating, e) {
  
  if (!e) var e = window.event;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement;
  if (targ.nodeType == 3) // defeat Safari bug
    targ = targ.parentNode;
  
  var imgStarOff = targ.src.replace('rate_star.gif', 'rate_star_off.gif');
  var imgStarOn = targ.src.replace('rate_star_off.gif', 'rate_star.gif');
  
  var idParts = targ.id.split('-'); 
  var thisStar = '';
  
  for (var r=1; r <= 5; r++) {
    thisStar = document.getElementById(idParts[0] + '-' + idParts[1] + '-' + r);
    if (r <= rating) thisStar.src = imgStarOn;
    else thisStar.src = imgStarOff;
  }
  
}
function submitRating(e) {
  if (!e) var e = window.event;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement;
  if (targ.nodeType == 3) // defeat Safari bug
    targ = targ.parentNode;
  
  var idParts = targ.id.split('-'); 
  var rating = idParts[2];
  var pid = idParts[1];
  
  window.location.href = '/start.php?page=_product_review&pid=' + pid + '&action=new&rating=' + rating;
}
function submitReview(pid) {
  if (document.getElementById('new_name') != null)
    var name = parseQS(document.getElementById('new_name').value);
  if (document.getElementById('new_location') != null)
    var location = parseQS(document.getElementById('new_location').value);
  var rating = parseQS(document.getElementById('new_rating').value);
  var review = parseQS(document.getElementById('new_review').value); 
  updateDiv('review_form', '/start.php', 'page_type=product_review&pid=' + pid + '&action=new&name=' + name + '&location=' + location + '&rating=' + rating + '&review=' + review, 'html', 1)
}
/////////////////////////////////////////////////////////////////////////////////////
// Validate forms 
function checkform(formname) { 
    /* Tool methods */
    function cf_adderr(o) {
      // create image, add to and colourise the error fields
      var errorIndicator=document.createElement('img');
      errorIndicator.alt=errorAlt;
      errorIndicator.src=errorImg;
      errorIndicator.title=errorTitle;
      o.className=errorClass;
      o.parentNode.insertBefore(errorIndicator,o);
      // Check if there is no error message
      if(!document.getElementById(errorID)) {
        // create errormessage and insert before submit button
        var em = document.createElement('div');
        em.style.textAlign='left';
        em.id = errorID;
        var newp = document.createElement('p');
        newp.innerHTML = errorMsg;
        // clone and insert the error image
        newp.appendChild(errorIndicator.cloneNode(true));
        em.appendChild(newp);
        // find the submit button 
        for(var i=0; i < formname.getElementsByTagName('input').length; i++){
          if(/submit/i.test(formname.getElementsByTagName('input')[i].type)) {
            var sb = formname.getElementsByTagName('input')[i];
            break;
          }
        }
        if(sb) {
          sb.parentNode.insertBefore(em,sb);
        }  
      } 
    }
    function cf_isEmailAddr(str) {
      return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
    }
  if(!document.getElementById || !document.createTextNode || !formname.required) {
    return;  
  }
  else {
    var errorID='error_alert';
    var errorClass='input_error'
    var errorMsg='Some fields are missing or invalid.
Please enter or change the fields marked with a ';
    var errorImg='library/templates/default/resources/form_alert.gif';
    var errorAlt='Error';
    var errorTitle='Please complete this field';
    var reqfields=formname.required.value.split('||');
    // Cleanup old mess
    // if there is an old errormessage field, delete it
    if(document.getElementById(errorID)){
      var em=document.getElementById(errorID);
      em.parentNode.removeChild(em);
    }
    // remove old images and classes from the required fields
    for(var i=0; i < reqfields.length; i++) {
      var f=document.getElementById(reqfields[i]);
      if(!f) continue;
      if(f.previousSibling && /img/i.test(f.previousSibling.nodeName)) {
        f.parentNode.removeChild(f.previousSibling);
      }
      f.className='inputbox';
    }
    // loop over required fields
    for(var i=0; i < reqfields.length; i++) {
      // check if required field is there
      var f=document.getElementById(reqfields[i]);
      if(!f) continue;     
      // test if the required field has an error, 
      // according to its type
      switch(f.type.toLowerCase()) {
        case 'text':
          if(f.value=='' && f.id!='email') cf_adderr(f);
          if(f.id=='email' && !cf_isEmailAddr(f.value)) cf_adderr(f);
          break;
        case 'hidden':  // if hidden, then we're looking for a radio selection instead, using name instead of ID
          var formnameName = formname.name;
          var radioObject = eval('document.' + formnameName + '.' + f.id + ';');
          var radioObjectNum = (radioObject.length == 'undefined') ? 1 : radioObject.length;
          var radioChecked = 0;
          for(var r = 0; r < radioObjectNum; r++) {
            if(radioObject[r].checked) {
              radioChecked = 1;
              break;
            }
          }
          if (radioChecked == 0) cf_adderr(f);
          break;
        case 'textarea':         
          if(f.value=='') cf_adderr(f);
          break;
        case 'checkbox': 
          if(!f.checked) cf_adderr(f);              
          break;
        case 'select-one':
          if(!f.selectedIndex && f.selectedIndex==0) cf_adderr(f);              
          break;
      }
    }
    return !document.getElementById(errorID);
  }
}
function validateField(field, valType, compareField) { 
  var fieldId = field.id;  
  if (typeof valInProgress != 'undefined' && typeof valInProgress[fieldId] != 'undefined') 
    window.clearTimeout(valInProgress[fieldId]);
  else if (typeof valInProgress == 'undefined')
    valInProgress = new Array();
  validationMessage(fieldId, 'wait'); 
  valInProgress[fieldId] = window.setTimeout("actualValidate('" + fieldId + "', '" + valType + "', '" + compareField + "')", 500);
}
function actualValidate(fieldId, valType, compareField) {
  var field = document.getElementById(fieldId);
  var fieldValue = field.value;
  var validated = false; 
  if (document.getElementById(compareField)) var compareVal = document.getElementById(compareField).value;
  switch (valType) {
    case "password": 
      if (fieldValue.length < 6)
        var valMsg = 'Password must be 6 or more characters long';
      else validated = true;
      break;
    case "confirm":
      if (fieldValue.length < 6)
        var valMsg = 'Password must be 6 or more characters long';
      else if (fieldValue.length < 6 && fieldValue != compareVal)
        var valMsg = 'This must be the same as the password';
      else validated = true;
      break;
    case "email":
      if (!fieldValue.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/))
        var valMsg = 'This doesn\'t appear to be a proper email address';
      else validated = true;
      break;
    case "postcode":
      field.value = formatPostcode(fieldValue);
      fieldValue = field.value;
      if(!isValidPostcode(fieldValue))
        var valMsg = 'This doesn\'t appear to be a valid postcode';
      else validated = true;
      break; 
    case "none":
      validated = true;
      break;
    default: // check if empty or not
      if (fieldValue != '') validated = true;
      else var valMsg = 'This field cannot be empty.';
      break;
  }
  
  validationMessage(fieldId, validated, valMsg); 
  
}
function validationMessage(fieldId, validated, valMsg) {
  var field = document.getElementById(fieldId);
  var valIcon = document.getElementById('valid_icon_' + fieldId);
  var iconOK = '/library/templates/default/resources/validate_ok.gif';
  var iconFailed = '/library/templates/default/resources/validate_failed.gif';
  var iconWait = '/library/templates/default/resources/validate_wait.gif';
  
  if (valIcon == null) { 
    var posX = findPosX(field) + field.offsetWidth + 25;
    var posY = findPosY(field) + field.offsetHeight - 21;
    var newValIcon = document.createElement('div');
    var bodyElement = document.getElementsByTagName('body');
    newValIcon.setAttribute('id', 'valid_icon_' + fieldId);
    field.parentNode.appendChild(newValIcon); 
    //bodyElement[0].firstChild.parentNode.insertBefore(newValIcon, bodyElement[0].firstChild);
    valIcon = document.getElementById('valid_icon_' + fieldId);  
    valIcon.style.display = 'inline';  
    valIcon.style.position = 'absolute';
    valIcon.style.marginTop = '-2px';
    valIcon.style.marginLeft = '10px';
    //valIcon.style.top = posY + 'px';
    //valIcon.style.left = posX + 'px';
    valIcon.style.padding = '2px 2px 2px 30px';
    valIcon.style.height = '19px';    
    valIcon.style.backgroundPosition = '2px 2px';
    valIcon.style.backgroundRepeat = 'no-repeat';
  }
  if (validated == 'wait') {
    valIcon.style.backgroundColor = 'Transparent';
    valIcon.style.backgroundImage = 'url(' + iconWait + ')';
    valIcon.innerHTML = ' ';
  }
  else if (validated == true) {
    valIcon.style.backgroundColor = 'Transparent';
    valIcon.style.backgroundImage = 'url(' + iconOK + ')';
    valIcon.innerHTML = ' ';
  }
  else {
    valIcon.style.backgroundColor = '#fff';
    valIcon.style.backgroundImage = 'url(' + iconFailed + ')';    
    valIcon.innerHTML = valMsg;
  }
}
function isValidPostcode(p) {
  var postcodeRegEx = /[A-Z]{1,2}[0-9]{1,2}[A-Z]? ?[0-9][A-Z]{2}/i;
  return postcodeRegEx.test(p);
}
/*  formats a VALID postcode nicely: AB120XY -> AB1 0XY */
function formatPostcode(p) {
  if (isValidPostcode(p)) {
    var postcodeRegEx = /(^[A-Z]{1,2}[0-9]{1,2}[A-Z]?)([0-9][A-Z]{2}$)/i;
    p = p.toUpperCase();
    return p.replace(postcodeRegEx,"$1 $2");
  } else {
    return p;
  }
}
function findPosX(obj) {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}
// For shop - when using additional products, check if any are ticked
function checkTickedProducts(thisFormId) {
  thisForm = document.getElementById(thisFormId);
  numExtra = thisForm.num_extra.value;
  if(thisForm.xtra_val_1) {
    noneTicked=1;
    for (x=1; x<=numExtra; x++) {
      thisElement=eval("thisForm.xtra_bool_"+x);
      if(thisElement.checked) {
        noneTicked=0;
      }
    }
    if (noneTicked==1) {
      alert('Please tick the items you require before adding to cart');
      return false;
    }
  }
  else {
    return true;
  }
}
// tidy strings before passing via query string
function parseQS(str) {
  var indexmatch = '';
  while (indexmatch != -1){
    str = str.replace('%', '[percent]');
    indexmatch = str.indexOf( "%" );
  } 
  indexmatch = '';
  while (indexmatch != -1){
    str = str.replace('&', '%26');
    indexmatch = str.indexOf( "&" );
  } 
  // make sure this one's last...
  indexmatch = '';
  while (indexmatch != -1){
    str = str.replace('[percent]', '%25');
    indexmatch = str.indexOf( "[percent]" );
  } 
  return str;
}
// Confirmations
function confirmAction(msg) {
  if (!msg) var msg = 'Are you sure you wish to delete this item?';
  return confirm(msg);
}
// Popup windows 
var newwin;
function launchwin(winurl,winname,winfeatures) {
	    
  if(newwin) { newwin.close(); }
  newwin = window.open(winurl,winname,winfeatures);
  newwin.focus();
}
function placeFocus() {
  if (document.forms.length > 0) {
    var field = document.forms[0];
      for (i = 0; i < field.length; i++) {
        if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
        document.forms[0].elements[i].focus();
        break;
        }
      }
  }
}      
// Return characters pressed, in input boxes etc, and filter (e.g. numbers only)
function getkey(e) {
  if (window.event)
   return window.event.keyCode;
  else if (e)
   return e.which;
  else
   return null;
}
function swapimage(imageid, imagefile) {
  document.getElementById(imageid).src = 'library/images/' + imagefile;
}
function goodchars(e, goods) {
  var key, keychar;
  key = getkey(e);
  if (key == null) return true;
  // get character
  keychar = String.fromCharCode(key);
  keychar = keychar.toLowerCase();
  goods = goods.toLowerCase();
  // check goodkeys
  if (goods.indexOf(keychar) != -1)
	return true;
  // control keys
  if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
     return true;
  // else return false
  return false;
}
function changeqty(dir, id) {
  currentqty = parseInt(document.getElementById(id).value);
  if (dir=='up') document.getElementById(id).value = currentqty+1;
  else if (dir=='down' && currentqty > 1)
    document.getElementById(id).value = currentqty-1;
  else if (dir=='down' && currentqty < 2)
    document.getElementById(id).value = 1;
}
function checksearch(searchform,searchbox)
{
  if (document.forms[searchform].elements[searchbox].value == "") {
    alert( "Please enter your criteria in the search box." );
    document.forms[searchform].elements[searchbox].focus();
    return false;
  }
  else if (document.forms[searchform].elements[searchbox].value.length < 3) {
    alert( "Search term should be more than 2 characters" );
    document.forms[searchform].elements[searchbox].focus();
    return false;
  }
  else return true;
}
function showFormComment(fieldId) {
  document.getElementById('form_comment_' + fieldId).style.display = 'block';
}
function checkAndShowCommentBox(fieldId, formName) {
  var specialConcat = document.getElementById('_special_' + fieldId).value;
  var specialIndexes = specialConcat.split(',');
  var formField = document.getElementById('_form_' + fieldId);
  if (formField.type == 'hidden') {  // if hidden, then we're looking for a radio selection instead, using name instead of ID    
    var radioObject = eval('document.' + formName + '.' + '_form_' + fieldId + ';');
    var radioObjectNum = (radioObject.length == 'undefined') ? 1 : radioObject.length;
    var radioChecked = 0;
    for(var r = 0; r < radioObjectNum; r++) {
      if(radioObject[r].checked) {
        var fieldSelected = r - 1;
        break;
      }
    }
  }
  else {
    var fieldSelected = formField.selectedIndex - 1;
  }
  var key = '';
  for (key in specialIndexes) {
    if (specialIndexes[key] == fieldSelected) {
      showFormComment(fieldId);
      var comments = 1;
    }
  }
  if (comments != 1) {
    document.getElementById('form_comment_' + fieldId).style.display = 'none';
  }
}
function formsDisabledWarning(inputObj) {
  alert('Please view the attachment before answering this question.');
  inputObj.blur();
}
function formsEnableField(fieldId) { 
  fieldObj = document.getElementById('_form_' + fieldId);
  fieldObj.onfocus = '';
}
function show_ee() {
  //
}
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }
  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
function getStats() {
  
  var screenres;
  var screencolor;
  var flashvn;
  var browser;
  var browservn;
  var os;
  
  if (screen.width) screenres=screen.width+" x "+screen.height;
  else screenres="Unknown";
  
  if (screen.colorDepth) screencolor=screen.colorDepth;
  else screencolor="Unknown";
  
    browser='';
  browservn='';
  
  alert("Screen res: "+screenres+", "+screencolor+" bit\nBrowser: "+browser+" "+browservn);
  
}
// CHAP for site login
var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
function md5_vm_test()
{
  return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
function core_md5(x, len)
{
  /* append padding */
  x[len >> 5] |= 0x80 << ((len) % 32);
  x[(((len + 64) >>> 9) << 4) + 14] = len;
  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;
  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;
    a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
    b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
    a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
    c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
    b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);
    a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
    b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
    b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
    a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
    b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
    a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
    a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
    c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
    b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
    a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
    b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
    b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
    c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
    a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
    c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
    a = safe_add(a, olda);
    b = safe_add(b, oldb);
    c = safe_add(c, oldc);
    d = safe_add(d, oldd);
  }
  return Array(a, b, c, d);
}
function md5_cmn(q, a, b, x, s, t)
{
  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
function core_hmac_md5(key, data)
{
  var bkey = str2binl(key);
  if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  var ipad = Array(16), opad = Array(16);
  for(var i = 0; i < 16; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }
  var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  return core_md5(opad.concat(hash), 512 + 128);
}
function safe_add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}
function bit_rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}
function str2binl(str)
{
  var bin = Array();
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < str.length * chrsz; i += chrsz)
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  return bin;
}
function binl2str(bin)
{
  var str = "";
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < bin.length * 32; i += chrsz)
    str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  return str;
}
function binl2hex(binarray)
{
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i++)
  {
    str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
           hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
  }
  return str;
}
function binl2b64(binarray)
{
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i += 3)
  {
    var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
                | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
                |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
    for(var j = 0; j < 4; j++)
    {
      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
    }
  }
  return str;
}
function doCHAP() {
  var password=document.getElementById('side_login_psw').value;
  document.getElementById('response').value=hex_md5(hex_md5(password)+'');
  document.getElementById('side_login_psw').value='';
  return true;
} 
// Embed Flash content
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="