﻿/*Validation*/

function ClientValidateCheckbox(oSource, oArgs) {
  var iFound = 0;   // number of checkboxes selected

  // get an array of all controls on the form
  var aControls = document.forms[0].elements;

  // iterate through array looking for checkboxes
  // the ID of CheckBoxList is "MyCheck" so each checkbox
  // control will have the name MyCheck:n where n is a value
  // from zero to the number of checkboxes minus one
  for (var i=0; i < aControls.length; i++) {
    if (aControls[i].name.indexOf("chkLst") != -1) {

      // increment counter if checkbox is "ticked"
      if (aControls[i].checked) iFound++;
    }
  }

  // set IsValid property of "argument" object to true
  // if at least three selected, or false otherwise
  oArgs.IsValid = (iFound > 0);
}

function ClientValidateCheckboxGroup(oSource, oArgs) {
  var iFound = 0;   // number of checkboxes selected

  // get an array of all controls on the form
  var aControls = document.forms[0].elements;

  // iterate through array looking for checkboxes
  // the ID of CheckBoxList is "MyCheck" so each checkbox
  // control will have the name MyCheck:n where n is a value
  // from zero to the number of checkboxes minus one
  for (var i=0; i < aControls.length; i++) {
    if (aControls[i].name.indexOf("chk") != -1) {

      // increment counter if checkbox is "ticked"
      if (aControls[i].checked) iFound++;
    }
  }

  // set IsValid property of "argument" object to true
  // if at least three selected, or false otherwise
  oArgs.IsValid = (iFound > 0);
}

function cvShow_ServerValidate(oSource, oArgs) {
    var showNameList = document.getElementById("ctl00_cphMainBody_ddlShow");
	if (null != showNameList)
	{
		var iValue = new Number(showNameList[showNameList.selectedIndex].value);
		oArgs.IsValid=(iValue > 0);
	}
	else
	{
		oArgs.IsValid = false;
	}

}

function cvShowDateTime_ServerValidate(oSource, oArgs) {

    var showDateTimeList = document.getElementById("ctl00_cphMainBody_ddlShowDateTime");
	if (null != showDateTimeList)
	{
		var iValue = new Number(showDateTimeList[showDateTimeList.selectedIndex].value);
		oArgs.IsValid=(iValue > 0);
	}
	else
	{
		oArgs.IsValid = false;
	}

}

//Enable and disable general layers (parameter required)
function showDiv(divName) {
	document.getElementById(divName).style.display = "block";
}
function hideDiv(divName) {
	document.getElementById(divName).style.display = "none";
}

//Disclaimer for leaving the site
function disclaimer() {
    return confirm("You are now leaving OneMoreProductions.com. We are not responsible for the content you access beyond this point.");
}

//Pop-up the page
function popPage() {
    args = popPage.arguments;
    window.open(args[0],'ompPop','width=750,height=550,scrollbars=1');
   }


/* Open a new window (perfectly centered at 70-90% of screen size) */
function openPDF() {
   	args = openPDF.arguments;

   	/*--- Choose window size (full screen minus how many pixels) ---*/
   	var windowsize = 150;
   	var maxwindowwidth = 1024;
   	var maxwindowheight = 768;
   	/*--------------------------------------------------------------*/

   	if (screen.width > maxwindowwidth) {
   		var width = maxwindowwidth;
   		var widthc = (screen.width - maxwindowwidth) / 2;
   	}
   	else {
   		var width = screen.width - windowsize;
   		var widthc = windowsize / 2;
   	}

   	if (screen.height > maxwindowheight) {
   		var height = maxwindowheight;
   		var heightc = ((screen.height - maxwindowheight) / 2) - 50;
   	}
   	else {
   		var height = screen.height - (windowsize * 2);
   		var heightc = windowsize / 2;
   	}

   	window.open(args[0], 'openWin', 'width=' + width + ',height=' + height + ',top=' + heightc + ',left=' + widthc + ',scrollbars=1,status=1,toolbar=1,menubar=1,resizable=1');
   	return false;
}