var isWorking = false;
var isWorking_slideshow = false;
var isWorking_scroll=false;
var QueryMovieList_isWorking = false;
var PromoReward_isWorking = false;
var PromoBuilder_isWorking = false;
var PromoReset_isWorking = false;
var ISSS_isWorking = false;
var productlisthandleAjax = false;
var PDFOnTheFly_isWorking=false;
var is_Functions_isWorking = false;
var url = "GetMoviesData.php?Product_Id=";
var urlML = "GetMoviesList.php?";
var urlPromoReward = "PromoReward.php";
var http = getHTTPObject();
var http_slideshow = getHTTPObject();
var thisMovieComment=null;
var DiviaAction="";
var DiviaMovieCode=-1;
var DiviaMovielistPosition=-1;
var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;
MessageBoxPrototype = new String ('<table border=0 CELLSPACING="0" cellpadding="0" style="padding:0px;margin:0px"><tr><td><img src="./images/ltcmsg.gif" width="4px" height="4px"></img></td><td bgcolor="#002B00" colspan="4"></td><td><img src="./images/rtcmsg.gif" width="4px" height="4px"></td></tr><tr><td bgcolor="#002B00" colspan="6"></td><td><img src="./images/srtcmsg.gif" width="4px" height="4px"></td></tr><tr height="4px"><td width="4px" bgcolor="#002B00" colspan="4"></td><td bgcolor="#002B00"><img class="closebox" src="./images/cancel.png" width="20px" height="20px" onclick="closepopupdiv(\'MessageContainer\',\'MessageId\')"></td><td bgcolor="#002B00" width="4px"></td><td bgcolor="#000000"></td></tr><tr bgcolor="#002B00"><td width="4px" colspan="2"></td><td colspan="2" style="padding-left:20px;">MessageText</td><td width="4px" colspan="2"></td><td width="4px" style="background-color:#000000"></td></tr><tr><td bgcolor="#002B00" colspan="6" height="20px"></td><td bgcolor="#000000"></td></tr><tr><td><img src="./images/lbcmsg.gif" width="4px" height="4px"></img></td><td bgcolor="#002B00" colspan="4"></td><td><img src="./images/rbcmsg.gif" width="4px" height="4px"></td><td bgcolor="#000000"></td></tr><tr height="4px"><td></td><td><img src="./images/slbcmsg.gif" width="4px" height="4px"></img></td><td style="background-color:#000000" colspan="4"></td><td><img src="./images/srbcmsg.gif" width="4px" height="4px"></img></td></tr></table>');
MessageBoxNoClosePrototype = new String ('<table border=0 CELLSPACING="0" cellpadding="0" style="padding:0px;margin:0px"><tr><td><img src="./images/ltcmsg.gif" width="4px" height="4px"></img></td><td bgcolor="#002B00" colspan="4"></td><td><img src="./images/rtcmsg.gif" width="4px" height="4px"></td></tr><tr><td bgcolor="#002B00" colspan="6"></td><td><img src="./images/srtcmsg.gif" width="4px" height="4px"></td></tr><tr height="4px"><td width="4px" bgcolor="#002B00" colspan="4"></td><td width="20px" height="20px" bgcolor="#002B00"></td><td bgcolor="#002B00" width="4px"></td><td bgcolor="#000000"></td></tr><tr bgcolor="#002B00"><td width="4px" colspan="2"></td><td colspan="2" style="padding-left:20px;">MessageText</td><td width="4px" colspan="2"></td><td width="4px" style="background-color:#000000"></td></tr><tr><td bgcolor="#002B00" colspan="6" height="20px"></td><td bgcolor="#000000"></td></tr><tr><td><img src="./images/lbcmsg.gif" width="4px" height="4px"></img></td><td bgcolor="#002B00" colspan="4"></td><td><img src="./images/rbcmsg.gif" width="4px" height="4px"></td><td bgcolor="#000000"></td></tr><tr height="4px"><td></td><td><img src="./images/slbcmsg.gif" width="4px" height="4px"></img></td><td style="background-color:#000000" colspan="4"></td><td><img src="./images/srbcmsg.gif" width="4px" height="4px"></img></td></tr></table>');
MenuItemTemplate=new String ('<table border=0 CELLSPACING="0" cellpadding="0" style="padding:0px;margin:0px"><tr><td><img src="./images/ltcmsg.gif" width="4px" height="4px"></img></td><td bgcolor="#002B00" colspan="2"></td><td><img src="./images/rtcmsg.gif" width="4px" height="4px"></td></tr><tr><td bgcolor="#002B00" colspan="4"></td><td><img src="./images/srtcmsg.gif" width="4px" height="4px"></td></tr><tr bgcolor="#002B00"><td width="4px"></td><td></td><td>%MenuItemText%</td><td width="4px" colspan="1"></td><td width="4px" style="background-color:#000000"></td></tr><tr bgcolor="#002B00" height="4px"><td colspan="4"></td><td bgcolor="#000000"></td></tr><tr><td><img src="./images/lbcmsg.gif" width="4px" height="4px"></img></td><td bgcolor="#002B00"></td><td bgcolor="#002B00" colspan="1"></td><td><img src="./images/rbcmsg.gif" width="4px" height="4px"></td><td bgcolor="#000000"></td></tr><tr height="4px"><td width="4px" ></td><td><img src="./images/slbcmsg.gif" width="4px" height="4px"></img></td><td style="background-color:#000000" colspan="2"></td><td><img src="./images/srbcmsg.gif" width="4px" height="4px"></img></td></tr></table>');

Array.prototype.has = function (itemarray,arraybase){
  var ItemIdx;
  var ItemInArray=false;
  for (ItemIdx = arraybase; ItemIdx <= itemarray; ItemIdx++) {
    if (this[ItemIdx]){ItemInArray=true;}
  }
  return ItemInArray;
}

var UserCodeNumIn=0;
var UserPINNumIn=0;
var InitMovielistIdx=1;
var MovielistOver=0;
var MovielistPosition=0;
var MovielistPositionPrev=0;
var TopOffset=0;
var MovieListLen=17;
var MovielistItemsNum=50;
var MovieListHeight=25*17;
var MovieListElementHeight=25;
var CausedClick=true;

function PopUpOpen(OpeningPage,PageWidth,PageHeight,PageName){
  var LeftPosition = (screen.width) ? (screen.width-PageWidth)/2 : 0;
  var TopPosition = (screen.height) ? (screen.height-PageHeight)/2 : 0;
  var settings = "left="+LeftPosition+", top="+TopPosition+", height="+PageHeight+", width="+PageWidth+", titlebar=no, location=no, menubar=no,status=no, toolbar=no, statusbar=no";
  var NewWindow = window.open(OpeningPage,PageName,settings);
  NewWindow.focus();
}

