function _flowEdit(bcID, beID, hook) {
    //build  different url depending if it's a hook or a block
	//==bcID is hookname and beID is hookitemid
	if(hook == 1)
	{
		url = 'hookedit.php?hook='+bcID+'&hookitemid='+beID;
	}
	else
	{
		url = 'index.php?s=edit&bc='+bcID+'&be='+beID;
	}

	newwindow=window.open(
        '/edit/'+url,
        '_adminSide',
        'width=900,status=yes,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function _flowAdd(bID,hook) {
    //build  different url depending if it's a hook or a block
	//==beID is hookname and bcID is hookitemid

	if(hook == 1)
	{
		url = 'hookedit.php?hook='+bID+'&hookitemid=0&new=1';
	}
	else
	{
		url = 'index.php?s=edit&b='+bID+'&new=1';
	}

    newwindow=window.open(
        '/edit/'+url,
        '_adminSide',
        'width=900,status=yes,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function _flowOrder(bID, extra) {
    if (extra != null) {
        extra = "&" + extra;
    } else {
        extra = '';
    }
    
    newwindow=window.open(
        '/edit/index.php?s=order&b='+bID+extra,
        '_adminSide',
        'width=900,status=yes,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function updatePreview(previewLink) {
    window.open(previewLink, '_previewWindow', 'width=1020,height=700,toolbar=no,scrollbars=yes');
}

function switchBlock(bcIDbeID, previewLink) {
    if (bcIDbeID == '') {
        return;
    }
//     if (confirm('Are you sure?')) {
        var parts = bcIDbeID.split('-');
        if ('hook' == parts[0])
        {
        	document.location = '/edit/hookedit.php?hook='+parts[1]+'&hookitemid='+parts[2]+'&previewLink='+previewLink;
        }
        else
		{
			document.location = '/edit/index.php?s=edit&bc='+parts[0]+'&be='+parts[1]+'&previewLink=#beID-'+parts[1];
		}
}

function switchContent(bcID, beID, previewLink) {

    if (bcID == '') {
        return;
    }

	if(isNaN(beID)) //hook
	{
		var parts = beID.split('-');
		if (1 < parts.length)
		{
			if ('hook' == parts[0])
			{
				hookname = parts[1];
				hookID = bcID;//alert('going to ' +'/edit/hookedit.php?hook='+hookname+'&hookitemid='+hookID);return false;
				var newlocation = '/edit/hookedit.php?hook='+hookname+'&hookitemid='+hookID;

				if(isNaN(bcID)) //it's a block related to a hook'
				{
					var parts = bcID.split('-');
					hookID = bcID;
					var newlocation = '/edit/index.php?s=edit&bc='+parts[1]+'&be='+parts[2]+'&previewLink=#beID-'+parts[2];
				} //means it's a block attached to the hook'
								
				document.location = newlocation;
				return false;
			}
			else
			{
				alert('malformed edit url');
			}
		}
    }
    else //block
    {
//     if (confirm('Are you sure?')) {
        document.location = '/edit/index.php?s=edit&bc='+bcID+'&be='+beID+'&previewLink='+previewLink;
//     }
	}
}

function _thisIsAPreview() {
    alert("This is a preview window");
    return false;
}