﻿function SetHeight(obj,SecObj,MasterName){
   
    var GetObject = document.getElementById(obj)
    var GetHeight=document.getElementById(MasterName + '_DivFixWidh').offsetHeight + document.getElementById(SecObj).offsetHeight
     
    var GetAllDocHeight = document.body.clientHeight
    var GetFinalHeight = GetAllDocHeight - GetHeight
    if (GetFinalHeight<1)
        GetFinalHeight=391 
    if (document.all){
        if  (GetFinalHeight>390 )
            GetObject.style.height=GetFinalHeight - 30
      }
    else{
        if  (GetFinalHeight>390 ){
                if (GetObject.offsetHeight<GetFinalHeight)
                    GetObject.style.height=GetFinalHeight - 29
            }
            else{
                //GetObject.style.height=390
            }
      }
  }


  function SetHeight_ContentPage(obj, SecObj, MasterName) {

      var GetObject = document.getElementById(obj)
      var GetHeight = document.getElementById(MasterName + '_DivFixWidh').offsetHeight + document.getElementById(SecObj).offsetHeight
       
      var GetAllDocHeight = document.body.clientHeight
      var GetFinalHeight = GetAllDocHeight - GetHeight

     
      if (GetFinalHeight < 1)
          GetFinalHeight = 391
      if (document.all) {
          if (GetFinalHeight > 390)
              GetObject.style.height = GetFinalHeight - 30
      }
      else {
          if (GetFinalHeight > 390) {
              if (GetObject.offsetHeight < GetFinalHeight)
                  GetObject.style.height = GetFinalHeight - 29
          }
          else {
              //GetObject.style.height = 390
          }
      }
  } 
 
function SetHeightContact(obj,SecObj,MasterName,DivBanner){
    var GetObject = document.getElementById(obj)
    var GetObjectBan = document.getElementById(DivBanner)
    
    var GetHeight=document.getElementById(MasterName + '_DivFixWidh').offsetHeight + document.getElementById(SecObj).offsetHeight 
     
    var GetAllDocHeight = document.body.clientHeight
    var GetFinalHeight = GetAllDocHeight - GetHeight
    if (GetFinalHeight<1)
        GetFinalHeight=1
        var OldHeight = GetObject.offsetHeight
    
    if (document.all){
        GetObject.style.height=GetFinalHeight + 3
        OldHeight = GetObject.offsetHeight - OldHeight
        document.getElementById('DivbottomSep').style.height=OldHeight
      }
    else{
        GetObject.style.height=GetFinalHeight + 4
        OldHeight = GetObject.offsetHeight - OldHeight
        document.getElementById('DivbottomSep').style.height=OldHeight-22
      }
}



function SetWidth(SecObj,obj,Container,ContainerSec){
    var GetObject = document.getElementById(obj)
    var GetSecObject = document.getElementById(SecObj)
    var GetWidth=document.getElementById(SecObj).offsetWidth 
    var GetAllDocWidth = document.body.clientWidth
    var GetFinalWidth = GetAllDocWidth - GetWidth
    var GetContainer = document.getElementById(Container)
    var GetContainerSec = document.getElementById(ContainerSec)
     if (GetAllDocWidth<1135)
         GetAllDocWidth=1135
     
    GetContainer.style.width=GetAllDocWidth
    GetContainerSec.style.width=1135
    if (GetFinalWidth<969){
        GetFinalWidth=969
    }
   
    if (document.all)
        GetObject.style.width=GetFinalWidth 
    else
       GetObject.style.width=GetFinalWidth  
}

function CheckSearch(obj,Msg,Frasi,lang,MsgCheck){
    var Search = document.getElementById(obj).value
    var ObjFrasi = document.getElementById(Frasi).checked
    if (Search == MsgCheck)
        Search='';
    if(Search!=''){
       if(Search.length==1){
          alert(Msg)
       }
       else{
           location.href='Search.aspx?Keyword=' + Search + '&Phrase=' + ObjFrasi + '&lang=' + lang
       }
    }
    else
        alert(Msg)
}

function CheckSearchValue(Obj, MsgCheck) {
    var Search = document.getElementById(Obj).value
    if (Search == MsgCheck)
        document.getElementById(Obj).value = '';
}

function handle_keydown(e,Obj)
{
    document.getElementById(Obj).focus();
    return(true);
}

function restoreScroll() {
	if(document.body.clientWidth < 770)
		document.body.style.overflowX = 'auto';
	else
		document.body.style.overflowX = 'hidden';
	if(navigator.appName.toLowerCase().indexOf('explorer') > -1) {
		str = parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('MSIE') + 4, 4));
		if(str < 6) {
			try {					
				document.body.style.overflowY = 'auto';
			} catch(e) { }
		}
	}
}