function PopUpClose(PageName){
  window.close(PageName);
}

function SetLang(FormId,Lang){
             FormId.langselected.value=Lang;
}

function getHTTPObject() {

  var xmlHttpReq;

  xmlHttpReq = false;

  if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }

  if (!xmlHttpReq && typeof XMLHttpRequest != "undefined") {
  	 try {xmlHttpReq = new XMLHttpRequest();}
	 catch(e) {xmlHttpReq = false;}
  }

  return xmlHttpReq;

}

function ValueOfElement(PassedElement){

  var PassedElementValue=null;

  if (document.getElementById(PassedElement) != null){
    PassedElementValue=document.getElementById(PassedElement).value;
  }

  return PassedElementValue;

}

function IHTMLOfElement(PassedElement){

  var PassedElementValue=null;

  if (document.getElementById(PassedElement) != null){
    PassedElementValue=document.getElementById(PassedElement).innerHTML;
  }

  return PassedElementValue;

}

function ChgSrchType(Switch) {
  switch (Switch){
  case 'Short':
    AlterElement('wsdiv_media_long','visibility',false);
    AlterElement('wsdiv_media_short','visibility',true);
    AlterElement('wsdiv_media_az','visibility',false);
    AlterElement('ChgSrchType_Long','forecolor',"#999999");
    AlterElement('ChgSrchType_Short','forecolor',"#CCFFCC");
    AlterElement('ChgSrchType_AZ','forecolor',"#999999");
    break;
  case 'Long':
    AlterElement('wsdiv_media_long','visibility',true);
    AlterElement('wsdiv_media_short','visibility',false);
    AlterElement('wsdiv_media_az','visibility',false);
    AlterElement('ChgSrchType_Long','forecolor',"#CCFFCC");
    AlterElement('ChgSrchType_Short','forecolor',"#999999");
    AlterElement('ChgSrchType_AZ','forecolor',"#999999");
    break;
  case 'AZ':
    AlterElement('wsdiv_media_long','visibility',false);
    AlterElement('wsdiv_media_short','visibility',false);
    AlterElement('wsdiv_media_az','visibility',true);
    AlterElement('ChgSrchType_Long','forecolor',"#999999");
    AlterElement('ChgSrchType_Short','forecolor',"#999999");
    AlterElement('ChgSrchType_AZ','forecolor',"#CCFFCC");
    break;
  }

  return Switch;

}

function ChgMovieSelType(Switch) {

  switch (Switch){
  case 'Search':
    if (document.getElementById('lstMovies') != null){
      document.getElementById('lstMovies').style.visibility = "hidden";
    }
    if (document.getElementById('lstActorInMovies') != null){
      document.getElementById('lstActorInMovies').style.visibility = "visible";
    }
    break;
  case 'Result':
    if (document.getElementById('lstMovies') != null){
      document.getElementById('lstMovies').style.visibility = "visible";
    }
    if (document.getElementById('lstActorInMovies') != null){
      document.getElementById('lstActorInMovies').style.visibility = "hidden";
    }
    break;
  }

  return Switch;

}

function CustomerAction(InSwitch,SpecialParm) {
  if (!isWorking && http) {
    var AdditionalParms="";
    var thisMovieComment_t="";
    var thisMovieComment="";
    var thisMovieComment_n="";

    if (!SpecialParm){SpecialParm=0;}

    SpecialParm=escape(SpecialParm);
    InSwitch=escape(InSwitch);

    CurrAction=trim(escape(InSwitch.substring(0,2)));

    switch (CurrAction){
    case 'MC':
      if (ValueOfElement('txt_commentmovie') != null){
	    thisMovieComment_t=ValueOfElement('txt_commentmovie_t').value;
	    thisMovieComment=ValueOfElement('txt_commentmovie').value;
	    thisMovieComment_n=ValueOfElement('txt_commentmovie_n').value;
	  }
      AdditionalParms="&MovieComment_T="+thisMovieComment_t+"&MovieComment="+thisMovieComment+"&MovieComment_N="+thisMovieComment_n;
      break;
    case 'WL': //Wish List
      AdditionalParms="&ProductKey="+SpecialParm;
      break;
    case 'SC': //Shopping Cart
      AdditionalParms="&MovieKey="+SpecialParm;
      break;
    case 'OB': //Our Best
      AdditionalParms="&ProductKey="+SpecialParm;
      break;
    case 'WB': //Web Booking
      AdditionalParms="&ProductKey="+SpecialParm;
      break;
    case 'HD': //Home Delivery
      AdditionalParms="&ProductKey="+SpecialParm;
      break;
    }
	  popupbox('waitbox','pagecontent','Attendi per favore...','open',false);
    http.open("POST", "custfuncs.php", true);
    http.onreadystatechange = CustomerAction_Return;
    isWorking = true;
    http.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8' );
    http.send("Action="+InSwitch+AdditionalParms);
  }
}

