
//Function to detect Resolution 
function jsCheckMonitor() {

 
	if ( screen.width < 1024) 
		return 800;
	else if ( screen.width < 1280)
		return 1024;
	else if ( screen.width >= 1280 && screen.width <= 1400)
		return 1280;
	else if ( screen.width > 1400)
		return 1600;	
	else 
		return 1280;
}


//Function to SET Video Parameters
var strVideoWidth,strVideoHeight,strVideoPosItop, strVideoPosILeft,video_home_OBJ, iZoom;
var iFlagZoom = 0;
iFlagStopVidHome = 1;

var iResolucion = jsCheckMonitor();

switch(iResolucion){

case 800:  args="&iTamanno=800"; 
			   
			   strAncho = "105";
			   strAlto = "66";
			   strVideoWidth = "240";
			   strVideoHeight = "160";
			   strVideoPosItop = "6";
			   strVideoPosILeft = "5";
			   iFlagZoom = 0;
			   iZoom = 20;
			   
			   /*strAncho = "105";
			   strAlto = "66";
			   strVideoWidth = "240";
			   strVideoHeight = "180";  
			   strVideoPosItop = "6";
			   strVideoPosILeft = "4";
			   iFlagZoom = 0;
			   iZoom = 20;*/
			   break;
	case 1024: args="&iTamanno=1024";
	            strAncho = "120";
			   strAlto = "76";
			   strVideoWidth = "320";
			   strVideoHeight = "240";
			   strVideoPosItop = "6";
			   strVideoPosILeft = "4";
			   iZoom = 30;
			   iFlagZoom = 1;
			   /*
			   strAncho = "120";
			   strAlto = "76";
			   strVideoWidth = "320";
			   strVideoHeight = "240";
			   strVideoPosItop = "6";
			   strVideoPosILeft = "4";
			   iZoom = 30;
			   iFlagZoom = 1; */
			   break;
	case 1280: args="&iTamanno=1280";
	            strAncho = "136";
			   strAlto = "86";
			   strVideoWidth = "400";
			   strVideoHeight = "300";
			   strVideoPosItop = "5";
			   strVideoPosILeft = "10";
			   iFlagZoom = 1;
			   iZoom = 25;
			   /*
			   strAncho = "136";
			   strAlto = "86";
			   strVideoWidth = "400";
			   strVideoHeight = "320";
			   strVideoPosItop = "6";
			   strVideoPosILeft = "4";
			   iFlagZoom = 1;
			   iZoom = 25;*/
			   break;
    case 1600: args="&iTamanno=1600";
			   strAncho = "156";
			   strAlto = "96";
			   strVideoWidth = "510";
			   strVideoHeight = "400";
			   strVideoPosItop = "6";
			   strVideoPosILeft = "4";
			   iZoom = 50;
			   break;
	default:   args="&iTamanno=1024";
			    strAncho = "120";
			   strAlto = "76";
			   strVideoWidth = "320";
			   strVideoHeight = "240";
			   strVideoPosItop = "6";
			   strVideoPosILeft = "4";
			   iZoom = 30;
			   iFlagZoom = 1;
			   
			   /*strAncho = "120";
			   strAlto = "76";
			   strVideoWidth = "320";
			   strVideoHeight = "240";
			   strVideoPosItop = "6";
			   strVideoPosILeft = "4";
			   iFlagZoom = 1; 
			   iZoom = 30;*/
			   break;
	
}


function writeFo()
{
    if( document.getElementById("divConsultCJ") != null && document.getElementById("divConsultCJ") != 'null' && document.getElementById("divConsultCJ") != 'undefined' ) 
    {
        document.getElementById("divflipPage").style.display='none';
        document.getElementById("divConsultCJ").style.display = 'block';
        window.setTimeout('writeFoOld()', '5000');
    }
    else
    {
        writeFoOld();
    }
}

