// JScript source code
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function dumpProps(obj, parent, recursive) {
	for (var i in obj) {
		if (parent) { msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
		if (!confirm(msg)) { return; }
		if (typeof obj[i] == "object") { 
			if (recursive && recursive==true)
			{
				if (parent) { 
					dumpProps(obj[i], parent + "." + i);
				} else { 
					dumpProps(obj[i], i);
				}
			}
		}
	}
}


// DEBUG MODE Flag
if (IsDebugMode==undefined) var IsDebugMode=false;

// Gets the top parent of a given document / window
function getTopParent(doc) {
	if ((doc==null)||(doc=='undefined')) doc=window;

	var parent=doc;
	var newParent=null;
	
	// search for parents 
	while ((newParent=getParentDocument(parent))!=null) {	
		if (parent==newParent) break;
		parent=newParent;
	}
		
	if (parent==doc) parent=null;
	return parent;
}

// Gets the top parent of a given document / window
function getParent(doc) {
	return getTopParent(doc);
}

function hasParent() {
	var p=getParent();
	return ((p!=null)&&(p!=undefined))
}


// Gets the first parent of the document
function getParentDocument(doc) {
	if (doc==undefined) doc=document;
	
	var p=null;
	if (doc.parent!=null)  p=doc.parent;
		
	return p;
}
// Get Window
function GetWindow(win) {
	if ((win==null)||win=='undefined') win=window;
	
	var parent=getTopParent(win);	
	if (parent!=null) win=parent;
	return win;
}

function hasOpener() {
	var w=GetWindow();
	var o=w.opener;
	return ((o!=null)&&(o!=undefined));
}

// Gets the opener of the window, which given window or document is in
function getOpener(win) {	
	if ((win==undefined)||(win==null)) win=window;
		
	var op=null;
	if ((win.opener!=null)&&(win.opener!=undefined))  op=win.opener;
	else {
		var parent=getTopParent(win);	
		if (parent!=null) {
			if (parent.opener!=null) op=parent.opener;
		}

	}
	
	return op;
}

var MainPageURL="/MEP/index.aspx?pageId=-3";
function GotoMainPage() {
	var _hasOpener=hasOpener();	
	var currentWindow=GetWindow();
		
	if (_hasOpener) {
		// 
		var openerWindow=getOpener();
		openerWindow.location.href=MainPageURL;
				
		// close this window
		closeMe();
		
		// focus to the main page
		openerWindow.focus();
		
	} else {
		var parent=getTopParent(window);
		if (parent==null) parent=window;
		
		parent.location.href=MainPageURL;		
	}
}

// Resize Error Page
function ResizeErrorPage() {		
	if (hasOpener()||hasParent()) {
		ShowAsCompactMode();		
		
		if (hasOpener()) {
			ResizeMe(760,525);
		}
	}
}

// Logoff script for popups
function Logoff_Popup() {	
	var openerWindow=getOpener();

	var parent=getTopParent(window);
	if (parent==null)	closeMe();
	else {
		CloseWindow(parent);
	}

	if (openerWindow!=null) {
		if (openerWindow.Logoff!=null) {
			openerWindow.Logoff();
		}
	}
}

// Logoff script for main window
function Logoff_MainWindow() {
	CloseAllMyChildPopups();
	document.location='/MEP/admin/Logoff.aspx';
}

function OpenHelpPopup(HelpID) {
	try {
		if(HelpID==null||HelpID=='undefined'||HelpID==0) {
			alert('Bu bölüm ile ilgili bir yardim tanimlanmamis!');
		}
		
		var url="/MEP/MEP/ORTAK/HELP/frmHelp.aspx?HelpID="+HelpID;
		var windowName="HelpPopup";
		var width=375;
		var height=460;
		var register=false;
		
		OpenMEPPopup_Modalless(url,windowName,width,height,register)
	
	} catch (ex) { 
		alert(ex);
	}
}


// Resizer this Window
function ResizeMe(width,height) {
	ResizeWindowTo(window,width,height);
}

// Set Window Size
function ResizeWindowTo(win,width,height) {
	try {	
		if (isIE_SP2()) height+=ExtraWindowHeightForSP2_Modalless;
		
		var ContainerWindow=GetWindow(win);
			
		ContainerWindow.dialogWidth=width+"px"; 
		ContainerWindow.dialogHeight=height+"px";
				
		ContainerWindow.width=width;
		ContainerWindow.height=height;
	
		ContainerWindow.resizeTo(width,height);
	} catch (ex) {}
}


function ResizePopupContent() 
{ 
    if(document.all) 
    { 
        winHeight=document.all['bodyArea'].offsetHeight; 
        winWidth=document.all['bodyArea'].offsetWidth; 
    } 
    window.resizeTo(winWidth+8,winHeight+30); 
}
//--------------------------------------------------------------------------
function setDocumentTitle(title) {
	var ContainerWindow=GetWindow(window);
	ContainerWindow.title=title;
}

// ==== CHILD MANAGEMENT =======================================

// List of Child Popups
// -------------------------------------------------------
var MyChildPopupList=new Array();
var CancelToCloseChildPopups=false;

// Close All My Childs
// -------------------------------------------------------
function CloseAllMyChildPopups() {
	// Check if it is Cancelled
	if (CancelToCloseChildPopups==true) return;
		
	// Start to Close Childs
	var popup;
	var i=0;
	for(i=0;i<MyChildPopupList.length;i++) {
		try {
			popup=MyChildPopupList[i];
			if ((popup!=null)&&(popup!=undefined)) {
				CloseWindow(popup);
			}
		} catch (ex) {
		}
	}
}

// Register new Child Popup
// -------------------------------------------------------
function AddNewChildPopup(PopupHandler) {

	var index=MyChildPopupList.length;
	MyChildPopupList[index]=PopupHandler;
}

// Close Me and my Childs
// -------------------------------------------------------
function closeMe() {
	// Close All MyChilds
	CloseAllMyChildPopups();
	
	var ContainerWindow=GetWindow(window);
	
	// Close All Parent's Childs
	if ((ContainerWindow.CloseAllMyChildPopups!=null)&&(ContainerWindow.CloseAllMyChildPopups!=undefined)) ContainerWindow.CloseAllMyChildPopups();
	
	// Close parent
	ContainerWindow.close();
}

// Tries to Close a Window
//-------------------------------------------------------
function CloseWindow(windowHandler) {
	if ((windowHandler==null)||(windowHandler==undefined)) return;
	
	if ((windowHandler.closeMe!=null)&&(windowHandler.closeMe!=undefined)) {
		windowHandler.closeMe();
	} else
		windowHandler.close();
}
// =============================================================

var ExtraWindowHeightForSP2_Modalless=30; // 30;
var ExtraWindowHeightForSP2_Modal=20;
var DetectPopupBlocker=true;
function OpenMEPPopup_Modalless(url,windowName,width,height,RegisterAsChild,showScrollbars) {
	var PopupHandler=new Object();
			
	var resizable=(IsDebugMode?1:0);
	var statusBar=(isIE_SP2()?1:0);
	var scrollbars=(((showScrollbars==1)||(showScrollbars==true))?1:0);
	var features='fullscreen=no, width='+width+', height='+height+', scrollbars='+scrollbars+', status='+statusBar+', resizable='+resizable+'';	
	
	PopupHandler=window.open(url,windowName,features);
	if (DetectPopupBlocker && (PopupHandler==null || typeof(PopupHandler)=="undefined")) {
		document.location.href="/MEP/MEP/ERRORS/Error.aspx?ErrorCode=900";
	}
	
	if ((RegisterAsChild==null)||(RegisterAsChild==undefined)) RegisterAsChild=true;
	
	// Register to the child list
	if (RegisterAsChild) AddNewChildPopup(PopupHandler);
	
	PopupHandler.focus();		
	// return PopupHandler;
}

function OpenMEPPopup_ModallessResizable(url,windowName,width,height,RegisterAsChild,showScrollbars,resize) {
	var PopupHandler=new Object();
	
	// Check SP2
	//if (isIE_SP2()) alert("Internet Explorer'inizda Service Pack 2 yüklü bulundu?u için problem ya?ayabilirsiniz.");
		
	// if (isIE_SP2()) height+=ExtraWindowHeightForSP2_Modalless;
		
	var resizable=(((resize==1)||(resize==true))?1:0);
	var statusBar=(isIE_SP2()?1:0);
	var scrollbars=(((showScrollbars==1)||(showScrollbars==true))?1:0);

//	alert('resize='+resize+'\nresizable='+resizable);
	
	var features='fullscreen=no; width='+width+'; height='+height+'; scrollbars='+scrollbars+'; status='+statusBar+'; resizable='+resizable+';';	
	
	PopupHandler=window.open(url,windowName,features);
	if (DetectPopupBlocker && (PopupHandler==null || typeof(PopupHandler)=="undefined")) {
		document.location.href="/MEP/MEP/ERRORS/Error.aspx?ErrorCode=900";
	}
	
	if ((RegisterAsChild==null)||(RegisterAsChild==undefined)) RegisterAsChild=true;
	
	// Register to the child list
	if (RegisterAsChild) AddNewChildPopup(PopupHandler);
	
	PopupHandler.focus();	
	// return PopupHandler;	
}


function OpenQuickGuide() {
	OpenMEPPopup_Modalless('/MEP/MiscFiles/QuickGuide/UI_Player.html','QuickGuide',700,440,false);
}

function OpenElEleBuyuyyukSevgiyi() {
	OpenMEPPopup_Modalless('/MEP/MiscFiles/ElEleBuyuttukSevgiyi/index.htm','ElEleBuyuttukSevgiyi',790,580,false);
}



var LastPopupURL="";
function OpenMEPPopup_ManualModal(url,windowName,width,height) {
	LastPopupURL=url;
	if (isIE_SP2()) height=parseInt(height)+ExtraWindowHeightForSP2_Modal;
	var resizable=(IsDebugMode?1:0);
	var w=window.open('/MEP/MEP/ORTAK/ManualModalWindow.aspx',windowName,'width:'+width+'; height:'+height+' scrollbars:no; status:no; resizable='+resizable);
	if (DetectPopupBlocker && (w==null || typeof(w)=="undefined")) {
		document.location.href="/MEP/MEP/ERRORS/Error.aspx?ErrorCode=900";
	}
	
	w.focus();
	// return w;
}

function OpenMEPPopup_Modal(urlToOpen,width,height) {

	if (isIE_SP2()) height=parseInt(height)+ExtraWindowHeightForSP2_Modal;
	// alert("isIE_SP2():"+isIE_SP2());

	var param=new PopupData();
	param.opener=window;
	param.url=urlToOpen;
	var resizable=(IsDebugMode?1:0);
	var statusBar=(isIE_SP2()?1:0);
	var features='edge:Raised;center:Yes;help:No;resizable:'+(resizable?'Yes':'No')+';status:'+(statusBar?'Yes':'No')+';';
	
	OpenModalDialog('/MEP/MEP/ORTAK/ModalFrame.htm',param,width,height,features);
}

function PopupData() {
	this.opener=null;
	this.url="";
}

function OpenModalDialog(url,param,width,height,features) {
	if ((features==null)||(features==undefined)) features="";
	if (window.showModalDialog) {
		window.showModalDialog(url,param,'dialogWidth:'+width+'px; dialogHeight:'+height+'px;'+features);	
	} else {
		OpenMEPPopup_Modalless(param.url,"MEP_ModalDiag",width,height-27,true);
	}
}

//--------------------------------------------------------------------------
function setParentLocation(newURL) {
	var doc=null;
	
	var op=getParent();	
	doc=op.document;	
		
	if (doc==null) {
		if (IsDebugMode) alert('DOCUMENT bulunamadi!');
		return;
	}
	
	doc.location=newURL;
}

//--------------------------------------------------------------------------
function setParentElement(elementName,elementValue) {
	var doc=null;
	
	var op=getParent();
	doc=op.document;	
		
	if (doc==null) {
		if (IsDebugMode) alert('DOCUMENT bulunamadi!');
		return;
	}
	
	var f=MM_findObj(elementName,doc);
	
	if (f==null) {
		if (IsDebugMode) alert(elementName+' bulunamadi!');
		return;
	}

	f.value=elementValue;
}

//--------------------------------------------------------------------------
function setOpenerElement(elementName,elementValue) {
	var doc=null;
		
	var op=getOpener();
	doc=op.document;	
		
	if (doc==null) {
		if (IsDebugMode) alert('DOCUMENT bulunamadi!');
		return;
	}
	
	var f=MM_findObj(elementName,doc);
	if (f==null) {
		if (IsDebugMode) alert(elementName+' bulunamadi!');
		return;
	}
	f.value=elementValue;
}

function getOpenerManagementModuleClientID() {
	var op=getOpener();	
	return op._managementModuleClientID;
}

function postBackOpener() {

	// find opener
	var op=getOpener();

	if ((op==null)||(op==undefined)) return;

	// Cancel to close the opener window of its childs
	op.CancelToCloseChildPopups=true;	

	// do postback
	op.__doPostBack('','');
}

function postBackParent() {
	// find opener
	var op=getParent();
	if ((op==null)||(op==undefined)) return;
	
	// Cancel to close the opener window of its childs
	op.CancelToCloseChildPopups=true;	
	
	// do postback
	op.__doPostBack('','');
}

function Show(object){
	var a=new MM_findObj(object);
	a.style.display='block';
}

function Hide(object){
	var a=new MM_findObj(object);
	a.style.display='none';
}

function ShowHide(object){
		var a=new MM_findObj(object);

		if (a.style.display=='none')
			Show(object);
		else 
			Hide(object);
}

function SetImage(ElementName,ImageURL) {
	var img=new MM_findObj(ElementName);
	img.src=ImageURL;	
}

function isElementVisible(object)
{
	var a=new MM_findObj(object);
	if (a.style.display=='none')
		return true;
	else
		return false;
}

var g_fIsSP2 = false;
function isIE_SP2()
{
   g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
   if (g_fIsSP2) {
		return true;   
   }
   else
   {
		return false;
   }
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

// MEP Menu Scripts -----------------------------------------------
	function menu_ItemHover(menuId, itemId, bHover){
		try {
			setPanelMenuState(bHover*1);
		} catch(e) {
		}
	}
	
// MEP NEWSPORTAL_MODULES Scripts --------------------------------
	function openNews(NewsID) {			
		var url="/MEP/MEP/NEWSPORTAL_MODULES/News/Forms/NewsRead.aspx?NewsID="+NewsID;
		var popupWin = window.open("","News_"+NewsID,"width=500,height=650");
		popupWin.focus();
		popupWin.document.location.href=url;			
	}

	function openNewsForPrint(NewsID) {			
		var url="/MEP/MEP/NEWSPORTAL_MODULES/News/Forms/NewsReadForPrint.aspx?NewsID="+NewsID;
		var popupWin = window.open("","News_"+NewsID,"resizable");
		popupWin.focus();
		popupWin.document.location.href=url;			
	}
	
	function openNewsFromMedia(NewsFromMediaID) {			
		var url="/MEP/MEP/NEWSPORTAL_MODULES/NewsFromMedia/Forms/NewsReadForm/frmNewRead_ForPrint.aspx?NewsFromMediaID="+NewsFromMediaID;		
		var popupWin = window.open("","NewsFromMedia_"+NewsFromMediaID,"width=700,height=720,scrollbars=yes, resizable=yes, toolbar=yes");
		popupWin.focus();
		popupWin.document.location.href=url;			
	}
	
	function openNewsFromMedia_v2(NewsFromMediaID) {			
		var url="/MEP/MEP/NEWSPORTAL_MODULES/NewsFromMedia/Forms/NewsReadForm/NewsRead.aspx?NewsFromMediaID="+NewsFromMediaID;		
		var popupWin = window.open("","NewsFromMedia_"+NewsFromMediaID,"width=500,height=720");
		popupWin.focus();
		popupWin.document.location.href=url;			
	}
	
	function openRSSNews(guid, ModuleID) {			
		var url="/MEP/MEP/NEWSPORTAL_MODULES/RSSNews/Forms/NewsRead.aspx?guid="+guid+"&ModuleID="+ModuleID;
		var popupWin = window.open("","RSSNews_"+guid,"width=500,height=650");
		popupWin.focus();
		popupWin.document.location.href=url;			
	}	
	
	function openBroadcastVideo(id) {			
		var url="/MEP/MEP/NEWSPORTAL_MODULES/Broadcast/BroadcastModule/frmVideoPlayer.aspx?id="+id;
		var popupWin = window.open("","VideoPlayer_"+id,"width=710,height=460");
		popupWin.focus();
		popupWin.document.location.href=url;
	}	

	function openVideo(path) {			
		var url="/MEP/MEP/DESKTOP_MODULES/AudioVideoPlayers/frmVideoPlayer.aspx?f="+path;
		var popupWin = window.open("","VideoPlayer","width=500,height=500");
		popupWin.focus();
		popupWin.document.location.href=url;
	}	
	
	function openAudio(path) {			
		var url="/MEP/MEP/DESKTOP_MODULES/AudioVideoPlayers/frmAudioPlayer.aspx?f="+path;
		var popupWin = window.open("","AudioPlayer","width=500,height=265");
		popupWin.focus();
		popupWin.document.location.href=url;
	}	


	function OpenWebMail() { 
	var url="/MEP/MiscFiles/EmailLoginForm/frmLogin.aspx";
	window.open(url,'','status=false,menubar=false,titlebar=false,toolbar=false,resizable,width=1000,height=600'); 
	}	