﻿function ConvertToUpper(theid)
{ var thecontrol = document.getElementById(theid); thecontrol.value = thecontrol.value.toUpperCase(); }
var ns6 = document.getElementById && !document.all
function countlimit(maxlength, e, placeholder) {
    var theform = eval(placeholder)
    var lengthleft = maxlength - theform.value.length
    var placeholderobj = document.all ? document.all[placeholder] : document.getElementById(placeholder)
    if (window.event || e.target && e.target == eval(placeholder)) { placeholderobj.innerHTML = lengthleft }
    if (lengthleft < 0)
    { alert('Έχετε υπερβεί το μέγιστο επιτρεπτό όριο χαρακτήρων στις Παρατηρήσεις κατά ' + ((-1) * lengthleft) + ' χαρακτήρες.'); return false; } 
}
function displaylimit(thename, theid, thelimit) {
    var theform = theid != "" ? document.getElementById(theid) : thename; var limit_text = 'Απομένουν<b> <span id="' + theform.toString() + '">' + (thelimit - theform.value.length) + '</span></b> χαρακτήρες.'
    if (document.all || ns6)
        document.write(limit_text)
    if (document.all)
        eval(theform).onkeyup = function() { countlimit(thelimit, event, theform) }
    else if (ns6)
        document.body.addEventListener('keyup', function(event) { countlimit(thelimit, event, theform) }, true);
}
function ShowHelp(strUrl)
{ window.open(strUrl, "Help", "location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes,top=40,left=40,width=720,height=480"); }


function BrowserCheck() {
    var b = navigator.appName;
    if (b == "Netscape") this.b = "NS";
    else if (b == "Microsoft Internet Explorer") this.b = "IE";
    else this.b = b;
    this.v = parseInt(navigator.appVersion);
    this.NS = (this.b == "NS" && this.v >= 4);
    this.NS4 = (this.b == "NS" && this.v == 4);
    this.NS5 = (this.b == "NS" && this.v == 5);
    this.IE = (this.b == "IE" && this.v >= 4);
    this.IE4 = (navigator.userAgent.indexOf('MSIE 4') > 0);
    this.IE5 = (navigator.userAgent.indexOf('MSIE 5') > 0);
    if (this.IE5 || this.NS5) this.VER5 = true;
    if (this.IE4 || this.NS4) this.VER4 = true;
    this.OLD = (!this.VER5 && !this.VER4) ? true : false;
    this.min = (this.NS || this.IE);
}

function Cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = location.y + 'px';
    top.style.left = location.x + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}


function clickButton(e, buttonid) {
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);
    if (bt) {
        if (evt.keyCode == 13) {
            bt.click();
            return false;
        }
    }
}

var statusmsg = "Copyright B-logica 2009";
function hidestatus() {
    window.status = statusmsg;
    return true;
}
if (document.layers)
    document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

document.onmouseover = hidestatus;
document.onmouseout = hidestatus;



//Generating Pop-up Print Preview page
function getPrint(print_area, title) {
    //Creating new page
    var pp = window.open();
    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<html><head><title>Print Preview</title>')
    //pp.document.writeln('<LINK href=../App_Themes/DefaultTemplate/default.css type="text/css" rel="stylesheet">')
    //pp.document.writeln('<link href="PrintStyle.css" ' +
      //                  'type="text/css" rel="stylesheet" >')
    //pp.document.writeln('<base target="_self"></HEAD>')
    pp.document.writeln('<style type="text/css">')
    pp.document.writeln('body {margin-left: 10px }')
    pp.document.writeln('.textNormal10 {font-family: Verdana, Helvetica, Geneva, Arial, sans-serif; font-size: 10px; font-weight: normal; font-style: normal; color: #666666; text-transform: none;}')
    pp.document.writeln('.textNormalBold11 {font-family: Verdana, Helvetica, Geneva, Arial, sans-serif; font-size: 11px; font-weight: bold; font-style: normal; color: #666666; text-transform: none;}')
    pp.document.writeln('.listNormal {list-style-image:url(images/green_list_dot_round.gif); margin: 8px 0px 4px 20px;}')
    pp.document.writeln('.listNormal li {padding: 0px 4px 2px 0px;}')
    pp.document.writeln('.hrGrayDashed {border: Dashed 1px #e5e6e8;}')
    pp.document.writeln('</style>')

    pp.document.writeln('</head>')
        
    //Adding Body Tag
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0"');
    pp.document.writeln(' leftMargin="0" topMargin="0" rightMargin="0">');
    //Adding form Tag
    pp.document.writeln('<form method="post">');

    //Creating two buttons Print and Close within a HTML table
    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right>');
    pp.document.writeln('<INPUT ID="PRINT" type="button" value="Print" ');
    pp.document.writeln('onclick="javascript:location.reload(true);window.print();">');
    pp.document.writeln('<INPUT ID="CLOSE" type="button" ' +
                        'value="Close" onclick="window.close();">');
    pp.document.writeln('</TD></TR><TR><TD></TD></TR></TABLE>');

    pp.document.writeln('<span style="font-size: 22px; font-weight: bold; color: black; margin-left: 10px;"><u>' + title + '</u></span><br /><br />');
    //Writing print area of the calling page
    pp.document.writeln(document.getElementById(print_area).innerHTML);
    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></html>');
}

