// JavaScript Document

// pop-up function
var newWin = null;
function closeWin(){
	if (newWin != null){
		if(!newWin.closed)
			newWin.close();
	}
}
function popUp(strURL,strType,strHeight,strWidth) {
closeWin();
var strOptions="";
if (strType=="console") strOptions="scrollbars,resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}


function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4

        if (bgcolor=="") {
                bgcolor="#FFFFFF";
        }
        var adj=10
        var w = screen.width;
        var h = screen.height;
        var byFactor=1;

        if(w<740){
          var lift=0.90;
        }
        if(w>=740 & w<835){
          var lift=0.91;
        }
        if(w>=835){
          var lift=0.93;
        }
        if (imageWidth>w){
          byFactor = w / imageWidth;
          imageWidth = w;
          imageHeight = imageHeight * byFactor;
        }
        if (imageHeight>h-adj){
          byFactor = h / imageHeight;
          imageWidth = (imageWidth * byFactor);
          imageHeight = h;
        }

        var scrWidth = w-adj;
        var scrHeight = (h*lift)-adj;

        if (imageHeight>scrHeight){
            imageHeight=imageHeight*lift;
          imageWidth=imageWidth*lift;
        }

        var posLeft=0;
        var posTop=0;

        if (hugger == "hug image"){
          if (hugMargin == ""){
            hugMargin = 0;
          }
          var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
          if (scrHeightTemp < scrHeight) {
                scrHeight = scrHeightTemp;
          }
          var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
          if (scrWidthTemp < scrWidth) {
                scrWidth = scrWidthTemp;
          }

          if (scrHeight<100){scrHeight=100;}
          if (scrWidth<100){scrWidth=100;}

          posTop =  ((h-(scrHeight/lift)-adj)/2);
          posLeft = ((w-(scrWidth)-adj)/2);
         }

        if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
                imageHeight=imageHeight-adj;
                imageWidth=imageWidth-adj;
        }
        posTop = parseInt(posTop);
        posLeft = parseInt(posLeft);
        scrWidth = parseInt(scrWidth);
        scrHeight = parseInt(scrHeight);

        var agt=navigator.userAgent.toLowerCase();
        if (agt.indexOf("opera") != -1){
          var args= new Array();
          args[0]='parent';
          args[1]=imageName;
          var i ; document.MM_returnValue = false;
          for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
        } else {
//         alert("http://"+ BASE_HOST +"/picture.html") ; 
        newWindow = window.open("http://"+ BASE_HOST +"/picture.html","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);

       
        newWindow.document.open();
// onBlur="self.close()" onClick="self.close()"
//alert( BASE_HOST +imageName);
        newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+'>');
        newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
        newWindow.document.write('<img src="' +imageName+'" width='+imageWidth+' height='+imageHeight+' alt="" >');
        newWindow.document.write('</td></tr></table></body></html>');
        newWindow.document.close();
        newWindow.focus();
        }
}
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function changeFrame(frame,link){
        top.frames[frame].location=link;
        }
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function annotate() {
	now = new Date;
	var month = now.getMonth() + 1;
	if (month < 10) { 
		month = "0" + month;
	}
	if (now.getDate() < 10) { 
		var day = "0" + now.getDate();
	}
	else {
		var day = now.getDate();
	}
	if (now.getMinutes() < 10) { 
		var minutes = "0" + now.getMinutes();
	}
	else {
		var minutes = now.getMinutes();
	}
	if (now.getHours() < 10) { 
		var hours = "0" + now.getHours();
	}
	else {
		var hours = now.getHours();
	}
	var add = "-----  " + month + "-" + day + "-" + now.getFullYear() + " @ " + hours + ":" + minutes + 
	          " \n\n";
	document.update_clients_form.comments.value = add + document.update_clients_form.comments.value;
}
function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}
// mouseover  function
// param imgName   string  image name/id  
//param imgSrc  string image url
//Example: changeImages('img1','dsg/img_y.gif')
function changeImages(imgName, imgSrc) 
{
 var imgName;
 var imgSrc;
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// Example:
// preload( '01.gif', '02.gif' ); 
function preload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

//function to open popup window
//Example: 
//<a href="link.html" onClick="PopupLink('windowName','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=100,height=200');return document.MM_returnValue">bla</a>
function PopupLink(winName,features) { 	
  	window.open(this.href,winName,features); document.MM_returnValue = false;
}


// advanced function for pop up window, one can define  (url, window name, features, window  width, window height, window align, if  link to be ignored, if window to be on top, auto close time in sec, if it is bordless)
// param theURL - string  e.g "new_pop_up.html'  
//param winName string containing only  alfanumeric characters
// param features : 
                   //fullscreen=yes/no, 
                  //toolbar=yes/no,
				  //location=yes/no,
				  //status=yes/no,
				  //menubar=yes/no,
				  //scrollbars=yes/no,
				  //resizable=yes/no
//param popWidth integer
//param  popHeight integer
//param  winAlign  string: 
               //  pls choose :  'lefttop' / 'leftcenter '/ l'eftbottom' / 'righttop '/ r'ightcenter '/ 'rightbottom' / 'topcenter' / 'center '/ 'bottomcenter'
				  
//param ignorelink  string :
           // 'ignoreLink' if you wish to ignore current link and '' if not to
//param  alwaysOnTop  string
                // 'alwaysOnTop' if you wish the window to be  on top of all others windows and '' if not to		
//param  autoCloseTime integer 
// param  borderless  string :
			     // 'borderless' if you wish the window to be   borderless and '' if not to	 
				   				  
//example  onclick="GP_AdvOpenWindow('url.html','name','fullscreen=no,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes',100,100,'lefttop','ignoreLink','alwaysOnTop',0,'');return document.MM_returnValue" 
function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

//SNIPPETS:


//1.close window:
//<a href="javascript:window.close();">Close</a>

//2.Go back
//<a href="javascript:history.go(-1);">Go back</a>


//3.Adv. email link
//<a href="mailto:to@email.com?Subject=Subject&CC=cc@email.com&BCC=bcc@email.com&Body=Body gre tukaj .... ">email</a>

var marked_row = new Array;
/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

      if (supportsDynamicLabels()) {
        document.writeln('<style type="text/css">');
        document.writeln('label.dynamic { display:none; }');
        document.writeln('</style>');

        addEvent(window, "load", setupLabels);
      }

      function setupLabels() {
        var objLabels = document.getElementsByTagName("LABEL");
        var objField;

        for (var i = 0; i < objLabels.length; i++) {
          if ("dynamic" == objLabels[i].className) {
            objField = document.getElementById(objLabels[i].htmlFor);
            addEvent(objField, "focus", focusDynamicLabel);
            addEvent(objField, "blur", blurDynamicLabel);
            objField._labelText = objLabels[i].firstChild.nodeValue;
            objField.value = objField._labelText;
          }
        }

        for (var i = 0; i < document.forms.length; i++) {
          addEvent(document.forms[i], "submit", resetLabels);
        }
      }

      function resetLabels(event) {
        var elm = getEventSrc(event);
        var objLabels = elm.getElementsByTagName("LABEL");
        var objField;

        for (var i = 0; i < objLabels.length; i++) {
          if ("dynamic" == objLabels[i].className) {
            objField = document.getElementById(objLabels[i].htmlFor);
            if (objField._labelText == objField.value) {
              objField.value = "";
            }
          }
        }
      }

      function addEvent(objObject, strEventName, fnHandler) {
        if (objObject.addEventListener)
          objObject.addEventListener(strEventName, fnHandler, false);
        else if (objObject.attachEvent)
          objObject.attachEvent("on" + strEventName, fnHandler);
      }

      function focusDynamicLabel(event) {
        var elm = getEventSrc(event);
        if (elm._labelText == elm.value) {
          elm.value = "";
        }
      }

      function blurDynamicLabel(event) {
        var elm = getEventSrc(event);
        if ("" == elm.value) {
          elm.value = elm._labelText;
        }
      }

      function getEventSrc(e) {
        if (!e) e = window.event;

        if (e.originalTarget)
          return e.originalTarget;
        else if (e.srcElement)
          return e.srcElement;
      }

    function supportsDynamicLabels() {
      return document.getElementById && 
        (window.attachEvent || window.addEventListener) && 
        null == navigator.appVersion.match(/Safari\/\d+$/);
    }

<!--if (top.location == self.location) {
               //self.location.replace("index.php")
               //}-->


