﻿// JScript File
var m_EOLifeBogrimBgColorKey = "EOLifeBogrimBgColor";
var m_EOLifeRadioWin;

function OpenRadio()
{
    m_EOLifeRadioWin = window.open('http://www.radio.eol.co.il/RadioEng.aspx','EOlRadio','width=447,height=485,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no')
    m_EOLifeRadioWin.focus();
}
function firefoxSpacer() {
   
    var oObj = document.getElementById('mySpacerForSearch');
    if (oObj) {
        if (isFirefox()) {
            oObj.style.width = '20px';
        }
    }
}

function isFirefox() {
    return navigator.userAgent.indexOf("Firefox") > -1;
}



function EOLifeWriteBogrimBgObj(){
    var sVars = "";
    var sColor = getEOLifeCookie(m_EOLifeBogrimBgColorKey);
    if(sColor != ""){
        sVars = "startColor="+sColor;
        EOLifeWriteBogrimBgColor(sColor);
    }
    //WriteFlashObj("/images/Home/bogrim_index.swf","100%","100%",true,sVars,"bg_swf_obj");
    if(document.body.style.backgroundColor == '')
    {
        document.body.style.backgroundColor = '#ddffff';    
    }
}

function rewriteScript()
{
    //document.forms[0].action='/' + document.forms[0].action;
    //alert(document.forms[0].action);
}

function EOLifeWriteBogrimBgColor(sPrm){
    var sColor = "";
    switch(sPrm){
        case "1": sColor = "#ddffff"; break;
        case "16": sColor = "#EBD0EB"; break;
        case "4": sColor = "#ddffff"; break;
        case "8": sColor = "#E1FFE1"; break;
        case "3": sColor = "#FFF3BE"; break;
        case "10": sColor = "#FFEAC5"; break;
        case "6": sColor = "#FFC7BB"; break;
        case "11": sColor = "#82BC82"; break;
        case "13": sColor = "#FFDFEC"; break;
        case "5": sColor = "#DDFFDD"; break;
        case "9": sColor = "#F4D6F4"; break;
        case "2": sColor = "#C5D9FF"; break;
    }
    if(sColor != ""){
        document.body.style.backgroundColor = sColor;
    }
    else
    {
        document.body.style.backgroundColor = '#DDFFFF';
    }
}
function flash_action(act,prm)
{
    //alert(act);
    switch(act){
        case "home_player_enlarge": 
            set_bogrim_player_rubric(); break;
        case "home_colors": 
            EOLifeWriteBogrimBgColor(prm);
            setEOLifeCookie(m_EOLifeBogrimBgColorKey,prm);
            break;
        case "home_player_save": 
            MyFolderAdd(prm,"1"); break;
        case "home_player_list":
            var oObj = document.getElementById("HomePlayer1_pnlBannerObj");
            if(oObj != null){
                if(prm == "open"){
                    oObj.style.display = "none";
                }else{
                    oObj.style.display = "";
                } 
            }
            break;
        case "home_player_send": 
            SendToFriend(act,"1");
            break;
        case "home_player_search":
            if (prm == 'GoToSearch'){
                var oObjWebSearch = document.getElementById('HomeBox3_1_WebSearch');
                if(oObjWebSearch)
                {
                    oObjWebSearch.value = 'Please type here the word you wish to find.';
                    oObjWebSearch.focus();
                }
                break;
            }
		case "home_player_play":
			if (prm != null){
				//alert(prm)
				var myUrl = "UpdatePlayerViews.aspx?MovieID=" + prm;
				UpdatePlayerViews(myUrl)
				//alert(myUrl);
				break;
			}
    }
}

function set_bogrim_player_rubric(){
    var oObj = document.getElementById("bogrim_player_rubric"); 
    var oPlayerBg = document.getElementById("PlayerBg");
    
    if(oObj && oPlayerBg)
    {
        if (oObj.style.zIndex != "5"){
            oPlayerBg.style.zIndex = "2";
            oObj.style.zIndex = "5";    
            SetZIndex("0");
            oPlayerBg.style.backgroundColor = "Gray";
        }else{
            oPlayerBg.style.zIndex = "0";   
            SetZIndex("4");
            oObj.style.zIndex = "4";
            oPlayerBg.style.backgroundColor = "Transparent";
        }
        oPlayerBg.style.height = document.documentElement.scrollHeight;
    }
}

function IsUserLogIn()
{
    var oUser = document.getElementById("ctl00_TopMenu1_lblUserName");
    var oUserHomePage = document.getElementById('TopMenu1_lblUserName');
    var bRet = false;
    if(oUser != null){
        if(oUser.innerHTML != ""){
            bRet = true;
        }
    }
    if(oUserHomePage != null)
    {
        if(oUserHomePage.innerHTML != "")   {
            bRet = true;
        }
    }
    return bRet;
}

function ShowPopUp(sAction)
{
    var sCmdName = "";
    switch (sAction){
        case "ShowSadnaScore": 
            sCmdName = "ctl00_ModalPopup1_ShowPopup"; break;
        case "CommentsAdd": 
            sCmdName = "ctl00_CommentsAdd1_ShowPopup"; break;
        case "SendToFriend": 
            sCmdName = "ctl00_SendToFriend1_ShowPopup"; break;
        case "ModalPopupMsg": 
            showModal('modalMessage'); break;
        case "MyFolderAdd":
            sCmdName = "ctl00_MyFolderAdd1_ShowPopup"; break;
        case "MyFolderDel":
            sCmdName = "ctl00_MyFolderDel1_ShowPopup"; break;
        case "TipAdd":
            sCmdName = "ctl00_TipAdd1_ShowPopup"; break;
        case "GalleryPopup":
            sCmdName = "ctl00_GalleryPopup1_ShowPopup"; break;
        case "ItemScorePopup":
            sCmdName = "ctl00_ItemScorePopup1_ShowPopup"; break;
        case "PopUpMyMemoAdd":
            sCmdName = "ctl00_PopUpMyMemoAdd1_ShowPopup"; break;
    }
    var oCmd = document.getElementById(sCmdName);
    if(oCmd == null){
        sCmdName = sCmdName.replace("ctl00_","");
        oCmd = document.getElementById(sCmdName);
    }
    if(oCmd != null){
        runCmdClick(oCmd);
    }
}