function QueryMovieData(MovieCode,PassedMovielistPosition,OnClickAction,QtyBox,PriceBox) {
  if (MovielistOver==0){
    if (document.getElementById('InitMovielistIdx') != null){
      InitMovielistIdx=document.getElementById('InitMovielistIdx').value;
    }
    MovielistOver=InitMovielistIdx;
    MovielistPosition=InitMovielistIdx;
    MovielistPositionPrev=InitMovielistIdx;
  }
  
  if (!isWorking && http && CausedClick) {
    MovielistPosition=PassedMovielistPosition;
    ScrollAction='';

	if (MovielistPositionPrev>MovielistPosition){
      ScrollAction = 'oru';
    }
    if (MovielistPositionPrev<MovielistPosition){
      ScrollAction = 'ord';
    }

	switch (ScrollAction){
    case 'oru':
      MovielistOver=MovielistPosition - Math.floor(MovielistPosition/MovieListLen)*MovieListLen;
      break;
    case 'ord':
      MovielistOver=MovielistPosition + Math.floor(MovielistPosition/MovieListLen)*MovieListLen;
      break;
    }

	if (document.getElementById('numberofmovies') != null){
      MovielistItemsNum=document.getElementById('numberofmovies').value;
    }
    if (MovielistItemsNum<MovieListLen){MovieListLen=MovielistItemsNum;}
		if (MovielistPositionPrev==0){MovielistPositionPrev=1;}
		//alert(MovielistPositionPrev);
		AlterElement('mle_' + MovielistPositionPrev,'forecolor','#000000');
		//AlterElement('mle_' + MovielistPositionPrev,'bkimage','url(\'./images/layout/navmenubk.png\')');
		AlterElement('mle_' + MovielistPositionPrev,'bkimage','');
		AlterElement('mle_' + MovielistPosition,'forecolor','#FF6600');
		AlterElement('mle_' + MovielistPosition,'bkimage','url(\'./images/layout/navmenubks.png\')');
    MovielistPositionPrev=MovielistPosition;
  }

  switch (OnClickAction){
  case 'SEARCH':
	  popupbox('waitbox','pagecontent','Attendi per favore...','open',false);
    http.open("GET", "GetMoviesData.php?Product_Id=" + escape(MovieCode), true);
    http.onreadystatechange = ReturnMovieData;
    isWorking = true;
    http.send(null);
    break;
  case 'ADD_PDF':
    DiviaAction="ADD_PDF";
    DiviaMovieCode=escape(MovieCode);
    DiviaMovielistPosition=MovielistPosition;
	  popupbox('waitbox','pagecontent','Attendi per favore...','open',false);
    http.open("GET", "ProductListHandle.php?Action=ADD_PDF&Product_Id=" + escape(MovieCode), true);
    http.onreadystatechange = ProductListHandle;
    productlisthandleAjax = true;
    http.send(null);
    break;
  case 'PDF_DEL':
    DiviaAction="PDF_DEL";
    DiviaMovieCode=escape(MovieCode);
    DiviaMovielistPosition=MovielistPosition;
	  popupbox('waitbox','pagecontent','Attendi per favore...','open',false);
    http.open("GET", "ProductListHandle.php?Action=PDF_DEL&Product_Id=" + escape(MovieCode), true);
    http.onreadystatechange = ProductListHandle;
    productlisthandleAjax = true;
    http.send(null);
    break;
  case 'ADD':
    if (document.getElementById('smlt_' + MovielistPosition)){
      AlterElement('innerselmovielist','rchld','','',ValueOfElement('smlt_' + MovielistPosition));
    }
    else{
      CustomerAction('OB_A',escape(MovieCode));
      my_movie = document.getElementById('mlt_' + MovielistPosition);
      new_tr=AlterElement('innerselmovielist','achld','','tr','smlt_' + MovielistPosition);
      new_td=AlterElement(new_tr.id,'achld','X','td','','CustomerAction(\'OB_R\',\''+MovieCode+'\');AlterElement(\'innerselmovielist\',\'rchld\',\'\',\'\',\''+new_tr.id+'\');');
      new_td=AlterElement(new_tr.id,'achld',my_movie.innerHTML,'td');
      new_td.setAttribute('width','190px');
      if (QtyBox==0){QtyBox='';}
      else if(QtyBox==1){
        new_td=AlterElement(new_tr.id,'achld','','td');
        new_element=AlterElement(new_tr.id,'achld','','input','mqty_' + MovielistPosition);
        new_element.setAttribute('value','1');
        new_element.setAttribute('size','3');
      }
      if (PriceBox==0){PriceBox='';}
      else if(PriceBox==1){
        new_td=AlterElement(new_tr.id,'achld','€','td');
        new_td=AlterElement(new_tr.id,'achld','','td');
        new_element=AlterElement(new_tr.id,'achld','','input','mprice_' + MovielistPosition);
        new_element.setAttribute('size','5');
      }
    }
    break;
  }
}

function ProductListHandle(){
  if (http.readyState == 4) {
	  closepopupdiv ('pagecontent','waitbox');
    if (http.responseText.indexOf('invalid') == -1) {
      var xmlDocument= new String;
      xmlDocument = http.responseText;
      switch(DiviaAction){
      case "ADD_PDF":
        if (document.getElementById('smlp_' + DiviaMovielistPosition)){}
        else{
          AlterElement('innerselmovielist','rchld','','','smlp_' + DiviaMovielistPosition);
          my_movie = document.getElementById('mlp_' + DiviaMovielistPosition);
          //new_tr=AlterElement('innerselmovielist','achld','','tr','smlp_' + DiviaMovielistPosition,'QueryMovieData('+DiviaMovieCode+','+DiviaMovielistPosition+',\'PDF_DEL\')');
          Element_Add('innerselmovielist','tr','smlp_' + DiviaMovielistPosition,'movielistelement','','QueryMovieData('+DiviaMovieCode+','+DiviaMovielistPosition+',\'PDF_DEL\')');
					Element_Add('smlp_' + DiviaMovielistPosition,'td','','','X');
					Element_Add('smlp_' + DiviaMovielistPosition,'td','','mvdtl_titlelist',my_movie.innerHTML);
					//Element_Add(ElemFather,ElemType,ElemId,ElemClass,ElemIHTML)
					//new_td=AlterElement(new_tr.id,'achld','X','td','');
          //new_td=AlterElement(new_tr.id,'achld',my_movie.innerHTML,'td');
          //new_td.setAttribute('width','190px');
        }
        break;
      case "PDF_DEL":
        AlterElement('innerselmovielist','rchld','','','smlp_' + DiviaMovielistPosition);
        break;
      }
    }
    productlisthandleAjax = false;
  }
  return;
}

function QueryMovieList(MovieSelCond) {
  if (!QueryMovieList_isWorking && http) {
	  popupbox('waitbox','pagecontent','Attendi per favore...','open',false);
    http.open("GET", "GetMoviesList.php?mnav=webselector&smnav=Long&" + MovieSelCond, true);
    http.onreadystatechange = ReturnMovieList;
    QueryMovieList_isWorking = true;
    http.send(null);
  }
}

function QueryMovieListFast(MovieSelCond) {
  var SelectedFilter="";
  var FilterRadiobtn=Object;
  if (document.getElementsByName('customfind') != null){
    FilterRadiobtn=document.getElementsByName('customfind');
	  if(FilterRadiobtn[0].checked){SelectedFilter = FilterRadiobtn[0].value;}
	  if(FilterRadiobtn[1].checked){SelectedFilter = FilterRadiobtn[1].value;}		
	  location.href='diviamovies.php?mnav=webselector&smnav=Short&' + MovieSelCond + '&SelectedFilter=' + SelectedFilter;
  }
}
function QMFP(MovieSelCond) {
  var SelectedFilter="";
  var FilterRadiobtn=Object;
  if (document.getElementsByName('customfindp') != null){
    FilterRadiobtn=document.getElementsByName('customfindp');
	  if(FilterRadiobtn[0].checked){SelectedFilter = FilterRadiobtn[0].value;}
	  if(FilterRadiobtn[1].checked){SelectedFilter = FilterRadiobtn[1].value;}		
	  if (!QueryMovieList_isWorking && http) {
		  popupbox('waitbox','pagecontent','Attendi per favore...','open',false);
	    http.open("GET", "GetMoviesList.php?mnav=webselector&smnav=Short&" + MovieSelCond + '&SelectedFilter=' + SelectedFilter, true);
	    http.onreadystatechange = ReturnMovieList;
	    QueryMovieList_isWorking = true;
	    http.send(null);
	  }
  }
}

