var popup1 ;
function openpopup(url)
{
url = "/" + url;
    if ( !popup1)
    {
         popup1 = window.open( url, 'FramepoolAG','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=400,height=500');
    }
    else
    {
        if (popup1.closed == true)
        {
            popup1 = window.open( url
                                  , "FramepoolAG"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=400,height=500');
			popup1.focus();
        }
        else
        {
            popup1.location.href = url;
            popup1.focus();
        }
    }
}

var popupT ;
function openTestfiles(url)
{
url = "/" + url;
    if ( !popupT)
    {
         popupT = window.open( url, 'FramepoolAG','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=400,height=400');
    }
    else
    {
        if (popupT.closed == true)
        {
            popupT = window.open( url
                                  , "FramepoolAG"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=400,height=600');
			popupT.focus();
        }
        else
        {
            popupT.location.href = url;
            popupT.focus();
        }
    }
}

var info ;
function openinfo(url)
{
url = "/" + url;
    if ( !info)
    {
         info = window.open( url, 'FramepoolAG','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=300,height=200');
	    info.focus();
    }
    else
    {
        if (info.closed == true)
        {
            info = window.open( url
                                  , "FramepoolAG"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=300,height=200');
        info.focus();
        }
        else
        {
            info.location.href = url;
            info.focus();
        }
    }
}


var rightsWindow;
function openRights(  )
{
actionType="0";
    if ( !rightsWindow)
    {
        rightsWindow = window.open( "addrights.jsp"
                              , "rightsWindow"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=550,height=550');
    }
    else
    {
       if (rightsWindow)
        {
            rightsWindow = window.open( "addrights.jsp"
                                  , "rightsWindow"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=550,height=550');
                                rightsWindow.focus();
        }
        else
        {
            rightsWindow.location.href = url;
            rightsWindow.focus();
        }
    }
}


var restrictionsWindow;

function openRestrictions(  )
{
actionType="0";
    if ( !restrictionsWindow)
    {
        restrictionsWindow = window.open( "addrestrictions.jsp" 
                              , "restrictionsWindow"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=550,height=550');
    }
    else
    {
       if (restrictionsWindow)
        {
            restrictionsWindow = window.open( "addrestrictions.jsp" 
                                  , "restrictionsWindow"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=550,height=550');
                                restrictionsWindow.focus();
        }
        else
        {
            restrictionsWindow.location.href = url;
            restrictionsWindow.focus();
        }
    }
}

var availabilityWindow;

function openAvailability(  )
{
actionType="0";
    if ( !availabilityWindow)
    {
        availabilityWindow = window.open( "addavailability.jsp" 
                              , "availabilityWindow"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=480,height=450');
    }
    else
    {
       if (availabilityWindow)
        {
            availabilityWindow = window.open( "addavailability.jsp?"
                                  , "availabilityWindow"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=480,height=450');
                                availabilityWindow.focus();
        }
        else
        {
            availabilityWindow.location.href = url;
            availabilityWindow.focus();
        }
    }
}

var dsWindow;

function openShotType(  )
{
actionType="0";
    if ( !dsWindow)
    {
        dsWindow = window.open( "addshottype.jsp" 
                              , "dsWindow"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=480,height=450');
    }
    else
    {
       if (dsWindow)
        {
            dsWindow = window.open( "addshottype.jsp?"
                                  , "dsWindow"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=480,height=450');
                                dsWindow.focus();
        }
        else
        {
            dsWindow.location.href = url;
            dsWindow.focus();
        }
    }
}

var catsWindow
function openCategories( )
{
actionType="0";
    if ( !catsWindow)
    {
        catsWindow = window.open( "addcategories.jsp"
                              , "catsWindow"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=350,height=300');
    }
    else
    {
       if (catsWindow)
        {
            catsWindow = window.open( "addcategories.jsp" 
                                  , "catsWindow"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=350,height=300');
                                catsWindow.focus();
        }
        else
        {
            catsWindow.location.href = url;
            catsWindow.focus();
        }
    }
}

var priceWindow;
function openPrices( )
{
actionType="0";
    if ( !priceWindow)
    {
        priceWindow = window.open( "addprices.jsp"
                              , "priceWindow"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=400,height=250');
    }
    else
    {
       if (priceWindow)
        {
            priceWindow = window.open( "addprices.jsp"
                                  , "priceWindow"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=400,height=250');
                                priceWindow.focus();
        }
        else
        {
            priceWindow.location.href = url;
            priceWindow.focus();
        }
    }
}


var keysWindow;
function openKeys(  actionType )
{
    if ( !keysWindow)
    {
        keysWindow = window.open( "addkeys.jsp?type=" + actionType
                              , "keysWindow"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=400,height=320');
    }
    else
    {
       if (keysWindow)
        {
            keysWindow = window.open( "addkeys.jsp?type=" + actionType
                                  , "keysWindow"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=400,height=320');
                                keysWindow.focus();
        }
        else
        {
            keysWindow.location.href = url;
            keysWindow.focus();
        }
    }
}

var playerWindow;
function openPlayer(  shotId )
{
    if ( !playerWindow)
    {
        playerWindow = window.open( "/player-popup.jsp?shotId=" + shotId
                              , "playerWindow"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=yes,width=600,height=420');
    }
    else
    {
       if (playerWindow)
        {
            playerWindow = window.open( "/player-popup.jsp?shotId=" + shotId
                                  , "playerWindow"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=yes,width=600,height=420');
                                playerWindow.focus();
        }
        else
        {
            playerWindow.location.href = url;
            playerWindow.focus();
        }
    }
}

var player1Window;
function openPlayer1(movieName, aspectRatio)
{
    if ( !player1Window)
    {
        player1Window = window.open( "/player1-popup.jsp?movie=" + movieName + "&aspect=" + aspectRatio
                              , "player1Window"
                              ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=500,height=320');
    }
    else
    {
       if (player1Window)
        {
            playerWindow = window.open( "/player1-popup.jsp?movie=" + movieName + "&aspect=" + aspectRatio
                                  , "player1Window"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=500,height=320');
                                player1Window.focus();
        }
        else
        {
            player1Window.location.href = url;
            player1Window.focus();
        }
    }
}



function openAdd()
{
    var obj = document.getElementById( "addShots" );
    obj.style.display = 'block';
}

function openAdd1( id)
{
	document.shotsForm.shotId.value = id ;
    var obj = document.getElementById( "addShots" );
    obj.style.display = 'block';
}


var responseTxt = "";
function addShots(  )
{
showWait( document.shotsForm.shotId.value );
if(  document.shotsForm.shotsId != null )
{
var n = document.shotsForm.shotsId.length ;
	for( i = 0; i < n ; i++)
	{
		if( document.shotsForm.shotsId[i].checked == true )
		{
			showWait( document.shotsForm.shotsId[i].value );
		}
	}
	}
  	new Ajax.Request('/addShots.do?ajax=true', 
  	{
  		method: 'post',
  		parameters: Form.serialize(document.shotsForm),
  		onSuccess: function(transport)
  		{
  			responseTxt = transport.responseText;
  			setTimeout("onSuccessAdd()",200);
  		}
  	}
  );
}



function onSuccessAdd(  )
{
	$("ajax-status").update( ""+ responseTxt );
	markAdded( document.shotsForm.shotId.value );
    document.shotsForm.shotId.value = 0 ;	
    if(  document.shotsForm.shotsId != null  )
    {		
	var n = document.shotsForm.shotsId.length ;
	for( i = 0; i < n ; i++)
	{
		if( document.shotsForm.shotsId[i].checked == true )
		{
			markAdded( document.shotsForm.shotsId[i].value );				
			document.shotsForm.shotsId[i].checked = false; 
		}
	}
	}
}

function addShot( id)
{
  document.shotsForm.shotId.value = id ;
  addShots( );
}

function showWait( shotId )
{
	var dets = $("dets_" + shotId );
	if( dets != null )
		dets.hide();
	var st = $("wait_" + shotId );
	if( st != null )
	{
		st.show();
		st.update( "Saving...." );
	}
}
function hideWait( shotId )
{
	var st = $("wait_" + shotId );
	if( st != null )
		st.hide(  );
	var dets = $("dets_" + shotId );
	if( dets != null )
		dets.show();
}

function markAdded( shotId )
{
	var plus = $("bt_" + shotId );
	if( plus != null )
	{
		plus.src = "img/b_add-a.gif";
		plus.onmouseout="this.src='img/b_add-a.gif'";	
	}	
	
	hideWait( shotId );
}


function closePopup(name)
{
	location.href = "/closePopup.do";	    
}

function hidePopup(name)
{
    objx = document.getElementById( name );
    if( objx != null )
	    objx.style.display = 'none';
}

function closeAllPopups()
{
	hidePopup("mailCliplist");
	hidePopup("createCliplist");
	hidePopup("selectCliplist");
	hidePopup("rename");
	hidePopup("copyShots");
	hidePopup("moveShots");
	hidePopup("mailCliplist");
}

  function getAnyCookie(   )
  {
    var myCookie = document.cookie;
    var index = myCookie.indexOf( "FP-LANG" );
    if (index == -1)
    	return null;
    else
    	return "";
  }

var editor ;
function openEditor(url)
{

    if ( !editor)
    {
         editor = window.open( 'editor.jsp?txt='+url, 'FramepoolAG','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=500,height=500');
    }
    else
    {
        if (editor.closed == true)
        {
            editor = window.open( 'editor.jsp?txt='+url
                                  , "FramepoolAG"
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,width=500,height=500');
			editor.focus();
        }
        else
        {
            editor.location.href = 'editor.jsp?txt='+url;
            editor.focus();
        }
    }
}
  
function openAccessInfo(  name  )
{
      win = window.open( "/" +name 
                                 , ""
                                  ,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=380,height=250');
      win.focus();
}
  
  
function deleteThisShot( shotId )
{
	if( confirm( deleteShotMessage ) )
	{

		 location.href= "/deleteShot.do?shotId=" + shotId;
	}
}  



function showAdvancedOptions( par )
{
    new Ajax.Request('/showAdvancedOptions.do?adv='+ par, 
    {
        method: 'post',
        onSuccess: function(transport)
        {
            responseTxt = transport.responseText;
           // setTimeout("onSuccessAdd()",200);
        }
    }
  );
}  