﻿//function getCurrentStyle(el, property) { 
//  if (document.defaultView) { 
//    // Get computed style information: 
//    if (el.nodeType != el.ELEMENT_NODE) return null; 
//    return document.defaultView.getComputedStyle(el, '').getPropertyValue(property); 
//  } 
//  if (el.currentStyle) { 
//    // Get el.currentStyle property value: 
//    return el.currentStyle.getAttribute(property.split('-').join(''));  // We need to get rid of slashes 
//  } 
//  if (el.style) { 
//    // Get el.style property value: 
//    return el.style.getAttribute(property.split('-').join(''));  // We need to get rid of slashes 
//  } 
//  return  null; 

//} 

//function getCurrentBackColor(el)
//{
//        var s = getCurrentStyle(el,'background-Color');
//        while (s.toLowerCase() == 'transparent')
//          {
//           el = el.parentElement;
//           if (el == null) break;
//           s = getCurrentStyle(el,'background-Color');
//        }
//        return s;
//        
//}
//function getCurrentBackgroundImage(el)
//{
//      var s = getCurrentStyle(el,'background-Image');
//      while (s == 'none')
//          {
//           el = el.parentElement;
//           if (el == null) break;
//           s = getCurrentStyle(el,'background-Image');
//           if (s == 'none')
//                    {
//                      s = getCurrentStyle(el,'background');
//                      if ( s == null) {s='none'}
//                    }
//           }
//        return s;      
//}
//function getCurrentBackgroundPosition(el)
//{
//      var s = getCurrentStyle(el,'background-repeat');
//      while (s == null)
//          {
//           el = el.parentElement;
//           if (el == null) break;
//           s = getCurrentStyle(el,'background-repeat');
//          }
//        return s;      
//}

//function getCurrentColor(el)
//{
//        var s = getCurrentStyle(el,'color');
//        return s;
//        
//}
//function getCurrentFontStyle(el)
//{
//        var sfam    = getCurrentStyle(el,'font-Family');
//        var ssize   = getCurrentStyle(el,'font-Size');
//        var sw      = getCurrentStyle(el,'font-Weight');
//        var sd      = getCurrentStyle(el,'text-Decoration');
//        var ss      = getCurrentStyle(el,'font-style');
//        return sfam + '|' + ssize + '|' + sw + '|' + sd + "|" + ss;
//}       
////function getStyle(id,targetid)
////{
////    var el =document.getElementById(id);
////    var target = document.getElementById(targetid);
////    
////    var bc = getCurrentBackColor(el);
////    var sbc = '';
////    if (bc != null)  sbc='BackColor=' + bc;
////    
////    var c = getCurrentColor(el);
////    var sc = '';
////    if (c != null)  sc='Color=' + c;
////    
////    var f = getCurrentFontStyle(el);
////    var sf = '';
////    if (f != null) sf= 'Font=' + f;
////    target.value = sbc + ';' + sc + ';' + sf; //; //';Color=' + getCurrentColor(el) + ';Font=' + getCurrentFontStyle(el);
////    //alert(target.innerText);
////    return true;
////}

//function getStyle(id)
//{
//    var el =document.getElementById(id);
//    var bc = getCurrentBackColor(el);
//    var sbc = '';
//    if (bc != null)  sbc='BackColor=' + bc;
//    var sbi = '';
//    var bi = getCurrentBackgroundImage(el);
//    if (bi != null)  sbi='Background=' + bi;
//    var sbp = '';
//    var bp = getCurrentBackgroundPosition(el);
//    if (bp != null)  sbp='BackgroundPos=' + bp;       
//    var c = getCurrentColor(el);
//    var sc = '';
//    if (c != null)  sc='Color=' + c;
//    
//    var f = getCurrentFontStyle(el);
//    var sf = '';
//    if (f != null) sf= 'Font=' + f;
//    var ret = sbc + ';' + sc + ';' + sf + ';' + sbi + ";" + sbp;
//    return URLEncode(ret); //; //';Color=' + getCurrentColor(el) + ';Font=' + getCurrentFontStyle(el);
//        
//}
////  function URLencode(sStr) {
////    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace('/','%2F');
////  }
//  
// function URLEncode(plaintext)
//{
//	// The Javascript escape and unescape functions do not correspond
//	// with what browsers actually do...
//	var SAFECHARS = "0123456789" +					// Numeric
//					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
//					"abcdefghijklmnopqrstuvwxyz" +
//					"-_.!~*'()";					// RFC2396 Mark characters
//	var HEX = "0123456789ABCDEF";