function PDFOnTheFly(){
  if (!PDFOnTheFly_isWorking && http) {
	  popupbox('waitbox','pagecontent','Attendi per favore...','open',false);
    http.open("POST", "PDFBuilder.php", true);
    PDFOnTheFly_isWorking = true;
    AdditionalParms='doch='+escape(ValueOfElement('docheader'))+'&docf='+escape(ValueOfElement('docfooter'))+'&docc='+escape(ValueOfElement('doccover'))+'&docb='+escape(ValueOfElement('docbackground'));
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8' );
    http.send(AdditionalParms);
    http.onreadystatechange = PDFOnTheFlyReturn;
  }
}

function PDFOnTheFlyReturn(){
  if (http.readyState == 4) {
	  PDFOnTheFly_isWorking=false;
	  closepopupdiv ('pagecontent','waitbox');
    if (http.responseText.indexOf('invalid') == -1) {
      ResponseData = trim(http.responseText);
		  window.open(ResponseData,'Diviavideo PDF on The Fly');
		}
	}
}

function dva_http(isWorking){
	if (!isWorking && http) {
	  http.open("POST", "is_Functions.php", true);
	  isWorking = true;
		return true;
  }
	else{
	 return false;
	}
}

function is_Functions(is_Section,is_Action){
	switch (is_Section){
	case 'FASTRENT':
		location.href='/is_entry.php?Fastrent=1&MovieCode='+is_Action;
		break;
	case 'LOGIN':
	  popupbox('waitbox','pagecontent','Attendi per favore...','open',false);
	  if (dva_http(is_Functions_isWorking)) {
		  //http.open("POST", "is_Functions.php", true);
			is_LoginCode=ValueOfElement('LoginCodeTrack');
			is_LoginPIN=ValueOfElement('LoginPINTrack');
		  AdditionalParms = 'is_Section='+is_Section+'&is_Action='+is_Action+'&is_LoginCode='+is_LoginCode+'&is_LoginPIN='+is_LoginPIN+'';
	    http.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8' );
	    http.send(AdditionalParms);
	    http.onreadystatechange = is_Functions_Return;
	  }
		break;
	case 'BROWSEFWD':
		location.href='is_diviamovies.php'+is_Action+ValueOfElement("SelItemValue");
		break;
	case 'BROWSEBCK':
		location.href='is_diviamovies.php'+is_Action;
		break;
	case 'BROWSE':
		switch (is_Action){
		case 'CONFIRM':
			break;
		case 'EXIT':
			break;
		}
		break;
	}
  return;
}

function is_Functions_Return(){
  if (http.readyState == 4) {
	  closepopupdiv ('pagecontent','waitbox');
    if (http.responseText.indexOf('invalid') == -1) {
      ResponseData = trim(http.responseText);
      ResponseData_ar = ResponseData.split('||')
      switch (ResponseData_ar[0]){
      case 'LOGIN':
			  AlterElement('LoginPhase','value',ResponseData_ar[1]);
        switch (ResponseData_ar[1]){
        case '0':
					for (var idx = 1; idx <= 8;  idx++) {
						AlterElement('usercode'+idx,'visibility',true);
					}	
					for (var idx = 1; idx <= 4;  idx++) {
						AlterElement('pincode'+idx,'visibility',false);
					}	
				  for (var idx = 0; idx <= 9;  idx++) {
				    AlterElement('codebtn'+idx,'visibility',true);
		      }
					break;
        case '1':
					for (var idx = 1; idx <= 8;  idx++) {
						AlterElement('usercode'+idx,'visibility',false);
					}	
					for (var idx = 1; idx <= 4;  idx++) {
						AlterElement('pincode'+idx,'visibility',true);
					}	
				  for (var idx = 0; idx <= 9;  idx++) {
				    AlterElement('codebtn'+idx,'visibility',true);
		      }
					break;
				}
			  break;
			}
		}
	}
  return;
}

function ReturnMovieList() {
  if (http.readyState == 4) {
	  closepopupdiv ('pagecontent','waitbox');
    if (http.responseText.indexOf('invalid') == -1) {
      var xmlDocument_ar = new Array();
      var xmlDocument= new String;
      xmlDocument = http.responseText;
      xmlDocument_ar=xmlDocument.split("<split>");
      document.getElementById('wsdiv_list').innerHTML=xmlDocument_ar[0];
      ReturnMovieDataSetValues(xmlDocument_ar[1]);
    }
    QueryMovieList_isWorking = false;
  }
}


function PromoReward() {
  if (!PromoReward_isWorking && http) {
    //AlterElement('lvpromoloading','src','./images/loading_06.gif');
    http.open("GET", "PromoReward.php?dvafunction=lvpromoreward", true);
    http.onreadystatechange = ReturnPromoReward;
    PromoReward_isWorking = true;
    http.send(null);
  }
}

function PromoReset() {
  if (!PromoReset_isWorking && http) {
    http.open("GET", "PromoReset.php", true);
    http.onreadystatechange = ReturnPromoReset;
    PromoReset_isWorking = true;
    http.send(null);
  }
}
function PromoBuilder() {
  if (!PromoBuilder_isWorking && http) {
    http.open("GET", "PromoBuilder.php?SelectedPromo="+ValueOfElement('lstPDFTypes'), true);
    http.onreadystatechange = ReturnPromoBuilder;
    PromoBuilder_isWorking = true;
    http.send(null);
  }
}

function ReturnPromoReward() {
  var ResultDatastr = new String;
  if (http.readyState == 4) {
    if (http.responseText.indexOf('invalid') == -1) {
      if (http.responseText != '_NOVALUE_'){
        ResultDatastr=document.getElementById('promorewardresponse').value=http.responseText;
        ResultData = ResultDatastr.split('|')
        int_ElemsCount = ResultData.length;
        for (int_Elems_idx = 0; int_Elems_idx < int_ElemsCount; int_Elems_idx++) {
          ResultDataDetail = ResultData[int_Elems_idx].split(';')
          if (ResultDataDetail[1]=='SUCCEDED'){
            AlterElement('lvpromoresult_'+ResultDataDetail[0],'ihtml','Promo of '+ResultDataDetail[2]+' euro(s) rewarded...');
          }
          else {AlterElement('lvpromoresult_'+ResultDataDetail[0],'ihtml','Promo reward failed...');
          }
        }
      }
    }
    PromoReward_isWorking = false;
  }
}

