﻿var http = createRequestObject();
function createRequestObject() {
    // find the correct xmlHTTP, works with IE, FF and Opera
    var xmlhttp;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xmlhttp = null;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;

}
function SetHTTP_Header(params) {
   
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");
}


var contentname="";
var changeImageSeconds=3000;
var position="top";
function flasheffectHtml()
{
   try
   {
   
        tabcount=document.getElementById('hiden_tabcount').value;
        currenttab=tabcount;
        var Imagcount= document.getElementById('hiden_changingFlashcount').value;
      
        Imagcount=parseInt(Imagcount)+1;

        var params = 'count=' + Imagcount+'&tabcount='+tabcount;
        http.open('get', 'changingImages/flashfunction.aspx?changingImages=true&' + params,'true');
        http.onreadystatechange = GetFlashImages;
       // SetHTTP_Header(params);
        http.send(null);
    }
    catch(ifitsnotaflashpage)
    {
    }
}

var currentseconds="";
function GetFlashImages() 
{
    if (http.readyState == 4) 
    {
        var response = http.responseText;
        var contentname="";
         var tabpos="";
        
          var currenttabnumber="";
            var newtabnumber="";
        if (response.indexOf('contentname:') != -1) 
        {
            var arr = new Array();
            arr = response.split('contentname:');
            arr = arr[1].split(':contentname');
            contentname = arr[0];
        }
       
          if (response.indexOf('flashCount:') != -1) 
        { 
            arr = new Array();
            arr = response.split('flashCount:');
            arr = arr[1].split(':flashCount');
            document.getElementById('hiden_changingFlashcount').value = arr[0];
            }
            
              if (response.indexOf('seconds:') != -1) 
        { 
            arr = new Array();
            arr = response.split('seconds:');
            arr = arr[1].split(':seconds');
            currentseconds=arr[0];
             }
            
              if (response.indexOf('tabpos:') != -1) 
        { 
            arr = new Array();
            arr = response.split('tabpos:');
            arr = arr[1].split(':tabpos');
            tabpos=arr[0];
            }
           
              if (response.indexOf('tabnumber:') != -1) 
        { 
            arr = new Array();
            arr = response.split('tabnumber:');
            arr = arr[1].split(':tabnumber');
             newtabnumber=arr[0];
              currenttabnumber=arr[0];
            }
        
            if(tabpos=="newtab")
            {
            if(newtabnumber!=0)
            {
              currenttabnumber=parseInt(newtabnumber)-1;
              }
              
            }
             document.getElementById('hiden_tabcount').value=newtabnumber;
             click_changeImage(contentname,document.getElementById('hiden_changingFlashcount').value, currenttabnumber);
             flash_expand(currentseconds);
        
    }
}
var timerid="";
function flash_expand(seconds)
{
        changeImageSeconds=parseInt(seconds)*1000;
        if (document.layers)
            timerid=setTimeout("flasheffectHtml();", changeImageSeconds)
        else if (document.all)
            timerid=setTimeout("flasheffectHtml();", changeImageSeconds)
        else if (document.getElementById) {
        
            timerid=setTimeout("flasheffectHtml();", changeImageSeconds)
        }
        return
  
    
}
var lastTab="";
var lastImage="";
function ClickFromPage(tabcount)
{
    //var st="<a href=\"javascript:stop_image()\"><img style=\"border:0;\" src=\"changingImages/Images/pause.png\" /></a>"; 
    //document.getElementById('play_pause').innerHTML=st;
    document.getElementById('hiden_tabcount').value=tabcount;
    document.getElementById('hiden_changingFlashcount').value=-1;
    clearTimeout(timerid);
   
        click_changeImage("",-1,tabcount);
    flash_expand(0);
}

function ClickFromPage_old(content,count,secondsOnClick,tabcount,tabname)
{
  click_changeImage(content,count);
  clearTimeout(timerid);
  flash_expand(secondsOnClick);
}
var currentvolume="";
function click_changeImage(content,count,tabnumber)
{

    document.getElementById('hiden_contentname').value = content;
    document.getElementById('hiden_changingFlashcount').value=count;
    lastImage=content;
    if(lastTab!="")
    {
       document.getElementById(lastTab).className="CSSTab";
    }
    document.getElementById('div_tab_'+tabnumber).className="CSSTabActive";
    lastTab='div_tab_'+tabnumber;
    var strng="";
    var arr=content.split('.');
    if(arr[1]=="flv")
    {
    
    //var controller=new Array();
    //controller=content.split('_controller');
    var path="changingImages/contents/";
    var wid=parseInt(screen.width)-10;
    //<a style=\"text-decoration:none\" href=\"productInfo.aspx?redirect=true&id="+targetmenu+"&page="+folder+"\"></a>
//    strng=" <div style=\"height:700px;width:100%;\">";
//    strng += "<object id=\"tester\" style=\"float:left;text-align:left;paddin:0;margin:0;\" id=\"jud_change\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"100%\" height=\"700px\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version==8\">";
//    strng += "<param name=\"src\" value=\""+path + content + "\"/>";
//    strng += "<param name=\"bgcolor\" value=\"FFFFFF\"/>";
//    strng += "<param name=\"quality\" value=\"best\"/>";
//    strng += "<param name=\"allowScriptAccess\" value=\"always\"/>";
//    strng += "<param name=\"flashVars\" value=\"csConfigFile=" +path+ controller[0] + "_config.xml&csColor=FFFFFF\"/>";
//    strng += "<embed  name=\"tester\" src=\"" +path+ content + "\" width=\"100%\" height=\"700px\" bgcolor=\"FFFFFF\" flashVars=\"csConfigFile="+path+controller[0]+"_config.xml&csColor=FFFFFF\"  quality=\"best\" allowScriptAccess=\"always\" pluginspage=\"http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>";
//    strng += "</object>";
//    strng+="</div>";



     strng="<a href=\""+path + content+"\" style=\"display:block;width:870px;height:700px\" id=\"player\"></a>"; 
     document.getElementById('middle_image').innerHTML=strng;
     flowplyr= flowplayer("player", "changingImages/flowplayer-3.1.3.swf",{clip:{autoPlay:false,autoBuffering: true },onPause:function(){StopFromflash();},onResume:function(){fromflash();}});
    }
    else
    {
     strng="<div style=\"height:700px;width:100%;\">";
     strng+="<div><img alt=\"\" style=\"height:700px;width:100%;border:0px;\" src=\"changingImages/contents/"+content +"\"/></div>";
     strng+="</div>";
     document.getElementById('middle_image').innerHTML=strng;
    
   }
     return; 
}
function callplugin()
{
 var cv=flowplyr.toggle()
 
}
var flowplyr="";

