﻿//Function for show page for buying tickets
function ticketWindow()
{
    if(document.getElementById("lstMovies").selectedIndex==0)
    {
        var w=window.open("http://tickets.yesplanet.co.il/","buytickets");
        w.focus();
        return;
    }
    if(document.getElementById("lstDays").selectedIndex==0)
    {
        alert("לביצוע הזמנה בחר/י ביום ושעות ההקרנה");
        return;
    }
    var ec=document.getElementById("EventID").value;
    if(ec=="0")
    {
        alert("לביצוע הזמנה בחר/י את השעות ההקרנה");
        return;
    }
    var wind=window.open("http://tickets.yesplanet.co.il/?EC="+ec,"buytickets");
    wind.focus();
}

//Function for fill in list of event days
function MovieSelected()
{
    var opt;
    document.getElementById("EventID").value="0";
    var lst=document.getElementById("lstMovies");
    var str=lst.options[lst.selectedIndex].value;
    lst=document.getElementById("lstHours");
    lst.innerHTML="";
    lst.disabled=true;
    opt=document.createElement("option");
    opt.text="שעות...";
    opt.value="0";
    lst.options.add(opt,0);
    lst=document.getElementById("lstDays");
    lst.innerHTML="";
    opt=document.createElement("option");
    opt.text="תאריך...";
    opt.value="0";
    lst.options.add(opt,0);
    if(str=="-1")
    {
        lst.disabled=true;
        return;
    }
    lst.disabled=false;
    var arr1=new Array();
    var arr3=new Array();
    var s="";
    arr1=str.split("|");
    var arr2=new Array();
    for(var i=0;i<arr1.length;i++)
    {
        arr2=arr1[i].split("&");
        opt=document.createElement("option");
        arr3=arr2[0].split("*");
        switch(arr3[1])
        {
            case "1":
                s=" יום א\'";
                break;
            case "2":
                s=" יום ב\'";
                break;
            case "3":
                s=" יום ג\'";
                break;
            case "4":
                s=" יום ד\'";
                break;
            case "5":
                s=" יום ה\'";
                break;
            case "6":
                s=" יום ו\'";
                break;
            case "7":
                s=" שבת";
                break;
            default:
                s="";
        }
        opt.text=arr3[0]+s;
        opt.value=arr2[1];
        lst.options.add(opt,i+1);
    }
}

//function for fill in list of event hours
function DaySelected()
{
    var opt;
    document.getElementById("EventID").value="0";
    var lst=document.getElementById("lstDays");
    var str=lst.options[lst.selectedIndex].value;
    lst=document.getElementById("lstHours");
    lst.innerHTML="";
    opt=document.createElement("option");
    opt.text="שעות...";
    opt.value="0";
    lst.options.add(opt,0);
    if(str=="0")
    {
        lst.disabled=true;
        return;
    }
    lst.disabled=false;
    var arr1=new Array();
    arr1=str.split(";");
    var arr2=new Array();
    for(var i=0;i<arr1.length-1;i++)
    {
        arr2=arr1[i].split("=");
        opt=document.createElement("option");
        opt.text=arr2[0];
        opt.value=arr2[1];
        lst.options.add(opt,i+1);
    }
}

//function for temporary saving of selected event code
function HourSelected()
{
    var lst=document.getElementById("lstHours");
    document.getElementById("EventID").value=lst.options[lst.selectedIndex].value;
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}