function ReturnPromoBuilder() {
  var ResultDatastr = new String;
  if (http.readyState == 4) {
    if (http.responseText.indexOf('invalid') == -1) {
      ResultDatastr=document.getElementById('promorewardresponse').value=http.responseText;
      AlterElement('promolist','ihtml',ResultDatastr);
      AlterElement('promoaction_bld','ihtml','Get Promo Data...');
      AlterElement('promoaction_rew','ihtml','<a href="#" onclick="PromoReward();">Promo Reward...</a>');
    }
    PromoBuilder_isWorking = false;
  }
}

function ReturnPromoReset() {
  if (http.readyState == 4) {
    if (http.responseText.indexOf('invalid') == -1) {
      AlterElement('promolist','ihtml','');
      AlterElement('promoaction_bld','ihtml','<a href="#" onclick="PromoBuilder();">Get Promo Data...</a>');
      AlterElement('promoaction_rew','ihtml','Promo Reward...');
    }
    PromoReset_isWorking = false;
  }
}

function CustomerAction_Return() {
  if (http.readyState == 4) {
	  closepopupdiv ('pagecontent','waitbox');
    if (http.responseText.indexOf('invalid') == -1) {
      CustActionClass='';
			var xmldocument = http.responseXML
			var CustActionClassStr=http.responseXML.getElementsByTagName('CustomerActionClass').item(0).firstChild.data
			var CustActionClass=CustActionClassStr.substring(0,2);
			var CustSubActionClass=CustActionClassStr.substring(2);
      switch (CustActionClass){
      case 'IN':
        var CurrentObject = document.getElementById('divia_informa');
        //DivChangeSize(CurrentObject,0,0);
        document.getElementById('divia_informa').innerHTML = xmlDocument.getElementsByTagName('DiviaInfo').item(0).firstChild.data;
        break;
      case 'MC':
        var CurrentObject = document.getElementById('commentmovies');
        var Comment_NickName=xmlDocument.getElementsByTagName('MovieComm_N').item(0).firstChild.data;
        if (Comment_NickName != null) {Comment_NickName = ' di '+Comment_NickName;}
        DivChangeSize(CurrentObject,0,0);
        document.getElementById('all_moviecomments_ul').innerHTML +=
		  "<li><div class=\"usercomment\">" + xmlDocument.getElementsByTagName('MovieComm_T').item(0).firstChild.data + Comment_NickName + "</div></li>";
        break;
      case 'WL':
			  AlterElement('wishlist_pic','ihtml',http.responseXML.getElementsByTagName('WishListFunc').item(0).firstChild.data);
				popupbox('waitbox','pagecontent',http.responseXML.getElementsByTagName('WishListMsg').item(0).firstChild.data,'open',true);
        break;
      case 'RT':
        switch (CustSubActionClass){
        case 'C':
          document.getElementById('movie_rating_tot').innerHTML = xmlDocument.getElementsByTagName('MovieRate').item(0).firstChild.data;
          break;
        default:
          document.getElementById('movie_rating').innerHTML = xmlDocument.getElementsByTagName('MovieRate').item(0).firstChild.data;
          break;
        }
        break;
      case 'SC':
			  CustSubActionClassArray = CustSubActionClass.split('_');
        switch (CustSubActionClassArray[1]){
        case '_SHOW':
					popupbox('waitbox','pagecontent',http.responseXML.getElementsByTagName('ShoppingCartPage').item(0).firstChild.data,'open',true);
					break;
				case 'DEL':
				case 'BUL':
				case 'BUM':
				case 'BU0':
				case 'BUY':
					AlterElement('sc_contents','ihtml',http.responseXML.getElementsByTagName('ShoppingCart').item(0).firstChild.data);
					AlterElement('sc_contents_ecom','ihtml',http.responseXML.getElementsByTagName('ShoppingCart').item(0).firstChild.data);
					break;
				}
				break;
      case 'WB':
			  msgtext=http.responseXML.getElementsByTagName('MovieBooking').item(0).firstChild.data;
				msgfunction=http.responseXML.getElementsByTagName('MovieBookingBtn').item(0).firstChild.data;
				popupbox('popupdiv','pagecontent',msgtext,'open',true,msgfunction);
        break;
      case 'HD':
	      popupbox('waitbox','pagecontent',http.responseXML.getElementsByTagName('HomeDelivery').item(0).firstChild.data,'open',true);
        break;
      case 'OB':
        switch (CustSubActionClass){
        case '_E':
          AlterElement('innerselmovielist','rchld','','','#ALL#');
          break;
        }
      }

      isWorking = false;
      return;
    }
  }
}

function ReturnMovieData() {
  if (http.readyState == 4) {
	  closepopupdiv ('pagecontent','waitbox');
    if (http.responseText.indexOf('invalid') == -1) {
      var xmlDocument= new String;
      xmlDocument = http.responseText;
      ReturnMovieDataSetValues(xmlDocument);
      isWorking = false;
      isWorking_scroll=false;
      return;
    }
  }
}

function msgbox(msgbox_id,msgbox_container,msgbox_text,msgbox_action,msgbox_closebtn){
	if (document.getElementById(msgbox_container) != null){
		var fatherelem = document.getElementById(msgbox_container);
	}
	else {
		var fatherelem = document.body;
	}
  var fatherelem = document.body;
	if (document.getElementById(msgbox_id) != null){
		var child_element = document.getElementById(msgbox_id);
		fatherelem.removeChild(child_element);
	}
	switch (msgbox_action){
	case 'open':
	  if (msgbox_closebtn===undefined) {msgbox_closebtn=false;}
	  if (msgbox_closebtn===false){
		  msgbox_innerhtml=MessageBoxNoClosePrototype.replace('MessageText',msgbox_text);
	  }
		else{
		  msgbox_innerhtml=MessageBoxPrototype.replace('MessageId',msgbox_id);
		  msgbox_innerhtml=msgbox_innerhtml.replace('MessageContainer',msgbox_container);
			msgbox_innerhtml=msgbox_innerhtml.replace('MessageText',msgbox_text);
    }
		var nchild = document.createElement('div');
		nchild.innerHTML=msgbox_innerhtml;
		if(msgbox_id===undefined){}
		else{
		  nchild.setAttribute('id',msgbox_id);
		  nchild.setAttribute('class',msgbox_id);
		}
		fatherelem.appendChild(nchild);
		break;
	case 'close':
		break;
	}
}

