// JavaScript Document

function initEditor (strTextAreaName) {
 
 tinyMCE.init({
	  mode: "exact",
	  language: "en",
	  elements: strTextAreaName,
	  plugins: "table,advimage,advlink,flash",
	  theme: "advanced",
	  theme_advanced_toolbar_location: "top",
	  theme_advanced_toolbar_align: "left",
	  theme_advanced_path_location: "bottom",
	  theme_advanced_buttons1: "justifyleft,justifycenter,justifyright,justifyfull,separator,bold,italic,strikethrough,separator,sub,sup,separator,charmap",
	  theme_advanced_buttons2: "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,image,flash,separator,cleanup,removeformat,separator,code",
	  theme_advanced_buttons3: "tablecontrols",
	  extended_valid_elements: "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]",
	  relative_urls: false,
	  debug: false,
	  theme:"advanced",language:"en",file_browser_callback:"myFileBrowser",plugins:"safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",theme_advanced_buttons1:"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime",theme_advanced_buttons3:"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl",theme_advanced_buttons4:"styleprops,|,forecolor,backcolor,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,fullscreen,preview",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_statusbar_location:"bottom",content_css:"/example_data/example_full.css",plugin_insertdate_dateFormat:"%Y-%m-%d",plugin_insertdate_timeFormat:"%H:%M:%S",external_link_list_url:"example_data/example_link_list.js",external_image_list_url:"example_data/example_image_list.js",flash_external_list_url:"example_data/example_flash_list.js",template_external_list_url:"example_data/example_template_list.js",theme_advanced_resize_horizontal:false,theme_advanced_resizing:false,apply_source_formatting:true,spellchecker_languages:"+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv,Width=auto,Height:auto"
 });
}

function ShowHide (objHTML, objLink, strMore, strLess) {
 
 if (objHTML.style.display == 'none') {
  objHTML.style.display = '';
	objLink.innerHTML = strMore;
 } else {
  objHTML.style.display = 'none';
	objLink.innerHTML = strLess;
 }
 
}

function ShowHideTwoDivs (objHTML1, objHTML2, objLink, strMore, strLess) {

 if (objHTML1.style.display == 'none') {
  objHTML1.style.display = '';
	objLink.innerHTML = strMore;
  objHTML2.style.display = 'none';
 } else {
  objHTML1.style.display = 'none';
	objLink.innerHTML = strLess;
  objHTML2.style.display = '';
 }

}

function loadNewWindow(pagename) {
window.open(pagename,'_blank','width=740,height=500,top=0,left=20,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no');
}

function clickMultiEdit (objCB, strValName) {
	 
	 var objHidden = document.getElementById (strValName);
	 
	 if (objCB.checked) {
		 if (objHidden.value != '') {
		   objHidden.value += ',';
		 }
		 objHidden.value += objCB.value;
	 } else {
		 var objVal = new String (objHidden.value);
		 objVal.replace (objCB.value, '');
		 objHidden.value = objCB.value;
	 }
}

function validate_form(thisform)
{
  with (thisform)
    {
    if (validate_required(export_reference,"Please enter an export Reference!")==false)
    {export_reference.focus();return false;}
    }
}


function ImageClicked(imageId)
{
    
    document.getElementById("img0").src = ("/frontend_dev.php/files/displaythumb/en_US/id/")+imageId+("/width/280.html");
    
   
}

function ShowEffect(element){
       new Effect.Appear(element,
       {duration:1, from:0.1, to:1.0});
}

function FadeEffect(element){
       new Effect.Fade(element,
       {duration:1});
}

var currentImage = 0;
var viewSize = 5;

var wait;
function moveToPrevious()
{
  if(currentImage > 0 && wait != 1)
  {
    wait = 1;
    new Effect.Move('imageBoxInside', {x: 61, y: 0, transition: Effect.Transitions.sinoidal});
    currentImage--;
    wait = 0;
  }
}

function moveToNext(iCount)

{
  totalImages = iCount;
  
 if(currentImage < totalImages-viewSize && wait != 1)
  {
    wait = 1;
    new Effect.Move('imageBoxInside', {x: -61, y: 0, transition: Effect.Transitions.sinoidal});
    currentImage++;
    wait = 0;
  }
}

function selectAllCheckBoxes ()
{
  var selected = document.getElementById('Selected').value;

  var checkboxes = [];

  checkboxes = $$('input').each(function(e){if(e.type == 'checkbox') checkboxes.push(e)});

  var form = $('SuburbSelect');
  checkboxes = form.getInputs('checkbox');

  if (selected == 0) {

    checkboxes.each(function(e){e.checked = 1});

    document.getElementById('Select').innerHTML='Unselect All';

    document.getElementById('Selected').value=1;

  }else if (selected == 1){

    checkboxes.each(function(e){e.checked = 0});

    document.getElementById('Select').innerHTML='Select All';

    document.getElementById('Selected').value=0;
  }
  spans = document.getElementsByTagName("span");
		for(var b = 0; b < spans.length; b++) {
      if (spans[b].className == 'checkbox'){
        spans[b].style.display = 'none';
        spans[b].id = '';
      }
    }
  Custom.init();

}

function otherExecutionCreditorShow(intShowNo){


    if (intShowNo <= 0){
      document.getElementById('ShowExCreditorTxtBox').style.display = '';
    }else {
      document.getElementById('ShowExCreditorTxtBox').style.display = 'none';
    }
}

function otherExpiryDateShow(intShowNo){


    if (intShowNo <= 0){
      document.getElementById('ShowExpiryDateTxtBox').style.display = '';
    }else {
      document.getElementById('ShowExpiryDateTxtBox').style.display = 'none';
    }
}


function validateContactForm() {

  if (document.getElementById('contact_reason_id_8').checked){

    if (document.getElementById('detailed_message').value == ''){
      alert("Please fill in a detailed message");
       return false;
    }else{
      return true;
    }
  }else{
    return true;
  }
}

function validateFEAdminUserForm() {

  if (document.getElementById('expiry_date_id').value==(-1)){

      if (document.getElementById('subscription_date_end').value == ''){
      alert("Please fill in a manual exipry date");
       return false;
    }else{
      return true;
    }
  }else{
    return true;
  }

}
function registerAsSheriffOrMember (objHTML1, objHTML2, objLink, strMore, strLess){

 if (objHTML1.style.display == 'none') {
  objHTML1.style.display = '';
	objLink.innerHTML = strMore;
  objHTML2.style.display = 'none';
  document.getElementById('user_or_sheriff').value = 0;
 } else {
  objHTML1.style.display = 'none';
	objLink.innerHTML = strLess;
  objHTML2.style.display = '';
  document.getElementById('user_or_sheriff').value = 1;
 }

}

function showHideSheriffDiv(intUserTypeID, intFeSheriffID){

  if (intUserTypeID == intFeSheriffID){
    document.getElementById('selectSheriffUser').style.display = '';
  }else{
    document.getElementById('selectSheriffUser').style.display = 'none';
  }
}




