/**
 * webarchive v1.0.0: WebArchive dinamically height and width for modal panel - http://www.swissbytes.ch
 *
 */

function setDocHeight(){ 
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}	
	
    var newHeight = 700;
	var newWidth = 830;

	if (myHeight < 700)
		newHeight = myHeight - 20;
	if (myWidth < 830)
		newWidth = myWidth - 20;  							
		
	Richfaces.showModalPanel('modalPPlayerId',{width:newWidth, height:newHeight});
	if(eval("typeof initializeThreeDots == 'function'")){
		initializeThreeDots();
	}
}	

function setCustomDocHeight(theWidth, theHeight){	
	Richfaces.showModalPanel('modalPPlayerId',{width:theWidth, height:theHeight});
	if(eval("typeof initializeThreeDots == 'function'")){
		initializeThreeDots();
	}
}

function setDocHeightPlayAllPlayer(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}	
	
    var newHeight = 720;
	var newWidth = 830;

	if (myHeight < 700)
		newHeight = myHeight - 20;
	if (myWidth < 830)
		newWidth = myWidth - 20;  							
	
	Richfaces.showModalPanel('playAllPlayerId',{width:newWidth, height:newHeight});	
}


function setDocHeightTraFileLayer(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}	
	
    var newHeight = 510;
	var newWidth = 810;

	if (myHeight < newHeight)
		newHeight = myHeight - 20;
	if (myWidth < newWidth)
		newWidth = myWidth - 20;  							
	
	Richfaces.showModalPanel('traFilePanel',{minWidth:newWidth, minHeight:newHeight});	
}

function setDocHeightWaitResponsePanel( bool, modalPanelId ){
	
	if ( bool == true ){
	
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			myWidth = window.innerWidth; myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
			myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
		}	
		
	    var newHeight = 100;
		var newWidth = 300;
	
		if (myHeight < newHeight)
			newHeight = myHeight - 20;
		if (myWidth < newWidth)
			newWidth = myWidth - 20;  							
		
		Richfaces.showModalPanel(modalPanelId,{width:newWidth, height:newHeight});
	}else{
		Richfaces.hideModalPanel(modalPanelId);
		Richfaces.hideModalPanel('traFilePanel');						
	}
}

//traRejectFilePanel
function setDocHeightTraRejectFileLayer(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}	
	
    var newHeight = 255;
	var newWidth = 750;

	if (myHeight < newHeight)
		newHeight = myHeight - 20;
	if (myWidth < newWidth)
		newWidth = myWidth - 20;  							
	
	Richfaces.showModalPanel('traRejectFilePanel',{width:newWidth, height:newHeight});	
}

function setDocHeightTraOnDemandLayer( showPanel, pixelSize, basicFormats, accountFormats, mediaOrder){
	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}	
	
    var newHeight = 640;
	var newWidth = 430;
	
	if( showPanel == false){
		newHeight = 150;	
	  
	}else{
		if( pixelSize == true ){
			
			if( basicFormats == false ){
				newHeight = newHeight - 220
			}
			
			if( accountFormats == false ){
				newHeight = newHeight - 220
			}
			
			if(mediaOrder == false){
				newHeight = newHeight - 20
			}
			
		}else{
			newHeight = 150 ;
		}
	}
	
	if (myHeight < newHeight)
		newHeight = myHeight - 20;
	
	if (myWidth < newWidth)
		newWidth = myWidth - 20;  							
	
	Richfaces.showModalPanel('traOnDemandPanel',{minWidth:newWidth, minHeight:newHeight,width:newWidth, height:newHeight, resizeable: false});
	
}

//traOnDemandConfirmationPanel
function setDocHeightTraOnDemandConfirmationLayer(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}	
	
    var newHeight = 575;
	var newWidth = 445;

	if (myHeight < newHeight)
		newHeight = myHeight - 20;
	if (myWidth < newWidth)
		newWidth = myWidth - 20;  							
	
	Richfaces.showModalPanel('traOnDemandConfirmationPanel',{width:newWidth, height:newHeight});	
}