function popupbox(msgbox_id,msgbox_container,msgbox_text,msgbox_action,msgbox_closebtn,msgbox_function){
	if (document.getElementById(msgbox_container) != null){
		var fatherelem = document.getElementById(msgbox_container);
	}
	else {
		var fatherelem = document.body;
	}
	var fatherelem = document.body;
	if (document.getElementById(msgbox_id) != null){
		var child_element = document.getElementById(msgbox_id);
		fatherelem.removeChild(child_element);
	}
	switch (msgbox_action){
	case 'open':
		var nchild = document.createElement('div');
		var childh = nchild.offsetHeight;
		var childw = nchild.offsetWidth;
		if (msgbox_function===undefined){boxfunctiontml='<div class="rwdiv"><div class="cldivfullw"></div></div>';}
		else{boxfunctiontml='<div class="rwdiv" id="'+msgbox_id+'funct">'+msgbox_function+'</div>';}
		if (msgbox_closebtn){
			boxclosehtml='<div class="rwdiv"><div class="cldivclose" onclick="closepopupdiv(\''+msgbox_container+'\',\''+msgbox_id+'\');">X Chiudi</div>';
		}
		else{
			boxclosehtml='<div class="rwdiv"><div class="cldivclose"></div></div>';
		}
		nchild.innerHTML='<div id="tbdivpu" class="tbdivpu">'+boxclosehtml+'<span>'+msgbox_text+'</span><div class="rwdiv"><div id="'+msgbox_id+'msg" class="cldivpu cldivfullw"></div></div>'+boxfunctiontml+'</div>';
		if(msgbox_id===undefined){}
		else{
		  nchild.setAttribute('id',msgbox_id);
		  nchild.setAttribute('class','popupdiv');
			nchild.style.width=fatherelem.offsetWidth+'px';
			nchild.style.height=fatherelem.offsetHeight+'px';
		}
		fatherelem.appendChild(nchild);
		var childh = Math.round(nchild.offsetHeight/2);
		var childw = Math.round(nchild.offsetWidth/2);
	  var inner_element = document.getElementById('tbdivpu');
	  var containerh=Math.round(inner_element.offsetHeight/2);
    var containerw=Math.round(inner_element.offsetWidth/2);
		inner_element.style.top=childh-containerh+'px';
		inner_element.style.left=childw-containerw+'px';
		break;
	case 'close':
		break;
	}
}

function Element_Remove(ElemId){
	if (document.getElementById(ElemId) != null){
		var ETBA = document.getElementById(ElemId);
	  ETBA.innerHTML='';
		ETBA.parentNode.removeChild(ETBA);
	}
	return;
}

function Element_Add(ElemFather,ElemType,ElemId,ElemClass,ElemIHTML,OnclickAction){
	Element_Remove(ElemId);
	var FETBA = Object;
	var ETBA = Object;
	if (document.getElementById(ElemFather) != null){FETBA = document.getElementById(ElemFather);}
	else {FETBA = document.body;}
	ETBA = document.createElement(ElemType);
	ETBA.innerHTML=ElemIHTML;
	if(ElemId===undefined){}
	else{ETBA.setAttribute('id',ElemId);}
	if(OnclickAction===undefined){}
	else{
		if (window.attachEvent) {ETBA.attachEvent('onclick',OnclickAction);}
	  else if (window.addEventListener) {ETBA.setAttribute('onclick',OnclickAction);}
	}
	if(ElemClass===undefined){}
	else{ETBA.setAttribute('class',ElemClass);}
	FETBA.appendChild(ETBA);
	return;
}		

function AlterElement(AlterthisElement,AlterType,AlterValue,ChildType,ChildId,ChildOnClick,ChildFaceText){
  var PassedElementValue=null;
	switch (AlterType){
	case 'rmve':
		if (document.getElementById(AlterthisElement) != null){
		  var tbrmvdelem = document.getElementById(AlterthisElement);
			tbrmvdelem.parentNode.removeChild(tbrmvdelem);
		}
		break;
	case 'newn':
		if (document.getElementById(AlterthisElement) != null){
		  var fatherelem = document.getElementById(AlterthisElement);
		}
		else {
		  var fatherelem = document.body;
		}
		if (document.getElementById(ChildId) != null){
			var child_element = document.getElementById(ChildId);
			fatherelem.removeChild(child_element);
		}
		var nchild = document.createElement(ChildType);
		nchild.innerHTML=AlterValue;
		if(ChildId===undefined){}
		else{
		 nchild.setAttribute('id',ChildId);
		 nchild.setAttribute('class',ChildId);
		}
		fatherelem.appendChild(nchild);
		break;
	default:
	  if (document.getElementById(AlterthisElement) != null){
		  ETBA = document.getElementById(AlterthisElement);
	    switch (AlterType){
	    case 'onclick':
				if (window.attachEvent) {ETBA.attachEvent('onclick',AlterValue);}
	      else if (window.addEventListener) {ETBA.setAttribute('onclick',AlterValue);}
	      break;
	    case 'href':
			  ETBA.href=AlterValue;
	      break;
			case 'bkimage':
				ETBA.style.backgroundImage=AlterValue;
				break;
	    case 'forecolor':
	      ETBA.style.color=AlterValue;
	      break;
	    case 'background':
	      ETBA.style.background=AlterValue;
	      break;
	    case 'ihtml':
	      ETBA.innerHTML=AlterValue;
	      break;
	    case 'itxt':
	      ETBA.innerText=AlterValue;
	      break;
	    case 'focus':
	      ETBA.focus();
	      break;
	    case 'value':
	      ETBA.value=AlterValue;
	      break;
	    case 'value+':
	      document.getElementById(AlterthisElement).value=ETBA.value+AlterValue;
	      break;
	    case 'src':
	      ETBA.src=AlterValue;
	      break;
	    case 'alt':
	      ETBA.alt=AlterValue;
	      break;
	    case 'visibility':
	      if(AlterValue==false){ETBA.style.visibility = "hidden";}
	      if(AlterValue==true){ETBA.style.visibility = "visible";}
	      break;
	    case 'zindex':
	      ETBA.style.zindex=AlterValue;
	      break;
	    case 'height':
	      ETBA.style.height=AlterValue;
	      break;
	    case 'top':
	      ETBA.style.top=AlterValue;
	      break;
	    case 'width':
	      ETBA.style.width=AlterValue;
	      break;
	    case 'achld':
	      var nchild = document.createElement(ChildType);
	      nchild.innerHTML=AlterValue;
	      if(ChildId===undefined){}
	      else{nchild.setAttribute('id',ChildId);}
	      ETBA.appendChild(nchild);
	      if (ChildOnClick===undefined){
	      }
	      else{
	        if (window.attachEvent) {
	          nchild.attachEvent('onclick',ChildOnClick);
	        }
	        else if (window.addEventListener) {
	          nchild.setAttribute('onclick',ChildOnClick);
	        }
	      }
	      switch(ChildType){
	      case 'a':
	        nchild.href='#';
	        nchild.innerHTML = ChildFaceText;
	        nchild.innerText = ChildFaceText;
	        break;
	      }
	      return nchild;
	      break;
	    case 'rchld':
	      if (ChildId===undefined){}
	      else{
	        if (ChildId=='#ALL#'){
	          if (ETBA.hasChildNodes()){
	            while (ETBA.childNodes.length >= 1){
	              ETBA.removeChild(ETBA.firstChild);
	            }
	          }
	        }
	        else{
	          var child_element = document.getElementById(ChildId);
	          if (child_element){
	            if (ETBA){
	              ETBA.removeChild(child_element);
	            }
	          }
	        }
	      }
	      break;
	    }
	  }
		break;
	}
  return;

}