function SpitMenu(){

    for (i=0;i<mnuArr.length;i++){
        var Title = mnuArr[i][0]
        var Depth = mnuArr[i][1]
        var Class   = mnuArr[i][2]
        var SelectedM = mnuArr[i][3]
        var Url = mnuArr[i][4]
        var IsFirstTow=mnuArr[i][5]
       
        addMenu(divleftmenu,Title,Depth,Class,SelectedM,Url,IsFirstTow);
    }
    
    restoreScroll();
}

window.onresize=restoreScroll;

function addMenu(Obj,Title,Depth,Class,SelectedM,Url,IsFirstTow) {
	var tbody = document.getElementById(Obj);
	var row = document.createElement("DIV");
	var ImgDiv = document.createElement("DIV");
	var TxtDiv = document.createElement("DIV");
	
	if (Depth==1){
	    ImgDiv.innerHTML = "<img src='images/Menu Pointer.png'>";}
	else{
	    ImgDiv.innerHTML = "<img src='images/Low Pointer.gif'>";}
	    
	 if (Depth==1){
	     if (SelectedM==0){
	            ImgDiv.className='NewDivFloatLeft_' + Class
	         }
	     else{
	            ImgDiv.className='NewDivFloatLeftSelected_' + Class
	         }
	 }
	 
	 if (Depth==2){
	       ImgDiv.className='DivDepth2Img'
	     }
	 if (Depth==3){
	       ImgDiv.className='DivDepth3Img'
	 }
	
	 if (Depth==1){
	    if (SelectedM==1)
	        row.style.backgroundColor='#d1564e' 
	 }
	 if (Depth==2){
	    row.style.backgroundColor='white'
	 }
	 if (Depth==3){
	    row.style.backgroundColor='white'
	 }
	
	TxtDiv.innerHTML = Title
	row.appendChild(ImgDiv);
	row.appendChild(TxtDiv);
	var DottDiv = document.createElement("DIV");
	DottDiv.className='MenuDott'
	DottDiv.innerHTML='&nbsp;s&nbsp;'
	
	if (Depth!=1)
	row.appendChild(DottDiv);
	
	tbody.appendChild(row);
	row.onclick=function SendTo(){location.href=Url;}
	
if (Depth==1 && SelectedM==0){
        row.onmouseover=function MouseOverDepth1(){TxtDiv.style.backgroundColor='#396cae';ImgDiv.style.backgroundColor='#396cae';};
        if (IsFirstTow==0)
            row.onmouseout=function MouseOutDepth1(){TxtDiv.style.backgroundColor='#8f8e8e';ImgDiv.style.backgroundColor='#8f8e8e';};
        else
            row.onmouseout=function MouseOutFTDepth1(){TxtDiv.style.backgroundColor='#033e89';ImgDiv.style.backgroundColor='#033e89';};
    }
if (Depth==2 && SelectedM==0){
        row.onmouseover=function MouseOverDepth2(){TxtDiv.style.color='#d1564e';}
        row.onmouseout=function MouseOutDepth2(){TxtDiv.style.color='black';;}
    }
if (Depth==3 && SelectedM==0){
        row.onmouseover=function MouseOverDepth3(){TxtDiv.style.color='#d1564e';}
        row.onmouseout=function MouseOutDepth3(){TxtDiv.style.color='black';}
    }        

	var GetHeight=0
	GetHeight=TxtDiv.offsetHeight
	
	 
	if (Depth==1){
	    if (GetHeight==13){
	        if (SelectedM==0)
	            TxtDiv.className='NewDivPadding1_' + Class
	        else
	            TxtDiv.className='Selected1_' + Class
	    }
	    if (GetHeight==26){
	        if (SelectedM==0){
	            if (document.all) 
	                TxtDiv.className='NewDivPadding2_' + Class
	            else    
	                TxtDiv.className='NewDivPadding2ex_' + Class
	            }
	        else{
	             if (document.all) 
	                TxtDiv.className='Selected2_' + Class
	            else    
	                TxtDiv.className='Selected2ex_' + Class
	            }
	                
	            
	    }
	    if (GetHeight==39){
	       if (SelectedM==0)
	          TxtDiv.className='NewDivPadding3_' + Class
	       else
	          TxtDiv.className='Selected3_' + Class
	    }
	    TxtDiv.style.marginLeft='8px'
	}
    if (Depth==2){
            if (SelectedM==0)
	            TxtDiv.className='DivDepth2_Txt' 
	        else
	            TxtDiv.className='DivDepth2_TxtSelected' 
	            
	            if (TxtDiv.offsetHeight==27){
	                ImgDiv.className='DivDepth2Img2Rows'
	            }
    }	
     if (Depth==3){
            if (SelectedM==0)
	            TxtDiv.className='DivDepth3_Txt' 
	        else
	            TxtDiv.className='DivDepth3_TxtSelected' 
	            
	            if (GetHeight==26){
	                ImgDiv.className='DivDepth3Img2Rows'
	            }
    }	
}

