$(function(){
        // don't forget this init!      
        $.initWindowMsg();​​​
        var childWin;
        /*****************************************************************************/
        //funkce slouzi k overeni existence substringu
        jQuery.isSubstring = function(haystack, needle) {
        	return haystack.indexOf(needle) !== -1; };
        
        
        var pathname;
        // funkce naplni promenou pathname hodnotou url
        $(document).ready(function() {
    		pathname = window.location.pathname;
    		//document.write(pathname);
    		});
        
        /*
        if( $.isSubstring(pathname, "edit") ) {
        $(document).ready(function(){
   		 $("#msgid").html("This is Hello World by JQuery");});
        }
        
        $(document).ready(function(){     
        	$("#odstavec").text(pathname); }); 
        */
        /************************************* Article Edit ************************************************/
        if( $.isSubstring(pathname, "article") && $.isSubstring(pathname, "edit")) {
        	$('#openWin').click(function(){
        		childWin = window.open('list2','child', "width=500, height=500, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
        		if (window.focus) {childWin.focus()}});
        	
        	$('#openWin1').click(function(){
        		childWin = window.open('list2','child', "width=500, height=500, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
        		if (window.focus) {childWin.focus()}});
        };
        /************************************* Article Search ************************************************/
        if( $.isSubstring(pathname, "article") && $.isSubstring(pathname, "search")) {
        	$('#openWin').click(function(){
        		childWin = window.open('list2','child', "width=500, height=500, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
        		if (window.focus) {childWin.focus()}});
        	
        	$('#openWin1').click(function(){
        		childWin = window.open('list2','child', "width=500, height=500, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
        		if (window.focus) {childWin.focus()}});
        };
        /************************************* Article New ************************************************/
        if( $.isSubstring(pathname, "article") && $.isSubstring(pathname, "new")) {
        	$('#openWin').click(function(){
        		childWin = window.open('list2','child', "width=500, height=500, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
        		if (window.focus) {childWin.focus()}});
        	
        	$('#openWin1').click(function(){
        		childWin = window.open('list2','child', "width=500, height=500, location=no, menubar=no, scrollbars=no, status=no, toolbar=no");
        		if (window.focus) {childWin.focus()}});
        };
        /****************************************************************************************************/
        
        
        
        /*
        // upon click of a button, send corresponding text input value to parent window
        $('#button1').click(function(){
          value = $('#in1').val();
          $.triggerWindowEvent(childWin, "parentMsg1", value); 
        });
        $('#button2').click(function(){
          value = $('#in2').val();
          $.triggerWindowEvent(childWin, "parentMsg2", value); 
        });
        */
        
        // maximalni pocet policek formulare ziskavajici hodnoty z popup window 0-20
        // tj. maximalni pocet odkazovanych seznamu list2
        
        // set up the message handlers, listen for events 'childMsg1' and 'childMsg2'
        $.windowMsg("childMsg0", function(message) {
            $('#in0').val(message);
          });
        $.windowMsg("childMsg1", function(message) {
          $('#in1').val(message);
        });
        $.windowMsg("childMsg2", function(message) {
          $('#in2').val(message);
        });
        $.windowMsg("childMsg3", function(message) {
            $('#in3').val(message);
          });
        $.windowMsg("childMsg4", function(message) {
            $('#in4').val(message);
          });
        $.windowMsg("childMsg5", function(message) {
            $('#in5').val(message);
          });
        $.windowMsg("childMsg6", function(message) {
            $('#in6').val(message);
          });
        $.windowMsg("childMsg7", function(message) {
            $('#in7').val(message);
          });
        $.windowMsg("childMsg8", function(message) {
            $('#in8').val(message);
          });
        $.windowMsg("childMsg9", function(message) {
            $('#in9').val(message);
          });
        $.windowMsg("childMsg10", function(message) {
            $('#in10').val(message);
          });
        $.windowMsg("childMsg11", function(message) {
            $('#in11').val(message);
          });
        $.windowMsg("childMsg12", function(message) {
            $('#in12').val(message);
          });
        $.windowMsg("childMsg13", function(message) {
            $('#in13').val(message);
          });
        $.windowMsg("childMsg14", function(message) {
            $('#in14').val(message);
          });
        $.windowMsg("childMsg15", function(message) {
            $('#in15').val(message);
          });
        $.windowMsg("childMsg16", function(message) {
            $('#in16').val(message);
          });
        $.windowMsg("childMsg17", function(message) {
            $('#in17').val(message);
          });
        $.windowMsg("childMsg18", function(message) {
            $('#in18').val(message);
          });
        $.windowMsg("childMsg19", function(message) {
            $('#in19').val(message);
          });
        $.windowMsg("childMsg20", function(message) {
            $('#in20').val(message);
          });
      });