//AddEditCustomer Functions


function CheckProfessionSelected(panelID, comboID) {
    var combo = document.getElementById(comboID);
    var panel = document.getElementById(panelID);
    if (combo.text == 'Δικηγόρος')
        panel.visible = true;
    else
        panel.visible = false;
}

function SetDropDownValue(controlName, value) {
    var dropdown = document.getElementById(controlName);
    dropdown.value = value;
}

function SetMaleFemaleValue(value)
{
	
	var radMale = document.getElementById('radMale');
	var radFemale = document.getElementById('radFemale');
	
	if(value == 0)
	{
		radMale.checked = true;
	}else
	{
		radFemale.checked = true;
	}

}

function CopyValue(sourceControlName,targetControlName)
{
	var sourceControl = document.getElementById(sourceControlName);
	var targetControl = document.getElementById(targetControlName);
	targetControl.value = sourceControl.value;
}


function SetBillInfoAsAddress(isChecked) {


        var tbaddress = document.getElementById('tbaddress');
        var tbBillingStreet = document.getElementById('tbBillingStreet');

        var tbaddressNo = document.getElementById('tbaddressNo');
        var tbBillingStreetNo = document.getElementById('tbBillingStreetNo');

        var tbPostalCode = document.getElementById('tbPostalCode');
        var tbBillingPostalCode = document.getElementById('tbBillingPostalCode');

        var tbArea = document.getElementById('tbArea');
        var tbBillingArea = document.getElementById('tbBillingArea');
        
        var tbPhone = document.getElementById('tbPhone');
        var tbBillingPhone = document.getElementById('tbBillingPhone');

		var tbName = document.getElementById('tbName');
		var tbbillingFirstName = document.getElementById('tbbillingFirstName');

		var tbLastname = document.getElementById('tbLastname');
		var tbbillingLastName = document.getElementById('tbbillingLastName');

		var tbCompanyName = document.getElementById('tbCompanyName');
		var tbbillingCompanyName = document.getElementById('tbbillingCompanyName');

		var classhidden ;
		if (isChecked)
			classhidden	='hiddenRow';
		else
		classhidden='';
		document.getElementById('divBill1').className = classhidden;
		document.getElementById('divBill2').className = classhidden;
		document.getElementById('divBill3').className = classhidden;

    if (isChecked)
    {
        
        tbBillingStreet.value = tbaddress.value;
        tbBillingStreetNo.value = tbaddressNo.value;
        tbBillingPostalCode.value = tbPostalCode.value;
        tbBillingArea.value = tbArea.value;
		tbBillingPhone.value = tbPhone.value;
		tbbillingFirstName.value = tbName.value;
		tbbillingLastName.value = tbLastname.value;
		tbbillingCompanyName.value = tbCompanyName.value;
        tbBillingStreetNo.value = tbaddressNo.value;
        tbBillingPostalCode.value = tbPostalCode.value;
        tbBillingArea.value = tbArea.value;
		tbBillingPhone.value = tbPhone.value;
		tbbillingFirstName.value = tbName.value;
		tbbillingLastName.value = tbLastname.value;
		tbbillingCompanyName.value = tbCompanyName.value;


       
        //HiddenField is actually the value
        if (ucSCCities_ccmbData.selValue != null) {
            ucSCBillingCities_ccmbData.setValueAndFireSelect(ucSCCities_ccmbData.selValue);
            ucSCBillingCities_ccmbData.selValue = ucSCCities_ccmbData.selValue;
        
        } else {
            ucSCBillingCities_ccmbData.setValueAndFireSelect(ucSCCities_ccmbData.lastSelectionText);
            ucSCBillingCities_ccmbData.value = ucSCCities_ccmbData.value;
        }
        
        ucSCBillingCities_ccmbData.hiddenField.value = ucSCCities_ccmbData.hiddenField.value;


        if (ucSCStates_ccmbData.selValue != null) {
            ucSCBillingStates_ccmbData.setValueAndFireSelect(ucSCStates_ccmbData.selValue);
            ucSCBillingStates_ccmbData.selValue = ucSCStates_ccmbData.selValue;
        } else 
        {
            ucSCBillingStates_ccmbData.setValueAndFireSelect(ucSCStates_ccmbData.lastSelectionText);
            ucSCBillingStates_ccmbData.value = ucSCStates_ccmbData.value;
        }
        
        
        ucSCBillingStates_ccmbData.hiddenField.value = ucSCStates_ccmbData.hiddenField.value;        
        
    }else
	{

        
        tbBillingStreet.value = "";
        tbBillingStreetNo.value = "";
        tbBillingPostalCode.value = "";
        tbBillingArea.value = "";
		tbBillingPhone.value = "";
		tbbillingFirstName.value = "";
		tbbillingLastName.value = "";
		tbbillingCompanyName.value = "";
        tbBillingStreetNo.value = "";
        tbBillingPostalCode.value = "";
        tbBillingArea.value = "";
		tbBillingPhone.value = "";
		tbbillingFirstName.value = "";
		tbbillingLastName.value = "";
		tbbillingCompanyName.value = "";


       
        //HiddenField is actually the value
        ucSCBillingCities_ccmbData.setValueAndFireSelect("");
        ucSCBillingCities_ccmbData.selValue = "";
        ucSCBillingCities_ccmbData.hiddenField.value = "";
		ucSCBillingStates_ccmbData.setValueAndFireSelect("");
        ucSCBillingStates_ccmbData.selValue = "";
		ucSCBillingStates_ccmbData.hiddenField.value = "";
	
	}
}