function expand(ElementId){
	AlterElement(ElementId,'height','300px');
	AlterElement(ElementId,'width','100%');
	AlterElement(ElementId,'visibility',true);
}

function closepopupdiv (FatherNode,NodeToBeRemoved){
	if (document.getElementById(FatherNode) != null){
		var fatherelem = document.getElementById(FatherNode);
	}
	else {
		var fatherelem = document.body;
	}
	var fatherelem = document.body;
	if (document.getElementById(NodeToBeRemoved) != null){
		var child_element = document.getElementById(NodeToBeRemoved);
		fatherelem.removeChild(child_element);
	}
	return;
}

function ReturnMovieDataSetValues(xmlDocument) {

  var xmlDocument_ar = new Array();
  xmlDocument_ar=xmlDocument.split("||");
	if (xmlDocument_ar[0]=='%titolo%'){
	  popupbox('waitbox','pagecontent','Nessun elemento presente...<p> Prova cambiando i criteri di ricerca.','open',true); 
    AlterElement('wsmoviediv','visibility',false);
  }
	else {
    AlterElement('wsmoviediv','visibility',true);
  }
  AlterElement('mvdtl_title','ihtml',xmlDocument_ar[0]);
  AlterElement('mvdtl_titleor','ihtml',xmlDocument_ar[1]);
  AlterElement('mvdtl_pic','src',xmlDocument_ar[2]);
  AlterElement('mvdtl_pic','alt',xmlDocument_ar[0]);
  AlterElement('mvdtl_trama','ihtml',xmlDocument_ar[3]);
  AlterElement('mvdtl_cast','ihtml',xmlDocument_ar[4]);
  AlterElement('mvdtl_durata','ihtml',xmlDocument_ar[5] + " min");
  AlterElement('mvdtl_nazione','ihtml',xmlDocument_ar[6]);
  AlterElement('mvdtl_genere','ihtml',xmlDocument_ar[7]);
  AlterElement('mvdtl_lingue','ihtml',xmlDocument_ar[8]);
  AlterElement('mvdtl_regista','ihtml',xmlDocument_ar[9]);
  AlterElement('mvdtl_YProd','ihtml',xmlDocument_ar[10]);
  AlterElement('mvdtl_YDist','ihtml',xmlDocument_ar[11]);
  AlterElement('mvdtl_public','src',xmlDocument_ar[12]);
  AlterElement('isatopmovie_pic','ihtml',xmlDocument_ar[13]);
  AlterElement('isaviewedmovie_pic','ihtml',xmlDocument_ar[14]);
  AlterElement('isamonthtopmovie_pic','ihtml',xmlDocument_ar[15]);
  AlterElement('isanewmovie_pic','ihtml',xmlDocument_ar[16]);
  AlterElement('ourbestmovie_pic','ihtml',xmlDocument_ar[17]);
  AlterElement('mvdtl_storage','ihtml',xmlDocument_ar[20]);
  AlterElement('ondvddate','ihtml','A noleggio dal ' + xmlDocument_ar[21]);
  AlterElement('productprice','ihtml',xmlDocument_ar[22]);
  AlterElement('addtocart','ihtml',xmlDocument_ar[18]);
  AlterElement('wishlist_pic','ihtml',xmlDocument_ar[23]);
  AlterElement('mvdtl_available','ihtml',xmlDocument_ar[24]);
	AlterElement('moviebookandcart','ihtml',xmlDocument_ar[25]);
	AlterElement('is_BookProd','ihtml',xmlDocument_ar[28]);
  //AlterElement('all_moviecomments_ul','ihtml',xmlDocument_ar[19]);
}

function moviedivshow(CurrDivId){
  var containerdiv2 = document.getElementById(CurrDivId);
  containerdiv2.style.visibility='visible';
  containerdiv2.style.zIndex=40;
  return;
}

function moviedivhide(CurrDivId){
  //if (!document.getElementById){return;}
  var containerdiv2 = document.getElementById(CurrDivId);
  containerdiv2.style.visibility='hidden';
  containerdiv2.style.zIndex=-1;
  return;
}

function MoviesForPDF(opt,selectedmovies,append) {

  var myselectedmovies = document.getElementById(selectedmovies);

  if (append==true){
	var mytmpstring = myselectedmovies.value;
	myselectedmovies.value=mytmpstring.replace(opt.value+';','');
    if (opt.checked) {myselectedmovies.value = myselectedmovies.value + opt.value + ';';}
  }
  else{
    if (opt.checked) {myselectedmovies.value = opt.value;}
	else{myselectedmovies.value ='';}
  }

  return;

}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

var scrollerspeed=2;
var pauseit=1;
var iedom=document.all||document.getElementById; 
var cross_scroller, ns_scroller; 
var pausespeed=(pauseit==0)? copyspeed: 0;
var ScrollBoxNews,ScrollElemNews;
var ScrollBoxNewsH,ScrollElemNewsH;

function populate(){ 
	ScrollBoxNews=document.getElementById("scrollbox_news");
	if (ScrollBoxNews){
		ScrollBoxNewsH=ScrollBoxNews.offsetHeight;
		ScrollElemNews=document.getElementById("scrollelem_news");
		ScrollElemNewsH=ScrollElemNews.offsetHeight;
		lefttime=setInterval("dvascroller()",20); 
		scrollerspeed=(document.all)?scrollerspeed : Math.max(1, scrollerspeed-1); //slow speed down by 1 for NS var 
		copyspeed=scrollerspeed;
	}
} 

function dvascroller(){
  var tmpObj=document.getElementById("scrollelem_news");
	if (parseInt(tmpObj.style.top)>(ScrollElemNewsH*(-1)+8)){
		tmpObj.style.top=parseInt(tmpObj.style.top)-copyspeed+"px";
	}
	else {tmpObj.style.top=parseInt(ScrollBoxNewsH)+8+"px";}
}