function SpitMenuSiteMap(){
    for (i=0;i<mnuArrSiteMap.length;i++){
        var Title = mnuArrSiteMap[i][0]
        var Depth = mnuArrSiteMap[i][1]
        var Class   = mnuArrSiteMap[i][2]
        var SelectedM = mnuArrSiteMap[i][3]
        var Url = mnuArrSiteMap[i][4]
        var IsFirstTow=mnuArrSiteMap[i][5]
      
        addMenuSiteMap(divleftmenuSiteMap,Title,Depth,Class,SelectedM,Url,IsFirstTow);
       
    }
}

function addMenuSiteMap(Obj,Title,Depth,Class,SelectedM,Url,IsFirstTow) {

    
	var tbody = document.getElementById(Obj);
	var row = document.createElement("DIV");
	var ImgDiv = document.createElement("DIV");
	var TxtDiv = document.createElement("DIV");
		
	
	if (Depth==1){
	        TxtDiv.innerHTML = "<img src='images/double_folder.gif'>  " + Title
	        TxtDiv.style.borderBottom='1px solid #f1f1f1'
	    }
	if (Depth==2){
	        TxtDiv.innerHTML = "&nbsp;&nbsp;&nbsp;<img src='images/folder_open.gif'>  " + Title
	        TxtDiv.style.borderBottom='1px solid #f1f1f1'
	    }
    if (Depth==3){
	        TxtDiv.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='images/page.gif'>  " + Title
	    }	    
	
	
	row.appendChild(ImgDiv);
	row.appendChild(TxtDiv);
	var DottDiv = document.createElement("DIV");
	
	
	tbody.appendChild(row);
	row.onclick=function SendTo(){location.href=Url;}
	


	var GetHeight=0
	GetHeight=TxtDiv.offsetHeight
	
	 
	 TxtDiv.className='SMDepth' + Depth
	
    
}