function toggleDisabled(el,state) {

		try {
			el.disabled = state;
		}
		catch(E){

		}

		if (el.childNodes && el.childNodes.length > 0) {
			for (var x = 0; x < el.childNodes.length; x++) {
				toggleDisabled(el.childNodes[x],state);
			}
		}
}



//-----------------Admin/AddEditCustomerContracts.aspx Functions



//Manage LookUps



//-----------------AddEdit Customer Communication


        function SetCommunicationAppointmentText() {

            var tbDetails=document.getElementById('tbDetails');
            var tbCommunicatedWith=document.getElementById('tbCommunicatedWith');
            var tbAppointmentText=document.getElementById('tbAppointmentText');
            var cdteAppointmentStart=document.getElementById('cdteAppointmentStart');
            var ctimAppointmentStart=document.getElementById('ctimAppointmentStart');
            var ctimAppointmentStart_Value=document.getElementById('ctimAppointmentStart_Value');
            var cdteAppointmentEnd=document.getElementById('cdteAppointmentEnd');
            var ctimAppointmentEnd=document.getElementById('ctimAppointmentEnd');
            var ctimAppointmentEnd_Value=document.getElementById('ctimAppointmentEnd_Value');
            var hidUsername=document.getElementById('hidUsername');

            var tbAppointmentSubject=document.getElementById('tbAppointmentSubject');
            var hidDefaultAppointmentSubject=document.getElementById('hidDefaultAppointmentSubject');
            var ucSCCommunicationTopic_ccmbData=document.getElementById('ucSCCommunicationTopic_ccmbData');
            tbAppointmentSubject.value=hidDefaultAppointmentSubject.value+' '+ucSCCommunicationTopic_ccmbData.value;

            var tbAppointmentLocation=document.getElementById('tbAppointmentLocation');
            var hidDefaultAppointmentLocation=document.getElementById('hidDefaultAppointmentLocation');
            tbAppointmentLocation.value=hidDefaultAppointmentLocation.value;

            var bodyText='------------------------------\n';
            bodyText=bodyText+tbDetails.value+'\n';
            bodyText=bodyText+'------------------------------\n';
            bodyText=bodyText+'Καταχωρήθηκε από: '+hidUsername.value+'\n';
            bodyText=bodyText+'Επικοινώνησε με : '+tbCommunicatedWith.value+'\n';

            var currentTime=new Date()
            var month=currentTime.getMonth()+1
            if(month<10) {
                month="0"+month;
            }

            var day=currentTime.getDate()
            if(day<10) {
                day="0"+day;
            }

            var year=currentTime.getFullYear()
            var hours=currentTime.getHours()
            var minutes=currentTime.getMinutes()
            if(minutes<30) {
                //Convert to half hours
                minutes="30";
            } else {
                minutes="00";
                hours=hours+1;
            }

            if(hours<10) {
                hours="0"+hours;
            }

            bodyText=bodyText+'Ώρα καταχώρησης: '+day+'/'+month+'/'+year+' '+hours+':'+minutes;
            tbAppointmentText.value=bodyText;

            cdteAppointmentStart.value=day+'/'+month+'/'+year;
            ctimAppointmentStart.value=hours+":"+minutes;
            ctimAppointmentStart_Value.value=hours+":"+minutes;

            cdteAppointmentEnd.value=day+'/'+month+'/'+year;
            ctimAppointmentEnd.value=(hours+1)+":"+minutes;
            ctimAppointmentEnd_Value.value=(hours+1)+":"+minutes;

            tbAppointmentSubject.value+=" ";

        }

        function SetCommunicationTaskText() {

            var tbDetails=document.getElementById('tbDetails');
            var tbCommunicatedWith=document.getElementById('tbCommunicatedWith');
            var tbTaskText=document.getElementById('tbTaskText');

            var cdteTaskStartDate=document.getElementById('cdteTaskStartDate');
            var ctimTaskStartDate=document.getElementById('ctimTaskStartDate');
            var ctimTaskStartDate_Value=document.getElementById('ctimTaskStartDate_Value');

            var cdteTaskDueDate=document.getElementById('cdteTaskDueDate');
            var ctimTaskDueDate=document.getElementById('ctimTaskDueDate');
            var ctimTaskDueDate_Value=document.getElementById('ctimTaskDueDate_Value');

            var cdteTaskReminderDate=document.getElementById('cdteTaskReminderDate');
            var ctimTaskReminderDate=document.getElementById('ctimTaskReminderDate');
            var ctimTaskReminderDate_Value=document.getElementById('ctimTaskReminderDate_Value');

            var hidUsername=document.getElementById('hidUsername');

            var tbTaskSubject=document.getElementById('tbTaskSubject');
            var hidDefaultAppointmentSubject=document.getElementById('hidDefaultAppointmentSubject');
            var ucSCCommunicationTopic_ccmbData=document.getElementById('ucSCCommunicationTopic_ccmbData');
            tbATasSkubject.value=hidDefaultAppointmentSubject.value+' '+ucSCCommunicationTopic_ccmbData.value;





            var bodyText='------------------------------\n';
            bodyText=bodyText+tbDetails.value+'\n';
            bodyText=bodyText+'------------------------------\n';
            bodyText=bodyText+'Καταχωρήθηκε από: '+hidUsername.value+'\n';
            bodyText=bodyText+'Επικοινώνησε με : '+tbCommunicatedWith.value+'\n';

            var currentTime=new Date()
            var month=currentTime.getMonth()+1
            if(month<10) {
                month="0"+month;
            }

            var day=currentTime.getDate()
            if(day<10) {
                day="0"+day;
            }

            var year=currentTime.getFullYear()
            var hours=currentTime.getHours()
            var minutes=currentTime.getMinutes()
            if(minutes<30) {
                //Convert to half hours
                minutes="30";
            } else {
                minutes="00";
                hours=hours+1;
            }

            if(hours<10) {
                hours="0"+hours;
            }


            bodyText=bodyText+'Ώρα καταχώρησης: '+day+'/'+month+'/'+year+' '+hours+':'+minutes;
            tbTaskText.value=bodyText;

            cdteTaskStartDate.value=day+'/'+month+'/'+year;
            ctimTaskStartDate.value=hours+":"+minutes;
            ctimTaskStartDate_Value.value=hours+":"+minutes;

            cdteTaskDueDate.value=day+'/'+month+'/'+year;
            ctimTaskDueDate.value=(hours+1)+":"+minutes;
            ctimTaskDueDate_Value.value=(hours+1)+":"+minutes;

            cdteTaskReminderDate.value=day+'/'+month+'/'+year;
            ctimTaskReminderDate.value=(hours+1)+":"+minutes;
            ctimTaskReminderDate_Value.value=(hours+1)+":"+minutes;
        }


        function SetCommunicationFollowUpText() {

            var tbDetails=document.getElementById('tbDetails');
            var tbCommunicatedWith=document.getElementById('tbCommunicatedWith');
            var tbFollowUpText=document.getElementById('tbFollowUpText');

            var cdteFollowUpStartDate=document.getElementById('cdteFollowUpStartDate');
            var ctimFollowUpStartDate=document.getElementById('ctimFollowUpStartDate');
            var ctimFollowUpStartDate_Value=document.getElementById('ctimFollowUpStartDate_Value');

            var cdteFollowUpDueDate=document.getElementById('cdteFollowUpDueDate');
            var ctimFollowUpDueDate=document.getElementById('ctimFollowUpDueDate');
            var ctimFollowUpDueDate_Value=document.getElementById('ctimFollowUpDueDate_Value');

            var cdteFollowUpReminderDate=document.getElementById('cdteFollowUpReminderDate');
            var ctimFollowUpReminderDate=document.getElementById('ctimFollowUpReminderDate');
            var ctimFollowUpReminderDate_Value=document.getElementById('ctimFollowUpReminderDate_Value');

            var hidUsername=document.getElementById('hidUsername');


            var bodyText='------------------------------\n';
            bodyText=bodyText+tbDetails.value+'\n';
            bodyText=bodyText+'------------------------------\n';
            bodyText=bodyText+'Καταχωρήθηκε από: '+hidUsername.value+'\n';
            bodyText=bodyText+'Επικοινώνησε με : '+tbCommunicatedWith.value+'\n';

            var currentTime=new Date()
            var month=currentTime.getMonth()+1
            if(month<10) {
                month="0"+month;
            }

            var day=currentTime.getDate()
            if(day<10) {
                day="0"+day;
            }

            var year=currentTime.getFullYear()
            var hours=currentTime.getHours()
            var minutes=currentTime.getMinutes()
            if(minutes<30) {
                //Convert to half hours
                minutes="30";
            } else {
                minutes="00";
                hours=hours+1;
            }

            if(hours<10) {
                hours="0"+hours;
            }


            bodyText=bodyText+'Ώρα καταχώρησης: '+day+'/'+month+'/'+year+' '+hours+':'+minutes;
            tbFollowUpText.value=bodyText;

            cdteFollowUpStartDate.value=day+'/'+month+'/'+year;
            ctimFollowUpStartDate.value=hours+":"+minutes;
            ctimFollowUpStartDate_Value.value=hours+":"+minutes;

            cdteFollowUpDueDate.value=day+'/'+month+'/'+year;
            ctimFollowUpDueDate.value=(hours+1)+":"+minutes;
            ctimFollowUpDueDate_Value.value=(hours+1)+":"+minutes;

            cdteFollowUpReminderDate.value=day+'/'+month+'/'+year;
            ctimFollowUpReminderDate.value=(hours+1)+":"+minutes;
            ctimFollowUpReminderDate_Value.value=(hours+1)+":"+minutes;
        }