//	var encoded = "";
//	for (var i = 0; i < plaintext.length; i++ ) {
//		var ch = plaintext.charAt(i);
//	    if (ch == " ") {
//		    encoded += "+";				// x-www-urlencoded, rather than %20
//		} else if (SAFECHARS.indexOf(ch) != -1) {
//		    encoded += ch;
//		} else {
//		    var charCode = ch.charCodeAt(0);
//			if (charCode > 255) {
//			    alert( "Unicode Character '" 
//                        + ch 
//                        + "' cannot be encoded using standard URL encoding.\n" +
//				          "(URL encoding only supports 8-bit characters.)\n" +
//						  "A space (+) will be substituted." );
//				encoded += "+";
//			} else {
//				encoded += "%";
//				encoded += HEX.charAt((charCode >> 4) & 0xF);
//				encoded += HEX.charAt(charCode & 0xF);
//			}
//		}
//	} // for

//	return encoded;
//	//return false;
//}


//  function showcontent(contentel,title,width,height)
//  {
//  /*var win = new Window(Application.getNewId(), {className: "alphacube", title: "Infodromio Calendar", 
//                                              top:70, left:100, width:650, height:500, 
//                                              resizable: true, url: "http://applications.infodromio.com/frmCalendar.aspx", showEffectOptions: {duration:1}}); */
//    var win = new Window(Application.getNewId(), {className: "alphacube", title: title, 
//                                              width:width, height:height, 
//                                              resizable: true,showEffectOptions: {duration:0}});                                              
//    var celem = document.getElementById(contentel);
//    var cvalue = celem.value;
//    win.getContent().innerHTML = cvalue;
//    win.showCenter(true);
//    //win.setStatusBar("<a Href='http://www.Infodromio.com'>infodromio.com</a>");
//    //win.showCenter(true);                                            
//    return false;  
//   } 
//   function showcontentautosize(contentel,title)
//  {
//  /*var win = new Window(Application.getNewId(), {className: "alphacube", title: "Infodromio Calendar", 
//                                              top:70, left:100, width:650, height:500, 
//                                              resizable: true, url: "http://applications.infodromio.com/frmCalendar.aspx", showEffectOptions: {duration:1}}); */
//    var win = new Window(Application.getNewId(), {className: "alphacube", title: title, 
//                                              resizable: true,showEffectOptions: {duration:0}});   
//    win.setContent(contentel,true,false);
//    win.showCenter(true);
//    //win.setStatusBar("<a Href='http://www.Infodromio.com'>infodromio.com</a>");
//    //win.showCenter(true);                                            
//    return false;  
//   } 
//  function showurl(url,title,width,height)
//  {
//  /*var win = new Window(Application.getNewId(), {className: "alphacube", title: "Infodromio Calendar", 
//                                              top:70, left:100, width:650, height:500, 
//                                              resizable: true, url: "http://applications.infodromio.com/frmCalendar.aspx", showEffectOptions: {duration:1}}); */
//    var win = new Window(Application.getNewId(), {className: "alphacube", title: title, 
//                                              width:width, height:height, 
//                                              resizable: true,url: url,minimizable: false,maximizable: false,hideEffectOptions: {duration:0},showEffectOptions: {duration:0}});                                              
//    //win.setStatusBar("<a Href='http://www.Infodromio.com' target='_blank'>infodromio.com</a>");
//    win.showCenter(true);   
//    return false;                                         
//        
//   } 
//   function showurlauto(url,title)
//  {
//  /*var win = new Window(Application.getNewId(), {className: "alphacube", title: "Infodromio Calendar", 
//                                              top:70, left:100, width:650, height:500, 
//                                              resizable: true, url: "http://applications.infodromio.com/frmCalendar.aspx", showEffectOptions: {duration:1}}); */
//    var win = new Window(Application.getNewId(), {className: "alphacube", title: title, 
//                                              resizable: true,showEffectOptions: {duration:0}});
//    win.setURLAutoSize(url,win);
////    var myObserver = {
////		onload: function(eventName, win) 
////		{
////			win.fitContent;
////		}}
////	Windows.addObserver(myObserver);
//    //win.setStatusBar("<a Href='http://www.Infodromio.com'>infodromio.com</a>");
//    win.showCenter(true);
//    return false;
//        
//   } 
//function changedisplay(id)
//{
//    var el =document.getElementById(id);
//    el.style.display="block";
//    return false;
//}
 function getUrl(w,URL)
    {
          w.location = URL; 
    }             

