/*
 * PHP File Uploader with progress bar Version 1.20
 * Copyright (C) Raditha Dissanyake 2003
 * http://www.raditha.com

 * Licence:
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Initial Developer of the Original Code is Raditha Dissanayake.
 * Portions created by Raditha are Copyright (C) 2003
 * Raditha Dissanayake. All Rights Reserved.
 *
 */


var postLocation="pgbar.php";

/*
 * add any extension that you do no want to upload to the list
 * below they should be placed with in the /^ and / characters
 * separate each extension by a pipe symbol |
 */

var re = /^(\.php)|(\.sh)/;  // disallow shell scripts and php


/**
 * dofilter = true; to enable filtering
 */
var dofilter=true;

/**
 * this method will match each of the filenames with a
 * given list of banned extension. If any one of the
 * extensions match, an alert will be popped up and the
 * upload will not continue;
 */

function check_types_video() {
	if(dofilter==false)
		return true;

		var result2=document.form_uploader.VideoFile.value.split(".");
		var num = result2.length;
		var ext = (result2[num-1]);

		if(ext == 'mpeg'|| ext == 'mpg' || ext == 'avi' || ext == 'flv' || ext == 'wmv' || ext == 'mov' ||
		   ext == 'MPEG'|| ext == 'MPG' || ext == 'AVI' || ext == 'FLV' || ext == 'WMV' || ext == 'MOV') {
		 return true;
		} else {

	alert("Špatný formát souboru.");
	return false;
	}
}

function popUP(mypage, myname, w, h, scroll, titlebar)
{

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}




function postItVideo(Type)
{
        if(Type == 'video') {
  	  if(check_types_video() == false) {
	    return false;
	  }
	}

	  baseUrl = postLocation;
	  sid = document.form_uploader.sessionid.value;
	  iTotal = escape("-1");
	  baseUrl += "?iTotal=" + iTotal;
	  baseUrl += "&iRead=0";
	  baseUrl += "&iStatus=1";
	  baseUrl += "&sessionid=" + sid;

	  //popUP(baseUrl,"Uploader",460,150,false,false);
	  document.form_uploader.submit();
}


function check_types_privatephoto() {
	if(dofilter==false)
		return true;

		var result2=document.form_uploader.PhotoFile.value.split(".");
		var num = result2.length;
		var ext = (result2[num-1]);

		if(ext == 'jpg' || ext == 'JPG' || ext == 'jpeg' || ext == 'JPEG') {
		 return true;
		} else {

	  alert("Špatný formát souboru.");
	  return false;
	}
}

function postItPrivatePhoto()
{
  	  if(check_types_privatephoto() == false) {
	    return false;
	  }

	  baseUrl = postLocation;
	  sid = document.form_uploader.sessionid.value;
	  Comment = document.form_uploader.Comment.value;
	  IdAlbum = document.form_uploader.IdAlbum.value;
	  iTotal = escape("-1");
	  baseUrl += "?iTotal=" + iTotal;
	  baseUrl += "&iRead=0";
	  baseUrl += "&iStatus=1";
	  baseUrl += "&sessionid=" + sid;
	  baseUrl += "&Comment=" + Comment;
	  baseUrl += "&IdAlbum=" + IdAlbum;

	  popUP(baseUrl,"Uploader",460,150,false,false);
	  document.form_uploader.submit();
}

function check_types_meet() {

         if(document.form_uploader.PhotoFile.value != '') {
		var result2=document.form_uploader.PhotoFile.value.split(".");
		var num = result2.length;
		var ext = (result2[num-1]);

		if(ext == 'jpg' || ext == 'JPG' || ext == 'jpeg' || ext == 'JPEG') {
		 return true;
		} else {

	    alert("Špatný formát souboru.");
	    return false;
	  }
	}

	return true;
}
