﻿function getContentEditor(editorId,hiddenId,btnId)
{
    var oEditor = FCKeditorAPI.GetInstance(editorId) ;
    document.getElementById(hiddenId).value = getHTMLEncode(oEditor.GetHTML());
    document.getElementById(btnId).click();
}

function getHTMLEncode(strHTML) {
    var html = "" + strHTML;
    var arrE = [["&","&amp;"], ["\"","&quot;"] ,["<","&lt;"], [">","&gt;"]];
    var arrO = [];

    for (var i=0, j=html.length, k=arrE.length; i<j; ++i) {
        var c = arrO[i] = html.charAt(i);
        for (var l=0; l<k; ++l) {
            if (c == arrE[l][0]) {
                arrO[i] = arrE[l][1];
                break;
            }
        }
    }
    return arrO.join("");
}

function showModal(modalId, text){
    popper = $find(modalId);
    if (popper){
        
        popper._foregroundElement.all[1].className = "innerMSG"
        
        popper._DynamicContextKey = text;
        popper.show();
    }
}

function hideModal(modalId){
    popper = $find(modalId);
    if (popper){
        popper.hide();
    }
}

function hidePopup(modalId){
    popper = $find(modalId);
    if (popper){
        popper.hidePopup();
    }
}

function bepaalAdres(value1, value2, knop1) {
    if (document.getElementById(value1).value != '' && document.getElementById(value2).value != '') {
        document.getElementById(knop1).click();
    }
}

var win

function windowfocus()
{
    win.focus();
}

function fnPopup(url, naam, wbreedte, whoogte)
{
    wbreedte += 32;
    whoogte  += 96;
    wlinks = (screen.width  - wbreedte) / 2;
    wtop   = (screen.height - whoogte)  / 2;
    win = window.open(url,naam,'width=' + wbreedte + ', height=' + whoogte + ', ' + 
    'left=' + wlinks + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
        'status=yes, toolbar=no, scrollbars=yes, resizable=yes')
        
    setTimeout ( "windowfocus();", 20 ); 
    
    
}

// Gets a element by its Id. Used for shorter coding.
function GetE( elementId )
{
	return document.getElementById( elementId )  ;
}

function SetUrl(elementId, url, eventId)
{
	GetE(elementId).value = url ;
	if (eventId != null)
	{
	    GetE(eventId).click();
	}	
	//window.opener.SetUrl('ctl00_cphContent_txtNewUrl','~/reorderlist.aspx?id=2');self.close();return false;
}

function OpenFileBrowser( url, width, height )
{
	// oEditor must be defined.
    //var oEditor = window.parent.InnerDialogLoaded() ;

	var iLeft = ( screen.width  - width ) / 2 ;
	var iTop  = ( screen.width - height ) / 2 ;

	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ;
	sOptions += ",width=" + width ;
	sOptions += ",height=" + height ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	window.open( url, 'FCKBrowseWindow', sOptions ) ;
}

//function calenderRightClick(buttonEvent, dayElem, txtElem) {

//  if (buttonEvent == 2)
//  {
//    _txtElem = GetE(txtElem);
//    alert(_txtElem);
//    if (_txtElem)
//    {
//        alert(dayElem.innerText);
//        _txtElem.value = dayElem.innerText;
//    }
//  }
////	var rightclick;
////	if (!e) var e = window.event;
////	if (e.which) rightclick = (e.which == 3);
////	else if (e.button) rightclick = (e.button == 2);
////	alert('Rightclick: ' + rightclick); // true or false
//}