//CALCULATORS
function commafy(text) {
    if (!window.event) {commafyNoEvent(text);return}
    if ((event.keyCode >= 33 && event.keyCode <= 46) || (event.keyCode == 9) || (event.keyCode == 16))
        return;
    text.value = text.value.replace(/\.$/,",").replace(/^,/,"0,").replace(/^0([^,])/g,"$1").replace(/[^0-9,\,]/g,"").replace(/,/,"#").replace(/,/g,"").replace(/#/,",")
    dec_pos = text.value.search(",");
    if (dec_pos == -1)
        dec_pos = text.value.length;
    if (text.value.length > (dec_pos+3)) { text.value = text.value.substring(0,dec_pos+3) }
    if (dec_pos > 10 ) { text.value = text.value.substring(0,text.value.length-1);dec_pos--}
    for (i = dec_pos-3; i>0; i-=3) {
        text.value = text.value.substr(0, i) + "." + text.value.substr(i);
    }
}
function commafyNoEvent(text) {
    text.value = text.value.replace(/\.$/,",").replace(/^,/,"0,").replace(/^0([^,])/g,"$1").replace(/[^0-9,\,]/g,"").replace(/,/,"#").replace(/,/g,"").replace(/#/,",")
    dec_pos = text.value.search(",")
    if (dec_pos == -1)
        dec_pos = text.value.length;
    if (text.value.length > (dec_pos+3)) { text.value = text.value.substring(0,dec_pos+3) }
    if (dec_pos > 10 ) { text.value = text.value.substring(0,text.value.length-1);dec_pos--}
    for (i = dec_pos-3; i>0; i-=3) {
        text.value = text.value.substr(0, i) + "." + text.value.substr(i);
    }
}

function integerize(text) {
    if (!window.event) {commafyNoEvent(text);return}
    if ((event.keyCode >= 33 && event.keyCode <= 46) || (event.keyCode == 9) || (event.keyCode == 16))
        return;
    text.value = text.value.replace(/[^0-9]/g,"")
}
function integerizeNoEvent(text) {
    text.value = text.value.replace(/[^0-9]/g,"")
}

function account2Iban(account){
     bankcode=account.substring(0,4)
     branchcode=account.substring(4,8)
     main=account.substring(8,20)
     //alert(bankcode + '-' + branchcode + '-' + main);
     //algorithos ipologismoy check digit
     //ta prota bimata ta kanoyme kateythian diladi
     // metaferoyme sto telos to CY00 kai metatrepetai se 123400
     temporesult= bankcode + branchcode + "0000" + main + "123400"
     
     temp= temporesult.substring(0,9)
     temp1 = temp % 97
     temporesult = temp1 + temporesult.substring(9,temporesult.length)
     
     temp= temporesult.substring(0,9)
     temp1 = temp % 97
     temporesult = temp1 + temporesult.substring(9,temporesult.length)
     
     temp= temporesult.substring(0,9)
     temp1 = temp % 97
     temporesult = temp1 + temporesult.substring(9,temporesult.length)
     
     temp= temporesult.substring(0,9)
     temp1 = temp % 97
     
     checkdigit= 98- temp1
     if (checkdigit <10)
      checkdigit = "0" + checkdigit
    
     //return checkdigit;
     return 'CY' + checkdigit + bankcode + branchcode + "0000" + main;
}


function IBANvalidate(obj){
    var ibannum = document.getElementById(txtIbanVerificationCtr).value;
    var account = ibannum.substring(4,12) + ibannum.substring(16,28);
    if (account2Iban(account) == ibannum && ibannum.substring(0,2) == 'CY')
        alert(document.getElementById(lblValidIBANCtr).innerHTML);
    else
        alert(document.getElementById(lblInValidIBANCtr).innerHTML);
        
/*
     var ibannum = document.getElementById(txtIbanVerificationCtr).value;
     if (ibannum.length < 23){
        alert(document.getElementById(lblFillInFormIBANCtr).innerHTML);
        return;
     }
     temp = ibannum.substring(2,4)
     temp1 =ibannum.substring(4,ibannum.length)
     

     temporesult= temp1.toString() + "1234"+ temp.toString()
     
     temp= temporesult.substring(0,9)
     temp1 = temp % 97
     temporesult = temp1 + temporesult.substring(9,temporesult.length)
     
     temp= temporesult.substring(0,9)
     temp1 = temp % 97
     temporesult = temp1 + temporesult.substring(9,temporesult.length)
     
     temp= temporesult.substring(0,9)
     temp1 = temp % 97
     temporesult = temp1 + temporesult.substring(9,temporesult.length)
     
     temp= temporesult.substring(0,9)
     temp1 = temp % 97
     if (temp1=="1" && ibannum.substring(0,2) == 'CY') 
        alert(document.getElementById(lblValidIBANCtr).innerHTML);
     else 
        alert(document.getElementById(lblInValidIBANCtr).innerHTML);
*/
}


function OpenIBANPopup(lang){
   if (document.getElementById(txtbranchCtr).value.length==4 && (!isNaN(document.getElementById(txtbranchCtr).value)) &&
        document.getElementById(txtTypeOfAccCtr).value.length==4 && (!isNaN(document.getElementById(txtTypeOfAccCtr).value)) &&
        document.getElementById(txtAccNoCtr).value.length==12 && (!isNaN(document.getElementById(txtAccNoCtr).value)))
    {
        var o = window.open('IBANConvertorPopup.aspx?lang=' + lang,'IBANPopup','width=420,height=200');
        o.focus();
    }
    else
        alert(document.getElementById(lblFillInFormAccountCtr).innerHTML);
    return false;
}

 function OpenSite(obj){
        var GetObj = document.getElementById(obj)
        if (GetObj.value!=''){
            window.open('http://' + GetObj.value)
        }
    }
    
    
    
function CreateFlash(url,obj){

    var GetObj = document.getElementById(obj)
    
    var StrSwf = '<object  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
    StrSwf = StrSwf + 'codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'
    StrSwf = StrSwf + 'width="970" height="200" align="middle"><param name="allowScriptAccess" value="sameDomain" />'
    StrSwf = StrSwf + '<param name="movie" value="' + url + '" />'
    StrSwf = StrSwf + '<param name="quality" value="high" />'
    StrSwf = StrSwf + '<param name="wmode" value="transparent"/>'
    StrSwf = StrSwf + '<param name="menu" value="false"/>'
    StrSwf = StrSwf + '<embed src="' + url + '" quality="high" width="970" height="200" name="topMovie" menu="false" wmode="transparent"'
    StrSwf = StrSwf + 'align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
    StrSwf = StrSwf + '</object>'
    GetObj.innerHTML=StrSwf
    
}
function CreateHomeFlash(url,obj){

    var GetObj = document.getElementById(obj)
    
    var StrSwf = '<object  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
    StrSwf = StrSwf + 'codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'
    StrSwf = StrSwf + 'width="970" height="235" align="middle"><param name="allowScriptAccess" value="sameDomain" />'
    StrSwf = StrSwf + '<param name="movie" value="' + url + '" />'
    StrSwf = StrSwf + '<param name="quality" value="high" />'
    StrSwf = StrSwf + '<param name="wmode" value="transparent"/>'
    StrSwf = StrSwf + '<param name="menu" value="false"/>'
    StrSwf = StrSwf + '<embed src="' + url + '" quality="high" width="970" height="235" name="topMovie" menu="false" wmode="transparent"'
    StrSwf = StrSwf + 'align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
    StrSwf = StrSwf + '</object>'
    GetObj.innerHTML=StrSwf
    
}

