﻿function ShowInfo(sender, infoBoxId)
{
    var obj = document.getElementById(infoBoxId);
    obj.style.display = "block";
}


function HideInfo(sender, infoBoxId)
{
    var obj = document.getElementById(infoBoxId);
    obj.style.display = "none";
}


function OpenBeneficiaryForm(sender, url, width, height)
{
//    sender.onclick = "return false;" + sender.onclick;
    window.open(url, "BeneficiaryWindow", "scrollbars=1,menubar=0,resizable=1,width=" + width + ",height=" + height + ",top=50");
}


function ReturnButton(senderID)
{
    var btn = window.opener.BeneficiariesRefreshBtnClientID;
    //alert(window.opener.document.getElementById(btn));
    window.opener.document.getElementById(btn).click();
    window.self.close();
//    window.opener.document.location.reload();
//    window.opener.focus();
}


function CssClassSwap(elem)
{
	if(elem.getAttribute('active') != 'Active')
		elem.className = 'menuItem' + (elem.className.indexOf('Active') > -1 ? '' : 'Active');
}

function popProsymvatrikh(){
	window.open('Conditions.aspx','Προσυμβατική','scrollbars=yes,width=490,height=585,resizable=no,toolbar=0,status=0,location=0');
}



    function noCopyMouse(e) {
        var isRight = (e.button) ? (e.button == 2) : (e.which == 3);
        
        if(isRight) {
            //alert('You are prompted to type this twice for a reason!');
            return false;
        }
        return true;
    }

    function noCopyKey(e) {
        var forbiddenKeys = new Array('c','x','v');
        var keyCode = (e.keyCode) ? e.keyCode : e.which;
        var isCtrl;

        if(window.event)
            isCtrl = e.ctrlKey
        else
            isCtrl = (window.Event) ? ((e.modifiers & Event.CTRL_MASK) == Event.CTRL_MASK) : false;
    
        if(isCtrl) {
            for(i = 0; i < forbiddenKeys.length; i++) {
                if(forbiddenKeys[i] == String.fromCharCode(keyCode).toLowerCase()) {
                    //alert('You are prompted to type this twice for a reason!');
                    return false;
                }
            }
        }
        return true;
    }

    function disableCopyPaste() {
        if (event != null) {
            var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
            if (event.ctrlKey && (pressedKey == "c" || pressedKey == "v")) {
                event.returnValue = false;
            }
        }
    }
  
  