function ScrollMovieList(ScrollAction,RefreshMovie){

  if (document.getElementById('InitMovielistIdx') != null){
    InitMovielistIdx=parseInt(document.getElementById('InitMovielistIdx').value);
    if (InitMovielistIdx != -1){
      MovielistOver=InitMovielistIdx;
      MovielistPosition=InitMovielistIdx;
      MovielistPositionPrev=InitMovielistIdx;
      document.getElementById('InitMovielistIdx').value=-1;
    }
  }
  else {
    MovielistOver=InitMovielistIdx;
    MovielistPosition=InitMovielistIdx;
    MovielistPositionPrev=InitMovielistIdx;
  }
  
  MovielistOver=parseInt(MovielistOver);
  MovielistPosition=parseInt(MovielistPosition);
  MovielistPositionPrev=parseInt(MovielistPositionPrev);
  MovieListLen=parseInt(MovieListLen);

  MovielistPositionPrev=MovielistPosition;
  
  CausedClick=false;
  RefreshOffset=false;
  
  if (document.getElementById('numberofmovies') != null){
    MovielistItemsNum=parseInt(document.getElementById('numberofmovies').value);
  }
  if (MovielistItemsNum<MovieListLen){MovieListLen=MovielistItemsNum;}
  
  if (!isWorking_scroll)  {
  isWorking_scroll=true;
  
  switch (ScrollAction){
  case 'oru':
    if (MovielistPosition>1){MovielistPosition--;}
    if (MovielistOver>1){MovielistOver--;}
    RefreshOffset=true;
    break;
  case 'opu':
    if (MovielistPosition>MovieListLen){MovielistPosition = MovielistPosition - MovieListLen;}
    else {MovielistPosition = InitMovielistIdx;}
    MovielistOver=InitMovielistIdx;
    RefreshOffset=true;
    break;
  case 'ord':
    if (MovielistPositionPrev<MovielistItemsNum){MovielistPosition++;}
    else {MovielistPosition=MovielistItemsNum;}
    if (MovielistOver<MovieListLen){MovielistOver++;}
    if (MovielistOver*MovieListElementHeight >=MovieListHeight){RefreshOffset=true;}
    break;
  case 'opd':
    if (MovielistPosition + MovieListLen<MovielistItemsNum){MovielistPosition = MovielistPosition + MovieListLen;}
    else {MovielistPosition=MovielistItemsNum;}
    MovielistOver=MovieListLen;
    if (MovielistOver*MovieListElementHeight >=MovieListHeight){RefreshOffset=true;}
    break;
  }
  
  if (document.getElementById('mlt_' + MovielistPositionPrev) != null){
    my_movie = document.getElementById('mlt_' + MovielistPositionPrev);
    my_movie.style.color='';
    my_movie.style.backgroundColor='';
  }
  if (document.getElementById('mlr_' + MovielistPositionPrev) != null){
    my_movie = document.getElementById('mlr_' + MovielistPositionPrev);
    my_movie.style.color='';
    my_movie.style.backgroundColor='';
  }  
  if (document.getElementById('mlh_' + MovielistPositionPrev) != null){
    my_movie = document.getElementById('mlh_' + MovielistPositionPrev);
    my_movie.style.color='';
    my_movie.style.backgroundColor='';
  }  
  if (document.getElementById('mlr_' + MovielistPosition) != null){
    my_movie = document.getElementById('mlr_' + MovielistPosition);
    my_movie.style.color='#FF6600';
    my_movie.style.backgroundColor='#CCFFCC';
  }  
  if (document.getElementById('mlt_' + MovielistPosition) != null){
    my_movie = document.getElementById('mlt_' + MovielistPosition);
    my_movie.style.color='#FF6600';
    my_movie.style.backgroundColor='#CCFFCC';
  }
  if (document.getElementById('mlh_' + MovielistPosition) != null){
    my_movie = document.getElementById('mlh_' + MovielistPosition);
    my_movie.style.color='#FF6600';
    my_movie.style.backgroundColor='#CCFFCC';
    isWorking_scroll=false;
  }
  
  //if (MovielistPositionPrev==MovielistPosition){RefreshMovie=false;}

  MovielistPositionPrev=MovielistPosition;
  if (RefreshOffset){
    TopOffset=(MovielistPosition-MovielistOver)*-MovieListElementHeight;  
  }
  my_element = document.getElementById('innermovielist');
  my_element.style.top = TopOffset + "px";
  if (RefreshMovie){ 
    if (document.getElementById('mlt_' + MovielistPosition) != null){
      if (document.all) {document.getElementById('mlt_' + MovielistPosition).fireEvent("onclick");} 
      else { 
        var clickEvent = window.document.createEvent("MouseEvent"); 
        clickEvent.initEvent("click", false, true); 
        if (document.getElementById('mle_' + MovielistPosition) != null){
          document.getElementById('mle_' + MovielistPosition).dispatchEvent(clickEvent); 
        }
		CausedClick=true;
      }
    }
  }
  else {isWorking_scroll=false;}
  }
  return;

}

var currentPanel;
var currentTab;
 
function showPanel(panelNum) {
	AlterElement('tab'+currentPanel,'background','#ffffff');
	AlterElement('tab'+currentPanel,'forecolor','navy');
	AlterElement('panel'+currentPanel,'visibility',false);
	AlterElement('panel'+panelNum,'visibility',true);
	currentPanel = panelNum;
	AlterElement('tab'+currentPanel,'background','#ddddff');
	AlterElement('tab'+currentPanel,'forecolor','red');
}
function PanelShow(panelName,tabFamily,thisPanelIdx,startIdx,endIdx,storePanel,defaultPanel,defaultTab) {
  var idxPanel;
  AlterElement(currentPanel,'visibility',false);
  AlterElement(defaultPanel,'visibility',true);
  AlterElement(defaultTab,'forecolor','#FFCC66');
  AlterElement(currentTab,'forecolor','#000000');
  currentPanel=defaultPanel;
  currentTab=defaultTab;
	for (idxPanel = startIdx; idxPanel <= endIdx; idxPanel++) {
		if (idxPanel == thisPanelIdx){
			AlterElement(panelName+idxPanel,'visibility',true);
			//AlterElement('tab'+idxPanel,'background','#ffffff');
			AlterElement(tabFamily+idxPanel,'forecolor','#FFCC66');
      if (storePanel){currentPanel=panelName+idxPanel;}
		}
		else {
			AlterElement(panelName+idxPanel,'visibility',false);
			//AlterElement('tab'+idxPanel,'background','#ddddff');
			AlterElement(tabFamily+idxPanel,'forecolor','#000000');
		}
	}
}	


function hover(tab) {
	tab.style.backgroundColor = '#ddddff';
	return;
}