function ShowSadnaScore(sID)
{
    ModalPopup_LoadSadnaScore(sID);
    ShowPopUp("ShowSadnaScore");
}
function CommentsAdd(sID,sType)
{
    CommentsAdd_Load(sID,sType);
}
function SendToFriend(sID,sType)
{
    SendToFriend_Load(sID,sType);
}
function ModalPopupMsg(sMsg)
{
    ModalPopupMsg_Load(sMsg);
}
function MyFolderAdd(sID,sType)
{
    if(IsUserLogIn()){
        MyFolderAdd_Load(sID,sType);
    }else{
        ModalPopupMsg("Please login first.");
    }
}
function PopUpMyMemoAdd(sID,sType)
{
    if(IsUserLogIn()){
        PopUpMyMemoAdd_Load(sID,sType);
    }else{
    ModalPopupMsg("Please login first.");
    }
}
function MyFolderDel(sID,sType)
{
    MyFolderDel_Load(sID,sType);
}
function TipAdd(sID,sType)
{
    TipAdd_Load(sID,sType);
}
function GalleryPopup(sID,sType)
{
    GalleryPopup_Load(sID,sType);
    ShowPopUp("GalleryPopup");
}
function ItemScorePopup(sID,sType)
{
    ItemScorePopup_Load(sID,sType);
}

function UpdatePlayerViews(url)
{
xmlhttp=null;
// פיירפוקס
if (window.XMLHttpRequest)
  {
	xmlhttp=new XMLHttpRequest();
  }
// אינטרנט אקספלורר
else if (window.ActiveXObject)
  {
	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
if (xmlhttp!=null)
  {
	  xmlhttp.onreadystatechange=state_Change;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.send(null);
  }
    else
  {
	alert("Your browser does not support XMLHTTP.");
  }
}
    
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
	{
		//alert('Yes!!!');
	}
  else
	{
		//alert("Problem retrieving XML data");
	}
  }
}

function ShowMySubMenu(menuID){
        var menuDivID = '';
        document.getElementById('AboutUsMenuDiv').style.display='none';
        document.getElementById('NewsMenuDiv').style.display='none';
        document.getElementById('SadnaotMenuDiv').style.display='none';
        document.getElementById('forumsMenuDiv').style.display='none';
        if(menuID=='AboutUs')
        {
            menuDivID = 'AboutUsMenuDiv';
        }
        else
        {
            if(menuID=='News'){
                HideBigTable();
                menuDivID = 'NewsMenuDiv';
            }
            if(menuID=='Sadnaot'){
                HideBigTable();
                menuDivID = 'SadnaotMenuDiv';
            }
            if(menuID=='forums')
            {
                HideBigTable();
                menuDivID = 'forumsMenuDiv';                
            }
        }
        
        if(document.getElementById(menuDivID))
        {
            if(document.getElementById(menuDivID).style.display=='none')
            {
                document.getElementById(menuDivID).style.display='';
            }
            else
            {
                document.getElementById(menuDivID).style.display='none';
            }
        }
    }
    function HideBigTable(){
        if(document.getElementById('subCatTable'))
        {
            if(document.getElementById('subCatTable').style.display=='none')
            {
                document.getElementById('subCatTable').style.display='';
            }
            else
            {
                document.getElementById('subCatTable').style.display='none';
            }
        }
    }
    
function doClientSearch(txtBox)
{
    if(document.getElementById(txtBox))
    {
        var srchTerm = document.getElementById(txtBox).value
        window.location = '/SearchResults.aspx?' + escape(srchTerm);
    }
}
function checkSearchField(elemID)
{
    var oObj = document.getElementById(elemID);
    if(oObj)
    {
        var s = oObj.value;
        if(s)
        {
            s = s.replace('Please type here the word you wish to find.', '');
            oObj.value = s;
        }
    }
    
}
function randomizeTagsSize(elemID)
{
    var oObj = document.getElementById(elemID);
    if(oObj)
    {
        var items = oObj.getElementsByTagName('a');
        for(var i=0; i<items.length; i++)
        {
            var size = randomFontSize()
            items[i].style.fontSize=size;
        }
    }
}
function randomFontSize() {
    var randomstring = Math.round((24-12) * Math.random()+12);
	return randomstring;
}
function checkSearchField()
{
    var elemId = 'TopMenu1_SearchBox';
    var oObj = document.getElementById(elemId);
    if(!oObj)
    {
        oObj = document.getElementById('ctl00_TopMenu1_SearchBox');
    }
    if(oObj)
    {
        if(oObj.value!='')
        {
            return true;
        }else{
            return false;
        }
    }else{
        return false;
    }
}
function showWaitInContact()
{
    var oObj = document.getElementById('pleaseWaitContact');
    if(oObj)
    {
        oObj.innerHTML = 'Please wait, transfaring information...';
        oObj.style.display='';
    }
}
function checkNewsletter(elem)
{
    var oObj = document.getElementById(elem);
    if(oObj)
    {
        if(elem.value != '')
        {
            return true;
        }else{
            alert('Please type a valid mail...');
            return false;
        }
    }
}