//Funciton to write Flipping oject
function writeFoOld() {
      
    //alert('called');
    
    if( document.getElementById("divConsultCJ") != null && document.getElementById("divConsultCJ") != 'null' && document.getElementById("divConsultCJ") != 'undefined' ) 
    {
        document.getElementById("divConsultCJ").style.display = 'none';
    }
    
    document.getElementById("divflipPage").style.display="block";
        try
        {
         
                switch(jsCheckMonitor())
                {
                        case 800:  args="&iTamanno=800"; 
		                           strAncho = "170";		           
		                           strAlto = "110";	
		                           strResolution = "800";	  
		                           break;
                        case 1024: args="&iTamanno=1024";
		                           strAncho = "200";
		                           strAlto = "120";
		                           strResolution = "1024";		  
		                           break;
                        case 1280: args="&iTamanno=1280";
		                           strAncho = "250";
		                           strAlto = "150";
		                           strResolution = "1280";		  
		                           break;
		                case 1600: args="&iTamanno=1600";
		                           strAncho = "300";
		                           strAlto = "160";
		                           strResolution = "1600";		  
		                           break;
                        default:   args="&iTamanno=1024";
		                           strAncho = "200";
		                           strAlto = "130";
		                           strResolution = "1024";
		                           break;
                }

                Argument = Argument.replace("#",strResolution);
                Argument = Argument.replace("#",strResolution);  
                Argument = Argument.replace("#",strResolution); 
                Argument = Argument.replace("#",strResolution);
                Argument = Argument.replace("#",strResolution);  
                Argument = Argument.replace("#",strResolution);                    
            
                if(Argument != '')
                {                  
                   
	                var foFlip = new FlashObject(FlashPath, 'hojear', strAncho , strAlto, '7', '');
	                foFlip.addParam('FlashVars', Argument);
	                foFlip.addParam('wmode', 'transparent');
	                foFlip.write('flashcontent');
                }
                else
                {
        	        document.getElementById('flashcontent').innerHTML = 'Datos de XML no disponibles en base de datos. <br/> Generarlo por favor con <br/>proceso de hornada.';
                	
                }
        	   
         }
         catch(ex)
         {
            alert(ex);
         }

      
        }


 function hojearFlash(tipo,loadsup,bodyid) 
    {
    
        try
        {   
            if(tipo.length > 3)
            {
                var tipoNombre = tipo.split("/");		
                tipoNombre = tipoNombre[tipoNombre.length-1];		
                tipoNombre = tipo.split("_");		
                tipoNombre = tipoNombre[tipoNombre.length-1];                                        
            }
            else
            {
                 var tipoNombre =  tipo;     	
            }
            
            if ( bodyid == undefined )
            {
                window.open("/FlashObject/FlippingDetailPage.aspx?IsInternal=true&SupplementId="+tipoNombre+"&BodyID=0&dt="+ strDate ,"popup","scrollbars=yes,resizable=no,fullscreen=yes");
            }
            else
            {
                window.open("/FlashObject/FlippingDetailPage.aspx?IsInternal=true&SupplementId="+tipoNombre+"&BodyID=" + bodyid + "&dt="+ strDate ,"popup","scrollbars=yes,resizable=no,fullscreen=yes");
            }
         }
         catch(ex)
         {
           
         }
        
    }


function ShowVideo()
{   
    VideoToPlay = 0;
    document.getElementById("dvVideo").style.display="block";
    document.getElementById("divflipPage").style.display="none";
    document.getElementById("flashcontent").innerHTML = '';
    
    if( document.getElementById("divConsultCJ") != null && document.getElementById("divConsultCJ") != 'null' && document.getElementById("divConsultCJ") != 'undefined' ) 
    {
        document.getElementById("divConsultCJ").style.display = 'none';
    }
    
    playHomePageVideo(0);
  
    
}
 

function PlayMedia(VideoArgs)
{
    try
      {        
        document.getElementById('video_home').style.width = strVideoWidth;
	    document.getElementById('video_home').style.height = strVideoHeight; 
	    
	    VideoArgs =  VideoArgs.replace('_800','_' + screen.width);
	    VideoArgs =  VideoArgs.replace('_800','_' + screen.width);
    	VideoArgs =  VideoArgs.replace('&iPercent=25','&iPercent=' + iZoom);
	    var args=VideoArgs + StreamingParameter;	  	    
	    var video_home_OBJ = new FlashObject("/FlashObject/videoHomeV2.swf", "video_home_SWF", strVideoWidth, strVideoHeight, "7", "");
	    video_home_OBJ.addParam('FlashVars', args);
	    video_home_OBJ.addParam('wmode', 'transparent');
	    
    	
        //alert(document.getElementById('video_home_div').style.left);
       
       
       document.getElementById('video_home_div').style.left = strVideoPosILeft;
              
	   document.getElementById('video_home_div').style.top = strVideoPosItop;
    	
    	//alert(strVideoPosILeft + ' ' + strVideoPosItop);
	    //var iPosLeftIni = strVideoPosILeft;
	    var iPosTopIni = strVideoPosItop;
	   
	   video_home_OBJ.write("video_home_div");
	 }
	 catch(ex)
	 {
	    alert(ex);
	 }
}

function reWriteVideo() 
{   
 
}
