﻿
var SelectedItem = "";
var SelectedItemType = "";
var ID1 = "";
var HTML = "";
                	     function GetMediaInformation(ID) {
                	         CloseClick();
                	         // MediaService.GetMediaEN(OnMediaSuccess, OnMediaFail, ID);
                	         document.getElementById("LodingDiv").style.display = "";
                	         SelectedItem = ID.toString();
                	         ID1 = ID;
                	         window.setTimeout('MediaService.GetMediaAR(ID1, OnMediaSuccess);', 1200);                	         
                	     }


                	     function OnMediaSuccess(result) {
                	         var divwidth = result.width + 60;
                	         var divheight = result.height + 60;
                	         if (result.width > 801) {
                	             divwidth = 800
                	             $("#PrivewMediaDiv").css("overflow", "auto");
                	         }
                	         else {
                	             $("#PrivewMediaDiv").css("overflow", "");
                	         }
                	         if (result.height > 501) {
                	             divheight = 500
                	             $("#PrivewMediaDiv").css("overflow", "auto");
                	         }
                	         else {
                	             $("#PrivewMediaDiv").css("overflow", "");
                	         }

                	         var marginleft = divwidth / 2;
                	         var margintop = divheight / 2;
                	         marginleft = "-" + marginleft + "px";
                	         margintop = "-" + margintop + "px";
                	         HTML = "<div id='DivMediaTitle' style='z-index:1001;background-color:#ffffff;'>"
                	         HTML += "<span  style='Float:right;font-weight:bold;padding:12px 10px 0px 5px;width:75%;text-align:right;color:#027fff;'>" + result.Title + "</span></div><div style='clear:both;'></div>"
                	         HTML += result.HTML
                	         HTML += "<div id='DivMediaFotter' style='z-index:1001;background-color:#ffffff;font-weight:bold;text-align:left;padding-top:5px;padding-bottom:5px;padding-left:0px;'><a style='Float:left;padding:5px 5px 5px 5px;' href='javascript:;' Onclick='CloseClick()' ><input type='button' value='إغلاق' class='sBtn' onmouseover='this.className='sBtn sBtnhov'' onmouseout='this.className='sBtn''/></a><div style='padding-right:15px;padding-left:25px;color:#ff3090;text-align:right;'>" + result.Description + "</div></div>"
                	         $("#PrivewMediaDiv").css("width", divwidth).css("margin-left", marginleft).css("margin-top", margintop).html(HTML);

                	         //if (result.FileType == "1") {
                	         //    window.setTimeout('ShowImage();', 1200);
                	         // }
                	        
                	        
                	          if (result.FileType == "4") {
                	             OpenFilePopup(SelectedItem);
                	             document.getElementById("LodingDiv").style.display = "none";
                	         }
                	         else {
                	             var timeoutID = window.setTimeout('$("#DivMediaTitle").css("width", "' + divwidth + 'px").show("slow")', 600);
                	             var timeoutID = window.setTimeout('$("#DivMediaFotter").css("width", "' + divwidth + 'px").show("slow")', 600);
                	             document.getElementById("LodingDiv").style.display = "none";
                	             $("#PrivewMediaDiv").show("slow");
                	             document.getElementById("MediaBG").style.display = "";
                	         }
                	     }


                	     var Newwidth;
                	     var Fotterwidth;
                	     
                	     function OnMediaFail() {
                	         alert("Can't Load File !!");
                	     }

                	     function CloseClick() {
                	         $("#PrivewMediaDiv").hide("slow");
                	         document.getElementById("MediaBG").style.display = "none";
                	         var timeoutID = window.setTimeout('$("#PrivewMediaDiv").html("")', 600);

                	         // window.setTimeout($("#PrivewMediaDiv").html("");, 200000);

                	     }
