function submitForm(id)
{
	var form = document.getElementById(id);
	form.submit();
}
function confirmSectionDelete()
{
	if(confirm("Are you sure you want to delete the selected section? \r\n This action is not reversible. \r\n\r\nClick OK to confirm."))
		return true;
	else
		return false;
}
function confirmSubDelete()
{
	if(confirm("Delete Subscriber? \r\n This action is not reversible. \r\n\r\nClick OK to confirm."))
		return true;
	else
		return false;
}
function showDiv(id)
{
	var div = document.getElementById(id);
	div.style.display = "block";
}
function hideDiv(id)
{
	var div = document.getElementById(id);
	div.style.display = 'none';
}

/**
* Displays a full size image when one of the thumbnails in show.phtml is clicked.
* The image is displayed in a centred div
*
* @param string dir  showimages sub folder name (same as showId)
* @param string filename
*/
function getImageFull(dir, filename)
{
	var image = new Image();
	/**
	* Onload handler - required to get image sizes in Firefox as well as IE
	* must be declared before image src is set
	*/
	image.onload = function()
	{
	   var imageX = image.width;
	   var imageY = image.height;

	   // assign our popup image src
	   document['ImageFull'].src = image.src;

	   // Positioning it
	   var div = document.getElementById('showImageFull');
	   var viewport = getViewportSize();

	   if(typeof document.body.style.maxHeight != 'undefined'){
	   	   // IE7+ Mozilla etc
	   	   div.style.top = ((viewport[1]/2) - (imageY/2)) + 'px';
	   } else {
	   	   // IE6 or below - we need to add scroll amount to y position
	   	   var scroll = getScrollAmount();
	   	   div.style.top = (((viewport[1]/2) - (imageY/2)) + scroll) + 'px';
	   }
	   div.style.left = (viewport[0]/2)-(imageX/2) + 'px';

	   // Display it
	   div.style.display = 'block';
	}
	// Load the image object which fires the event handler above when fully loaded
	image.src = "/showimages/" + dir + "/" + filename;
}


function getScrollAmount()
{
	var ScrollTop = document.body.scrollTop;

 	if (ScrollTop == 0)
	{
    	if (window.pageYOffset)
        	ScrollTop = window.pageYOffset;
    	else
        	ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	return ScrollTop;
}

function getViewportSize()
{
    var viewport = new Array();

 	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined')
 	{
      	viewport[0] = window.innerWidth,
      	viewport[1] = window.innerHeight
 	}

	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 	else if (typeof document.documentElement != 'undefined'
    	&& typeof document.documentElement.clientWidth !=
    	'undefined' && document.documentElement.clientWidth != 0)
 	{
    	viewport[0] = document.documentElement.clientWidth,
    	viewport[1] = document.documentElement.clientHeight
 	}

 	// older versions of IE
 	else
 	{
    	viewport[0] = document.getElementsByTagName('body')[0].clientWidth,
    	viewport[1] = document.getElementsByTagName('body')[0].clientHeight
 	}
 	return viewport;
}

function CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);

      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  }
}