function setRadURL(WindowName,URL)
{
            var oManager = GetRadWindowManager();
		    var oWindow = oManager.GetWindowByName(WindowName);
		    if (oWindow != null ) 
			{
			    var oWindow = window.radopen(null, WindowName);
				oWindow.SetUrl(URL);
				alert (URL);
			}
			return false;
}    
function handleErr(msg,url,l)
{
    return false;
}
function ShowRadDialog(URL,Title,width,height)
				{					
				onerror=handleErr;
					//Force reload in order to guarantee that the onload event handler of the dialog which configures it executes on every show.
					var oWnd = window.radopen(URL, null);
					if (width != -1) oWnd.SetWidth(width);
					if (height != -1) oWnd.SetHeight(height);
					if (width != -1) oWnd.Center();
					oWnd.SetTitle(Title);
					oWnd.SetStatus("<strong>ΔΥΝΑΜΙΣ ΑΣΦΑΛΙΣΤΙΚΗ</strong>");
					//oWnd.SetUrl(oWnd.GetUrl());
					return false;
				}
				
function GetElementPosition (el)   
        {   
            var parent = null;   
            var pos = {x: 0, y: 0};   
            var box;   
       
            if (el.getBoundingClientRect)    
            {    
                // IE   
                box = el.getBoundingClientRect();   
                var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;   
                var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;   
       
                pos.x = box.left + scrollLeft - 2;   
                pos.y = box.top + scrollTop - 2;   
                   
                return pos;   
            }   
            else if (document.getBoxObjectFor)    
            {    
                // gecko   
                box = document.getBoxObjectFor(el);   
                pos.x = box.x - 2;   
                pos.y = box.y - 2;   
            }   
            else    
            {    
                // safari/opera   
                pos.x = el.offsetLeft;   
                pos.y = el.offsetTop;   
                parent = el.offsetParent;   
                if (parent != el)   
                {   
                    while (parent)    
                    {   
                        pos.x += parent.offsetLeft;   
                        pos.y += parent.offsetTop;   
                        parent = parent.offsetParent;   
                    }   
                }   
            }   
       
       
            if (window.opera)   
            {   
                parent = el.offsetParent;   
                   
                while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML')    
                {   
                    pos.x -= parent.scrollLeft;   
                    pos.y -= parent.scrollTop;   
                    parent = parent.offsetParent;   
                }   
            }   
            else  
            {   
                parent = el.parentNode;    
                while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML')    
                {   
                    pos.x -= parent.scrollLeft;   
                    pos.y -= parent.scrollTop;   
       
                    parent = parent.parentNode;   
                }   
            }   
            return pos;
        }
        
        var skip_close = false;
        var param_value = '';
        function OpenWindowWithParam (WindowName, ContentElementId, element)
        {
            //alert(param_value + '==' +  ParamValue)
              var oWindow = window.radopen(null, null);
              oWindow.SetUrl("/DotNetNuke%20WebSite/Resources/HoverPopUp.htm");
              //του βάζω το Style Sheet Reference
              //el.document.createStyleSheet("/DoteNetNuke%20WebSite/Portals/_default/Skins/Imagination-Blue/Styles.css"); //'.HoverWindow {font-size: 10px;color: black;font-family: verdana;padding-right: 10px;padding-left: 10px;padding-bottom: 10px;padding-top: 10px;filter: alpha(opacity=80);-moz-opacity: 0.8;opacity: 0.8;}";
              //oWindow.SetUrl("/DotNethtml?paramName=" + escape(ParamValue));
              var contentElement = document.getElementById(ContentElementId); 
//              var Content = '<DIV Class="HoverWindow" id="DivContent">' + contentElement.innerHTML + '</DIV>';
//              oWindow.SetContent(Content);

//              //Παίρνω το Frame του Window
//              
//              //Δημιουργώ ένα element DIV
              var el = oWindow.GetContentFrame();
              var Divel = el.document.body.getElementsByTagName('div')[0];
              //alert(Divel);
              Divel.innerHTML = contentElement.innerHTML;
              //oWindow.SetWidth(Divel.offsetWidth + 4);
              //oWindow.SetHeight(el.Divel.offsetHeight + 70);
            var pos = GetElementPosition(element);
            var X = pos.x;
            var Y = pos.y;
            
            oWindow.MoveTo(X, Y + element.offsetHeight);
//            param_value = ParamValue;
            skip_close=false;
        }
        
        function HandleClick (WindowName, ParamValue)
        {
            skip_close=true;
        }
        
        function CloseWindow (WindowName) 
        {
            if (skip_close) return 
            var oManager = GetRadWindowManager();
		    var oWindow = oManager.GetWindowByName(WindowName);
		    param_value = '';
		    if (oWindow != null ) 
			{
				oWindow.Close();
			}
        }
        function CloseWindows () 
        {
            if (skip_close) return 
            var oManager = GetRadWindowManager();
		    oManager.CloseAll();
        }