﻿// JScript File

function toggleDialogState(DomId,theFrmSrc,theFrmWidth,theFrmHeight, startId)
{
    var theDialogDiv;
    if(typeof(startId) != 'undefined')
    {
        theDialogDiv = document.getElementById(startId + 'ContentPopup1_Dialog1');
    }
    else
    {
        theDialogDiv = document.getElementById('ContentPopup1_Dialog1');
    }
    if(theDialogDiv == null)
    {
        theDialogDiv = document.getElementById('ctl00_ContentPopup1_Dialog1');
    }
        
	if(Dialog1.get_isShowing())
	{
		Dialog1.Close();
	}
	else
	{
        var theIframe = document.getElementById("theInnerIframe");
        if(theIframe != null)
        {
             theIframe.src = theFrmSrc;
             theIframe.style.border='0px';
             theIframe.width= theFrmWidth + 'px';
             theIframe.height=theFrmHeight + 'px';
        }
        Dialog1.ShowTransition=3;				
        Dialog1.CloseTransition=3;				
        Dialog1.AnimationSlide=2;	  
        Dialog1.AnimationType='Live';
        Dialog1.AnimationType='Direct';

        Dialog1.AnimationDirectionElement = DomId; 
        Dialog1.ModalMaskImage= PageThemePath + "/Images/bgModal.gif";
        Dialog1.AnimationDuration = 1000; 
        Dialog1.TransitionDuration = 500; 
        Dialog1.AnimationSlide = 1; 

        Dialog1.Alignment='MiddleCentre';
        Dialog1.Modal=true;
        try
        {
            Dialog1.Show(); 
        }
        catch(ex){}

        theDialogDiv.className = theDialogDiv.className.replace("dNone","");
        theDialogDiv.style.width = theFrmWidth + 30 +'px';
        theDialogDiv.style.top = ((((screen.availHeight)/ 2) - (theDialogDiv.offsetHeight /2)) + document.documentElement.scrollTop + "px");
	}
}

//
// phone - The phone to send the UrlCallback
// tmpid - The id of the BoneId(promotions) that contains the UrlCallback and message
// DomId - The id of the HTML control that call this function
//
function OpenWinPopUpUrlCallback(phone, tmpid, DomId)
{
    var theFrmSrc = SiteUrl + "SMS/PopUpPromotionSms.aspx";
    var theFrmWidth = 200;
    var theFrmHeight = 150;
    var startId = 'ctl00_';
    
    if (phone.length < 10)
    {
		alert("מספר ספרות לא תקין");
	}
	else
	{
	    theFrmSrc = theFrmSrc + "?tmpid=" + tmpid + "&CellnNum=" + phone;
	    toggleDialogState(DomId, theFrmSrc, theFrmWidth, theFrmHeight, startId);
	}	
}

//
// phoneId - The id of the HTML control that call use UrlCallback
// tmpid - The id of the BoneId(promotions) that contains the UrlCallback and message
//
function OpenWinPopUpUrlCallbackByPhoneId(phoneId, tmpid)
{
    var DomId = phoneId;
    var phone = document.getElementById(phoneId).value;
    
    OpenWinPopUpUrlCallback(phone, tmpid, DomId);
}

//
// objId - The id of the HTML control that teh toggleDialog need
// melPath - The id of the song to pre hear
//
function OpenWinPopUpPreHearing(objId, melPath)
{
    var DomId = objId;
    var theFrmSrc = SiteUrl + "Music/Multimedia/player.aspx?melType=SW&melPath=" + melPath;
    var theFrmWidth = 380;
    var theFrmHeight = 350;
    var startId = 'ctl00_';
    
    toggleDialogState(DomId, theFrmSrc, theFrmWidth, theFrmHeight, startId);
}