function pre_Image(ct)
{

    var count= document.getElementById('hiden_changingFlashcount').value;
   
   /* if(count=parseInt(ct)-1)
    {
     document.getElementById('div_prev').style.display="none";
    }
    else
    {
    document.getElementById('div_prev').style.display="block";
    }*/
  
   
  var prevTab=0;
    if(parseInt(currenttab)<parseInt(ct) && parseInt(currenttab)!=0)
    {
    
        prevTab=parseInt(currenttab)-1;
    }
    else
    {
        if(parseInt(currenttab)==0)
        {
           prevTab=parseInt(ct)-1;
        }
    }
    
       document.getElementById('hiden_changingFlashcount').value = -1;
       currenttab=prevTab;
       document.getElementById('hiden_tabcount').value=prevTab;
       
       ChangeStartPicture();
   flasheffectHtml();
   
}
function stop_image()
{
  if(flowplyr!="")
  {
    flowplyr.pause();
  }
  StopFromflash();
}
function StopFromflash()
{

clearTimeout(timerid);

var st="<a href=\"javascript:start_image()\"><img style=\"border:0;\" src=\"changingImages/Images/play.png\" /></a>"; 

//document.getElementById('play_pause').innerHTML=st;
}
function ChangeStartPicture()
{

var st="<a href=\"javascript:stop_image()\"><img style=\"border:0;\" src=\"changingImages/Images/pause.png\" /></a>"; 
//document.getElementById('play_pause').innerHTML=st;
}
function start_image()
{
if(flowplyr!="")
  {
    flowplyr.play();
  }
  fromflash();
}
function fromflash()
{

document.getElementById('hiden_tabcount').value=parseInt(document.getElementById('hiden_tabcount').value)-1;
var st="<a href=\"javascript:stop_image()\"><img style=\"border:0;\" src=\"changingImages/Images/pause.png\" /></a>"; 
//document.getElementById('play_pause').innerHTML=st;
      //  flasheffectHtml();
    flash_expand(currentseconds);
}
var nexttab=0;
var currenttab=0;
function next_image(ct)
{
    var count= document.getElementById('hiden_changingFlashcount').value;
   
    if(currenttab<parseInt(ct)-1)
    {
     nexttab=parseInt(currenttab)+1;
    }
    else
    {
      nexttab=-1;
    }
   
    document.getElementById('hiden_changingFlashcount').value = -1;
    document.getElementById('hiden_tabcount').value=nexttab;
   ChangeStartPicture();
   flasheffectHtml();
}
function testVolume()
{

    var strng=" <div style=\"height:700px;width:100%;\">";
    strng += "<object  style=\"float:left;text-align:left;paddin:0;margin:0;\" id=\"jud_change\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"100%\" height=\"700px\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version==8\">";
    strng += "<param name=\"src\" value=\"changingImages/contents/Judah_Demo_Sharing_Final_controller.swf\"/>";
    strng += "<param name=\"bgcolor\" value=\"FFFFFF\"/>";
    strng += "<param name=\"quality\" value=\"best\"/>";
    strng += "<param name=\"allowScriptAccess\" value=\"always\"/>";
    strng += "<param name=\"flashVars\" value=\"csConfigFile=changingImages/contents/Judah_Demo_Sharing_Final_config.xml&csColor=FFFFFF\"/>";
    strng += "<embed  src=\"changingImages/contents/Judah_Demo_Sharing_Final_controller.swf\" width=\"100%\" height=\"700px\" bgcolor=\"FFFFFF\" flashVars=\"csConfigFile=changingImages/contents/Judah_Demo_Sharing_Final_config.xml&csColor=FFFFFF\"  quality=\"best\" allowScriptAccess=\"always\" pluginspage=\"http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>";
    strng += "</object>";
    strng+="</div>";
   
    document.getElementById('newflash').innerHTML = strng;
    
}
function getFlashNEW()
{
        tabcount=document.getElementById('hiden_tabcount').value;
        currenttab=tabcount;
        var Imagcount= document.getElementById('hiden_changingFlashcount').value;
      
        Imagcount=parseInt(Imagcount)+1;

        var params = 'count=' + Imagcount+'&tabcount='+tabcount;
        http.open('get', 'changingImages/flashfunction.aspx?changingImages=true&newflash=true&' + params,'true');
        http.onreadystatechange = GetFlashTrial;
       // SetHTTP_Header(params);
        http.send(null);
}
function GetFlashTrial()
{
 if (http.readyState == 4) 
    {
      testVolume();
    }
}
