function open_view( picture,title ) {
	var sURL = 'http://www.tvnzb.com/view_showimage.php?img=' + String(picture) + '&title=' + String(title);
	var imageWin = window.open(sURL, 'imageWin', 'height=420,width=410,scrollbars=1,resizable=1');	
}  

function open_view2( picture,title ) {
	var sURL = 'http://www.tvnzb.com/view_image.php?img=' + String(picture) + '&title=' + String(title);
	var imageWin = window.open(sURL, 'imageWin', 'height=420,width=410,scrollbars=1,resizable=1');	
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function setContent(elementId) {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		var windowWidth = getWindowWidth();
		
		if (windowHeight > 0 && windowWidth) {
			var contentElement = document.getElementById(elementId);
			var contentHeight = contentElement.offsetHeight;
			var contentWidth = contentElement.offsetWidth;
			contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + 'px';
		}
	}
}
  
  function CheckAllItems(How,Form, Prefix) {
    Form = document[Form].elements
    for (i=0; i<Form.length; i++) {
      if (Form[i].type == "checkbox")
      Form[i].checked = How
    }
  }
	
  function CheckAllFormItems(f, prefix) {
	  if (prefix == undefined) prefix = '';
	  e = document[f][prefix+'check_all_variable'];
		e.checked = !e.checked
		sel = e.checked
	  f = document[f].elements;
    for (i=0; i<f.length; i++) {
		e = f[i];
      if (e.type == "checkbox" && e.name.indexOf(prefix) == 0)
      e.checked = sel
    }
  }	
	
	function RangeFormItems(f, prefix) {
	  if (prefix == undefined) prefix = '';
	sel = false;
	f = document[f].elements;
	for (i = 0; i < f.length; i ++) {
	 e = f[i];	
	 if (e.type == "checkbox" && e.name.indexOf(prefix) == 0 && e.name != prefix+'check_all_variable') {
	  if (e.checked) {
		 if (i < f.length - 1 && !f[i + 1].checked && (!f[i - 1].checked || sel)) { 
		  sel = !sel;
		 }
		}
		else {
		 e.checked = sel;
		}
	 } 
	}
	}
	
  function CheckAllCustomFormItems(f, prefix) {
	  if (prefix == undefined) prefix = '';
	  e = document[f][prefix+'check_all_variable'];
		e.checked = !e.checked;
		sel = e.checked;
		bgColor = (sel) ? custom_form_mouseover_color_html : '';
	  f = document[f].elements;
    for (i=0; i<f.length; i++) {
		e = f[i];
      if (e.type == "checkbox" && e.name.indexOf(prefix) == 0 && e.name != prefix+'check_all_variable') {
			 document.getElementById(custom_form_tag_id_prefix+e.name).style.backgroundColor = bgColor;
       e.checked = sel;
			}
    }
  }	
	
	function RangeCustomFormItems(f, prefix) {
	  if (prefix == undefined) prefix = '';
	sel = false;
	bgColor = '';
	f = document[f].elements;
//debug_check*/	debug = '';
	for (i = 0; i < f.length; i ++) {
	 e = f[i];	
	 if (e.type == "checkbox" && e.name.indexOf(prefix) == 0 && e.name != prefix+'check_all_variable') {
//debug_check*/			debug += e.name + " "
	  if (e.checked) {
//debug_check*/			if (!(i < f.length - 1)) debug += " 1 fail ";
//debug_check*/			if (!(!f[i + 1].checked)) debug += " 2 fail ";
//debug_check*/			if (!(!f[i - 1].checked || sel)) debug += " 3 fail ";
		 if (i < f.length - 1 && !f[i + 1].checked && (!f[i - 1].checked || sel)) { 
		  sel = !sel;
//debug_check*/				debug += " to " + sel + " ";
		  bgColor = (sel) ? custom_form_mouseover_color_html : '';
		 }
		}
		else {
		 e.checked = sel;
			 document.getElementById(custom_form_tag_id_prefix+e.name).style.backgroundColor = bgColor;		 
		}
//debug_check*/			debug += "<br />";
	 } 
	}
//debug_check*/		document.getElementById('all_files').innerHTML = debug;
	}
	
 function CheckAllSelectOptions(f) {
  if (typeof(f) == 'string') f = document[f];
	len = f.options.length;
	if (len == 0) { alert("No items present, cannot select all/none"); return; }	
	bool = !f.options[0].selected;
	for (i = f.options.length - 1; i > -1; i--) {
	 f.options[i].selected = bool;
	} 
 } 
	
 function RangeSelectOptions(f) {
  if (typeof(f) == 'string') f = document[f]; 
	len = f.options.length;
	if (len == 0) { alert("No items present, cannot range"); return; }	
	bool = false;
	for (i = f.options.length - 1; i > -1; i--) {
	 if (f.options[i].selected) {
	  bool = !bool;
	 }
	 else {
	  f.options[i].selected = bool;
	 }
	} 
 } 	

  function APChangeSectionVisiblity(id, bVisible) { APChangeSectionVisibility(id, bVisible); }

  function APChangeSectionVisibility(id, bVisible) {
    if (bVisible == true) {
      if (document.layers) {
        document.layers[id].visibility = "show"
      }
      else if (document.all) {
        document.all[id].style.display = ""
      }
      else if (document.getElementById) {
        document.getElementById(id).style.display = ""
      }
    }
    else {
      if (document.layers) {
        document.layers[id].visibility = ""
      }
      else if (document.all) {
        document.all[id].style.display = "none"
      }
      else if (document.getElementById) {
        document.getElementById(id).style.display = "none"
      }
    }

  }

  function APShowSection(Section) {
    APShowSection_ActiveSection = Section
    for (i=0; i<APShowSection_Sections; i++) {
      id = 'APSection_' + i
      APChangeSectionVisibility(id, (i == Section));
    }
  }

  function APChangeTabVisibility(section) {

    if (document.getElementById(section+'_link').className != "horizontal_menu_item_active") {
      document.getElementById(section+'_link').className = "horizontal_menu_item_active"
      document.getElementById(section+'_link').title = "Hide This Tab (" + section + ")"
      document.getElementById(section).style.display = ""
      if (HorizontalMenu_AutomaticallySwitchToSelectedTab != false){
        window.location="#"+section
      }
    }
    else {
      document.getElementById(section+'_link').className = ""
      document.getElementById(section+'_link').title = "Show This Tab (" + section + ")"
      document.getElementById(section).style.display = "none"
    }

  }


  function preSelectDropDown(drop, value) {
    for (i=0; i< drop.options.length; i++) {
      if (drop.options[i].value == value)
      drop.options.selectedIndex = i
    }

  }

  function handleMessage(e, f) {
    value = e.value
    a = value.length
    b = a-value.split(' ').join('').length
    if (a <= 0) {
      chartxt="No Characters"
    }
    else if (a == 1)
    chartxt="One Character Written"
    else
    chartxt=a+" Characters Written"
    chartxt += '; '
    if (b <= 0) {
      chartxt +="No Words"
    }
    else if (b == 1)
    chartxt +="One Word Written"
    else
    chartxt +=b+" Words Written"

    document.getElementById(f).innerHTML = chartxt
  }

  doStat=true

  statDefault="Welcome to TvNZB.com"

  statRandomHash='none given'

  function stat() {
    var theargs,numargs,flag,secs,hash
    theargs=stat.arguments
    numargs=theargs.length
    if (numargs == 0)  {
      window.status=statDefault
      return
    }
    flag=theargs[0]
    if (flag == 0)
    statDefault='Status Line Message V. 1.0 by Avi P. ... Waiting for status line command...'

    if (flag == 1) {
      statDefault=stat.arguments[1]
      window.status=statDefault
    }

    if (flag == 2)
    window.status=''
    if (flag == 3 && theargs[1] == statRandomHash)
    window.status=statDefault


    if (!isDigit(stat.arguments[0])) {
      if (numargs > 1) {
        hash=statRandomHash
        while (hash == statRandomHash) {
          hash = Math.round(Math.random()*100000)
        }
        statRandomHash=hash
        setTimeout("stat(3,"+hash+")",theargs[1]*1000)
      }


      window.status=stat.arguments[0]

    }

  }

  function isDigit(iDdigStr) {

    if ((1+iDdigStr+'').charAt(0)=='1')

    return false

    if (1+iDdigStr+0==0+iDdigStr+1) //commutative property of addition, two numbers so it works with 0

    return true

    return false

  }
	
	function isNumeric(str) {
	 return (str * 1 == str);
	}

  function AP_manageDefaultValue() {

    args = AP_manageDefaultValue.arguments

    e = args[0];
    is_blur = false;
  if (args.length > 1) { if (args[1] != 1) is_blur = true; }

    if (e.defaultValue != " ") {
      if (is_blur) {
        if (e.value == "") e.value = e.defaultValue;
        if (e.value == " ") e.defaultValue = " ";
      }
      else {
        e.select();
        //if (e.defaultValue == e.value) e.value = "";
      }
    }

  }

  function AP_XML_Http(request, file, bool) {
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
    try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
    xmlhttp = false;
    }
    }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
      xmlhttp = new XMLHttpRequest();
    }

    xmlhttp.open(request, file, bool);
    return xmlhttp;
  }
	
	function deleteArrayValue(array, vals) {
	 new_array = new Array();
	 if (typeof(vals) == 'string') vals = new Array(vals);
	 for (i = 0; i < array.length; i++) {
	  pass = true;
		cur_val = array[i];
		for (j = 0; j < vals.length; j++) {
		 if (cur_val == vals[j]) {
		  pass = false;
			break;
		 }
		}
	  if (pass) new_array.push(cur_val);
	 }
	 return new_array;
	}
	
	function confirmWithRandomNumber() {
	args = confirmWithRandomNumber.arguments;
	if (args.length > 0) digs = args[0]; else digs = 3;
	 x = Math.random()
	 x *= (Math.pow(10, digs) - Math.pow(10, digs - 1) - 1);
	 x += Math.pow(10, digs - 1);
	 x = Math.round(x);
	 x2 = Math.random()
	 x2 *= (Math.pow(10, digs) - Math.pow(10, digs - 1) - 1);
	 x2 += Math.pow(10, digs - 1);
	 x2 = Math.round(x2);	 
	 matched = prompt("Are you sure you want to do this?  Confirm your action by typing in '"+x+"' below.", x2);
	 return (matched == x);
	}
	
  stat();
