﻿// JScript File

var popup = {
	win : null,
	open : function (src,width,height,fixedSize) {
		if (fixedSize) var param = 'no';
		else var param = 'yes';
		var p = 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=' + param + ',resizable= ' + param + ',status=no,width=' + width + ',height=' + height + ',left=' + (screen.availWidth/2-width/2) + ',top=' + (screen.availHeight/2-height/2);
		if (this.win) this.win.close();
		this.win = window.open(unescape(src),'',p);
		this.win.focus();
		},
	callBack : function (programCode) {
		eval(programCode);
		},
	getObj : function (x) {
		return getObj(x);
		}
	};
	

function PopupPic(sPicURL) 
{ 
	window.open( "ImagePreview.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=320"); 
} 

function PopupJob(id) 
{ 
	window.open( "JobView.aspx?aid=" + id, "", "resizable=1,scrollbars=1"); 
} 

function ConfirmMe(t)   
{
    var v = confirm("Opravdu chcete "+ t + "?");
    if (v) return true; else return false;
}


function isMSIE () {
	var value = (navigator.appName == "Microsoft Internet Explorer") && (navigator.userAgent.indexOf('Opera') == -1);
	return value;
	}


var checkedAll = false;
var checkedCount = 0;

function selectAll () {
	var form = document.forms[0];
	if (!checkedAll) 
	{		
		for (var i=0; i<form.length; i++) 
		{
			if (form[i].id.indexOf('cboxSelectItem') != -1) 							
				form[i].checked = true;
        }
		checkedAll = true;	
    }
	else 
	{
		for (var i=0; i<form.length; i++) 
		{
			if (form[i].id.indexOf('cboxSelectItem') != -1) 
			    form[i].checked = false;
        }
            checkedAll = false;
		}	
	}

function openWindows () 
{
    var form = document.forms[0];
	for (var i=0; i<form.length; i++) 
	{
		if (form[i].id.indexOf('cboxSelectItem') != -1)
		{ 							
			if (form[i].checked)
			{
			    window.open("ArticlesPreview.aspx?Articles=" + form[i+1].value, "_blank");
			}
	    }
    }
   }
   
   function displayPanel(number) {
   	if (getObjStyle('panel-' + number, 'display') == 'block') {
   		getObj('panelExpandImage-' + number).src = 'App_Themes/Theme/Images/profile_add.png';
   		displayObj('panel-' + number, false, '');
   	}
   	else {
   		getObj('panelExpandImage-' + number).src = 'App_Themes/Theme/Images/profile_min.png';
   		displayObj('panel-' + number, true, 'block');
   	}
   }

   function displayObj(obj, on, type) {
   	if (on && !type) 
   		type = 'block';
   	
   	return setObjStyle(obj, 'display', (on) ? type : 'none');
   }

   function getObjStyle(obj, prop) {
   	var o = getObj(obj)
   	if (document.defaultView)
   		var val = window.document.defaultView.getComputedStyle(o, null).getPropertyValue(prop);
   	else if (o.currentStyle) {
   	var val = eval('o.currentStyle.' + prop);
   	}
   	return val;
   }

   function setObjStyleByClass(t, c, prop, val) {
   	var elements = document.getElementsByTagName(t);
   	for (var i = 0; i < elements.length; i++) {
   		if (elements[i].className.indexOf(c) != -1) {
   			setObjStyle(elements[i], prop, val);
   		}
   	}
   }

   function getObj(x) {
   	if (typeof x != 'string') return x;
   	else if (Boolean(document.getElementById)) return document.getElementById(x);
   	else return null;
   }

   function changeObjClass(t, c, new_c) {
   	var elements = document.getElementsByTagName(t);
   	for (var i = 0; i < elements.length; i++) {
   		if (elements[i].className.indexOf(c) != -1) {
   			elements[i].className = new_c;
   		}
   	}
   }

   function showObj(obj, on) {
   	return setObjStyle(obj, 'visibility', (on) ? 'visible' : 'hidden');
   }

   function setObjStyle(obj, prop, val) {
   	var o = getObj(obj);
   	if (o && o.style) {
   		eval('o.style.' + prop + '="' + val + '"');
   		return true;
   	}
   	else return false;
   }