function toGreeklish(greekText){
       var lett = '';
       var lett0 = '';
       var lett2 = '';
       var lett3 = '';
       var newlett = '';
       var str = '';
       var result = '';
       var isUpper = false;
       var isUpper0 = false;
       var isUpper2 = false;
       for (var i = 0; i < greekText.length; i++){
              lett = greekText.charAt(i);
              lett0 = i > 0 ? greekText.charAt(i - 1) : '';
              lett2 = i <= greekText.length - 1 ? greekText.charAt(i + 1) : '';
              lett3 = i <= greekText.length - 2 ? greekText.charAt(i + 2) : '';
              isUpper = lett.toUpperCase() == lett && lett != 'ς';
              isUpper0 = lett0.toUpperCase() == lett0;
              isUpper2 = lett2.toUpperCase() == lett2;
              lett = lett.toLowerCase();
              lett0 = lett0.toLowerCase();
              lett2 = lett2.toLowerCase();
              lett3 = lett3.toLowerCase();
              newlett = '';
              switch (lett){
                     case 'α':
                           switch (lett2){
                                  case 'υ': case 'ύ':
                                         str = 'βγδζλμνραάεέηήιίϊΐοόυύϋΰωώ';
                                         if (str.indexOf(lett3) != -1 && lett3 != ''){
                                                newlett = 'av';
                                                i++;
                                         }
                                         str = 'θκξπστφχψ';
                                         if (str.indexOf(lett3) != -1 || lett3 == ''){
                                                newlett = 'af';
                                                i++;
                                         }
                                         break;
                                  default:
                                         newlett = 'a';
                           }
                           break;
                     case 'ά':
                           newlett = 'a';
                           break;
                     case 'β':
                           newlett = 'v';
                           break;
                     case 'γ':
                            switch (lett2){
                                  case 'γ':
                                         newlett = 'ng';
                                         i++;
                                         break;
                                  case 'ξ':
                                         newlett = 'nx';
                                         i++;
                                         break;
                                  case 'χ':
                                         newlett = 'nch';
                                         i++;
                                         break;
                                  default:
                                         newlett = 'g';
                           }
                           break;
                     case 'δ':
                           newlett = 'd';
                           break;
                     case 'ε':
                           switch (lett2){
                                  case 'υ': case 'ύ':
                                         str = 'βγδζλμνραάεέηήιίϊΐοόυύϋΰωώ';
                                         if (str.indexOf(lett3) != -1 && lett3 != ''){
                                                newlett = 'ev';
                                                i++;
                                         }
                                         str = 'θκξπστφχψ';
                                         if (str.indexOf(lett3) != -1 || lett3 == ''){
                                                newlett = 'ef';
                                                i++;
                                         }
                                         break;
                                  default:
                                         newlett = 'e';
                           }
                           break;
                     case 'έ':
                           newlett = 'e';
                           break;
                     case 'ζ':
                           newlett = 'z';
                           break;
                     case 'η': case 'ή':
                           switch (lett2){
                                  case 'υ': case 'ύ':
                                         str = 'βγδζλμνραάεέηήιίϊΐοόυύϋΰωώ';
                                         if (str.indexOf(lett3) != -1 && lett3 != ''){
                                                newlett = 'iv';
                                                i++;
                                         }
                                         str = 'θκξπστφχψ';
                                         if (str.indexOf(lett3) != -1 || lett3 == ''){
                                                newlett = 'if';
                                                i++;
                                         }
                                         break;
                                  default:
                                         newlett = 'i';
                           }
                           break;
                     case 'θ':
                           newlett = 'th';
                           break;
                     case 'ι': case 'ί': case 'ϊ': case 'ΐ':
                           newlett = 'i';
                           break;
                     case 'κ':
                           newlett = 'k';
                           break;
                     case 'λ':
                           newlett = 'l';
                           break;
                     case 'μ':
                           if (lett2 == 'π'){
                                  newlett = (lett0 == '' || lett3 == '' || lett0 == ' ' || lett3 == ' ') ? 'b' : 'mp';
                                  i++;
                           } else
                                  newlett = 'm';
                           break;
                     case 'ν':
                           newlett = 'n';
                           break;
                     case 'ξ':
                           newlett = 'x';
                           break;
                     case 'ο':
                           if ((lett2 == 'υ' || lett2 == 'ύ') && lett != 'ό'){
                                  newlett = 'ou';
                                  i++;
                           } else
                                  newlett = 'o';
                           break;
                     case 'ό':
                           newlett = 'o';
                           break;
                     case 'π':
                           newlett = 'p';
                           break;
                     case 'ρ':
                           newlett = 'r';
                           break;
                     case 'σ': case 'ς':
                           newlett = 's';
                           break;
                     case 'τ':
                           newlett = 't';
                           break;
                     case 'υ': case 'ύ': case 'ϋ': case 'ΰ':
                           newlett = 'y';
                           break;
                     case 'φ':
                           newlett = 'f';
                           break;
                     case 'χ':
                           newlett = 'ch';
                           break;
                     case 'ψ':
                           newlett = 'ps';
                           break;
                     case 'ω': case 'ώ':
                           newlett = 'o';
                           break;
                     default:
                           newlett = lett;
              }
              if (isUpper)
                     newlett = newlett.charAt(0).toUpperCase() + (isUpper2 ? newlett.substr(1).toUpperCase() : newlett.substr(1).toLowerCase());
              result += newlett;
       }
       return result;
}


        function Right(str, n)
        /***
                IN: str - the string we are RIGHTing
                    n - the number of characters we want to return

                RETVAL: n characters from the right side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                   return "";
                else if (n > String(str).length)   // Invalid bound, return
                   return str;                     // entire string
                else { // Valid bound, return appropriate substring
                   var iLen = String(str).length;
                   return String(str).substring(iLen, iLen - n);
                }
        }

        function Left(str, n)
        /***
                IN: str - the string we are LEFTing
                    n - the number of characters we want to return

                RETVAL: n characters from the left side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                        return "";
                else if (n > String(str).length)   // Invalid bound, return
                        return str;                // entire string
                else // Valid bound, return appropriate substring
                        return String(str).substring(0,n);
        }
        
        function Mid(str, start, len)
        /***
                IN: str - the string we are LEFTing
                    start - our string's starting position (0 based!!)
                    len - how many characters from start we want to get

                RETVAL: The substring from start to start+len
        ***/
        {
                // Make sure start and len are within proper bounds
                if (start < 0 || len < 0) return "";

                var iEnd, iLen = String(str).length;
                if (start + len > iLen)
                        iEnd = iLen;
                else
                        iEnd = start + len;

                return String(str).substring(start,iEnd);
            }


            function addCommas(nStr) {
                nStr += '';
                x = nStr.split('.');
                x1 = x[0];
                x2 = x.length > 1 ? ',' + x[1] : '';
                var rgx = /(\d+)(\d{3})/;
                while (rgx.test(x1)) {
                    x1 = x1.replace(rgx, '$1' + '.' + '$2');
                }
                return x1 + x2;
            }




            window.onresize = function () { if (document.getElementById('tblMenu')) CssClassSwap(document.getElementById('tblMenu').rows[0]); }

            $(document).ready(function () {
                inittipsy();
                fixdropwidth();
            });

            function inittipsy(){
                $('.tipsy').hide();
                $('.info-trigger,.tps').each(function () {
                    var el = $(this),
                        gvt = el.attr('gravity');
                    el.tipsy({ gravity: gvt, html: true, fade: false });
                });
            }
            
            function fixdropwidth()
            {
                var ie = ($.browser.msie === true);
                if(ie == true)
                {
                    $('select.fixwidth').ieSelectStyle();
                }
            }