function setDocHeightTraAddProfileLayer(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}	
	
    var newHeight = 540;
	var newWidth = 639;

	if (myHeight < newHeight)
		newHeight = myHeight - 20;
	if (myWidth < newWidth)
		newWidth = myWidth - 20;  							
		
	Richfaces.showModalPanel('aditionalPanel',{minWidth:newWidth, minHeight:newHeight, width:newWidth, height:newHeight});	
}

function setDocHeightTraSaveChanged( bool, modalPanelId ){
	
	if( bool == false){
		
		var myWidth = 0, myHeight = 0;
		
		if( typeof( window.innerWidth ) == 'number' ) {
			myWidth = window.innerWidth; myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
			myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
		}	
		
	    var newHeight = 120;
		var newWidth = 350;
	
		if (myHeight < newHeight)
			newHeight = myHeight - 20;
		if (myWidth < newWidth)
			newWidth = myWidth - 20;  							
		
		Richfaces.showModalPanel(modalPanelId,{width:newWidth, height:newHeight});		
	}
	else{
		Richfaces.hideModalPanel('aditionalPanel');
	}	
}



function enlargePic(elm) {	 
  var selector = "";
  var selectorRemoveImageOnTop = "#tapeEntryTP\\:tapeEntryTable img.foo";

  try {
	selector = eval("");
	selectorRemoveImageOnTop = eval("#tapeEntryTP\\:tapeEntryTable img.foo");
  } catch (e) {}
  
  jQuery(selectorRemoveImageOnTop).removeClass('image-ontop');   
  jQuery(elm || selector).addClass('image-ontop');
  jQuery(elm || selector).stop().animate({width:'120px'}, 1000);
}

function resetOnMiddleImg(elm){
	var selector = "";
	
	try {	
		selector = eval("");
	} catch (e) {}
	
	jQuery(elm || selector).removeClass('image-onmiddle');	
}

function normalPic(elm) {	 
    var selector = "";
	var selectorRemove = "#tapeEntryTP\\:tapeEntryTable img.foo";

	try {
	    selector = eval("");
	    selectorRemove = eval("#tapeEntryTP\\:tapeEntryTable img.foo");
	} catch (e) {}
	
	jQuery(elm || selector).removeClass('image-ontop');	 	
	jQuery(elm || selector).addClass('image-onmiddle');
	jQuery(elm || selector).stop().animate({width:'30px'},70, function() { resetOnMiddleImg(elm); });	
}

var oldRow;

function changeColor(row)
{
    if (oldRow!=undefined)
    {
       oldRow.style.backgroundColor='#ffffff';
    } 
    row.style.backgroundColor='#949596'; 
    oldRow=row;
}

function addClickedClass(elm)
{
	var selector = "";
	
	try {	
		selector = eval("");
	} catch (e) {}
	
	jQuery(elm || selector).addClass('clicked');	
}

function mouseOverChangeColor(elm){
	 var selector = "#tapeEntryTPE\\:tapeEntryTable tr";
	 
	 try {
	     selector = eval("#tapeEntryTPE\\:tapeEntryTable tr");
	 } catch (e) {}
	 
	 jQuery(selector).mouseover(function(){jQuery(elm).addClass('active-row')});
}

function mouseOutChangeColor(elm){
	 var selector = "#tapeEntryTPE\\:tapeEntryTable tr";
	 
	 try {
	     selector = eval("#tapeEntryTPE\\:tapeEntryTable tr");
	 } catch (e) {}
	 
	 jQuery(selector).mouseout(function(){jQuery(elm).removeClass('active-row')});
}

function blinkEffect(){
    var selector = "#blinkDiv";
    try {
        selector = eval("#blinkDiv");
    } catch (e) {}
    
    jQuery(selector).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200);
}

function blinkEffectAll(){
    var selector = "#blinkDivAll";
    try {
        selector = eval("#blinkDivAll");
    } catch (e) {}
    
    jQuery(selector).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200);
}

function clearStatusMsg(){
	if (document.getElementById("playStatus")) {
		document.getElementById("playStatus").innerHTML = "";
	}
	if (document.getElementById("playDownloadIcon")) {
		document.getElementById("playDownloadIcon").style.display = "none";
	}
	if (document.getElementById("videoContent")) {
		document.getElementById("videoContent").innerHTML = "";
	}
}
function showfileObjectsTEIdTable(){
	document.getElementById("fileObjectsTEIdTable").style.display = "";	
}

