/* ******************************  This is the quickedit.js file that should be located @ the SCS target server, inside the website's folder ******************************************** */
var QEConfig = new Object();

QEConfig.editEnabled=false;
QEConfig.approveEnabled=false;;
QEConfig.SITE_NAME = "Cranes_WC";
QEConfig.WP_URL = "https://wp.mantiowoc.com/wp"; //This should NOT end with a slash.
QEConfig.BASE_URL = "http://www.manitowoccranes.com/site/RU/"; 

QEConfig.editServerBase= QEConfig.WP_URL + "/siteBuilder/quickedit/";  //Set the root to the quickedit code base

QEConfig.pencilImagePath = QEConfig.editServerBase;
QEConfig.pencilStyle="position:absolute;z-index:1;";
//Scroll Bars Enabled for Manitowoc, Ian Hudson
QEConfig.windowStyle="directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no"; 
QEConfig.formWindowStyle="directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no";    
QEConfig.wysiwygHeight = "400px";
QEConfig.wysiwygWidth = "700px";
QEConfig.textlineHeight = "50px";
QEConfig.textlineWidth = "379px";
QEConfig.keywordHeight = "400px";
QEConfig.keywordWidth = "450px";
QEConfig.approverHeight = "25px";
QEConfig.approverWidth = "250px";


function quickEdit(objectID,target,editor,title,role,image,offset,editorMenuName)
{
    // editorMenuName is for special configurations of the FCKEditor menu.  If set, it will use the 
    // menu with the given name for building the menu
	var width = QEConfig.wysiwygWidth;
	var height = QEConfig.wysiwygHeight;

    // if editor menu name is not set in the link, then use the default
    // ensures backward compatibility of links	
	if (typeof(editorMenuName) == "undefined") {
	  editorMenuName = "";
	}
	
	var offsetStyle = "";
	
	if(offset!="" && offset!="0px" && offset!="0")
	{
		offsetStyle = "left:" + offset;
	}
	
	if(editor=="textline")
	{
		width = QEConfig.textlineWidth;
		height = QEConfig.textlineHeight;
	}
	
	
	try
	{
		if(QEConfig.editEnabled)
		{	
			var editServer = QEConfig.editServerBase;

			if(editor=="wysiwyg")
			{
				editServer += "QuickEditWysiwyg.html";
			}
			else if(editor=="textline")
			{
				editServer += "QuickEditTextline.html";
			}
			
			var dlg = "<a href=\"#\" title=\"" + title + "\" style=\"" + QEConfig.pencilStyle + offsetStyle + "\" onclick=\"javascript:quickEditOpenDialog('" + editServer + "?target=" + target + "&role=" + role + "&editor=" + editor + "&title=" + title + "&object=" + objectID + "&width=" + width + "&height=" + height + "&emn=" + editorMenuName + "&url=" + window.top.location + "&siteName=" + QEConfig.SITE_NAME + "&siteURL=" + QEConfig.BASE_URL + "','" + width + "','" + height + "',false);\"><img src=\"" + QEConfig.pencilImagePath + image + "\" border=\"0\"/></a>";
			document.write(dlg);
			
		}
	}
	catch (e)
	{
	}
}

function quickApprove(objectID,targets,title,role,image,offset)
{
	var width = QEConfig.approverWidth;
	var height = QEConfig.approverHeight;
	
	var offsetStyle = "";
	var editorMenuName = "";
	
	if(offset!="" && offset!="0px" && offset!="0")
	{
		offsetStyle = "left:" + offset;
	}
	
	
	try
	{
		if(QEConfig.approveEnabled)
		{	
			var editServer = QEConfig.editServerBase;

			editServer += "QuickApprover.html";
			document.write("<a href=\"#\" title=\"" + title + "\" style=\"" + QEConfig.pencilStyle + offsetStyle + "\" onclick=\"javascript:quickEditOpenDialog('" + editServer + "?target=" + targets + "&role=" + role + "&editor=approver" + "&title=" + title + "&object=" + objectID + "&width=" + width + "&height=" + height + "&emn=" + editorMenuName + "&url=" + window.top.location + "&siteName=" + QEConfig.SITE_NAME + "&siteURL=" + QEConfig.BASE_URL + "','" + width + "','" + height + "',false);\"><img src=\"" + QEConfig.pencilImagePath + image + "\" border=\"0\"/></a>");
			
		}
	}
	catch (e)
	{
	}
}


function quickEditDropdown(objectID,target,type,options,title,role,image,offset)
{
	var editor = "dropdown";
	width = QEConfig.textlineWidth;
	height = QEConfig.textlineHeight;

	var offsetStyle = "";
	var editorMenuName = "";
	
	if(offset!="" && offset!="0px" && offset!="0")
	{
		offsetStyle = "left:" + offset;
	}
	
	try
	{
		if(QEConfig.editEnabled)
		{	
			var editServer = QEConfig.editServerBase + "QuickEditDropdown.html";


			
			var str = "<a href=\"#\"  title=\"" + title + "\" style=\"" + QEConfig.pencilStyle + offsetStyle + "\" onclick=\"javascript:quickEditOpenDialog('" + editServer + "?target=" + target + "&role=" + role + "&editor=" + editor + "&type=" + type + "&options=" + options + "&title=" + title + "&object=" + objectID + "&width=" + width + "&height=" + height + "&emn=" + editorMenuName + "&url=" + window.top.location + "&siteName=" + QEConfig.SITE_NAME + "&siteURL=" + QEConfig.BASE_URL + "','" + width + "','" + height + "',false);\"><img src=\"" + QEConfig.pencilImagePath + image + "\" border=\"0\"/></a>";
			document.write(str);
		}
	}
	catch (e)
	{
	}
}

function quickEditForm(objectID,target,repeat,configuration,subTargets,formWidth,formHeight,title,role,image,offset)
{
	var editor = "form";
	width = formWidth;
	height = formHeight;
	
	var offsetStyle = "";
	var editorMenuName = "";
	
	if(offset!="" && offset!="0px" && offset!="0")
	{
		offsetStyle = "left:" + offset;
	}
	
	try
	{
		if(QEConfig.editEnabled)
		{	
		    var editServer = QEConfig.editServerBase + configuration + ".html";
			document.write("<a href=\"#\"  title=\"" + title + "\" style=\"" + QEConfig.pencilStyle + offsetStyle + "\" onclick=\"javascript:quickEditOpenDialog('" + editServer + "?target=" + target + "&role=" + role + "&editor=" + editor + "&repeat=" + repeat + "&title=" + title + "&object=" + objectID + "&width=" + width + "&height=" + height + "&emn=" + editorMenuName + "&url=" + window.top.location + "&siteName=" + QEConfig.SITE_NAME + "&siteURL=" + QEConfig.BASE_URL + "','" + width + "','" + height + "',true);\"><img src=\"" + QEConfig.pencilImagePath + image + "\" border=\"0\"/></a>");
		}
	}
	catch (e)
	{
	}
}

function quickEditCategory(objectID,target,title,role,image,offset)
{
	var editor = "category";
	width = QEConfig.keywordWidth;
	height = QEConfig.keywordHeight;
	
	var offsetStyle = "";
	var editorMenuName = "";
	
	if(offset!="" && offset!="0px" && offset!="0")
	{
		offsetStyle = "left:" + offset;
	}
	
	try
	{
		if(QEConfig.editEnabled)
		{	
			var editServer = QEConfig.editServerBase + "QuickEditCategory.html";
			document.write("<a href=\"#\"  title=\"" + title + "\" style=\"" + QEConfig.pencilStyle + offsetStyle + "\" onclick=\"javascript:quickEditOpenDialog('" + editServer + "?target=" + target + "&role=" + role + "&editor=" + editor + "&title=" + title + "&object=" + objectID + "&width=" + width + "&height=" + height + "&emn=" + editorMenuName + "&url=" + window.top.location + "&siteName=" + QEConfig.SITE_NAME + "&siteURL=" + QEConfig.BASE_URL + "','" + width + "','" + height + "',false);\"><img src=\"" + QEConfig.pencilImagePath + image + "\" border=\"0\"/></a>");				
		}
	}
	catch (e)
	{
	}
}

function quickEditRule(objectID,target,title,role,image,offset)
{
	var editor = "category";
	width = QEConfig.keywordWidth;
	height = QEConfig.keywordHeight;
	
	var offsetStyle = "";
	var editorMenuName = "";
	
	if(offset!="" && offset!="0px" && offset!="0")
	{
		offsetStyle = "left:" + offset;
	}
	
	try
	{
		if(QEConfig.editEnabled)
		{	
			var editServer = QEConfig.editServerBase + "QuickEditRule.html";
			document.write("<a href=\"#\"  title=\"" + title + "\" style=\"" + QEConfig.pencilStyle + offsetStyle + "\" onclick=\"javascript:quickEditOpenDialog('" + editServer + "?target=" + target + "&role=" + role + "&editor=" + editor + "&title=" + title + "&object=" + objectID + "&width=" + width + "&height=" + height + "&emn=" + editorMenuName + "&url=" + window.top.location + "&siteName=" + QEConfig.SITE_NAME + "&siteURL=" + QEConfig.BASE_URL + "','" + width + "','" + height + "',false);\"><img src=\"" + QEConfig.pencilImagePath + image + "\" border=\"0\"/></a>");				
		}
	}
	catch (e)
	{
	}
}

var qeDialog = null;

function quickEditOpenDialog(url,width,height,isForm)
{



		if(isForm)
		{
			qeDialog = window.open(url,'SBEditor','height=' + height + ',width=' + width + ',' + QEConfig.formWindowStyle,false);
		}
		else
		{
			qeDialog = window.open(url,'SBEditor','height=' + height + ',width=' + width + ',' + QEConfig.windowStyle,false);		
		}
}



function quickEditCheckFocus()
{


	// It is strange, but we have to check the FCKDialog existence to avoid a
	// random error: "FCKDialog is not defined".
	if ( typeof( qeDialog) != "object" )
		return false ;

	if ( qeDialog && !qeDialog.window.closed )
		qeDialog.window.focus() ;
	else
	{
		// Try/Catch must be used to avoit an error when using a frameset
		// on a different domain:
		// "Permission denied to get property Window.releaseEvents".
		try
		{
			window.top.removeEventListener( 'onmousedown', quickEditCheckFocus, true ) ;
			window.top.removeEventListener( 'mouseup', quickEditCheckFocus, true ) ;
			window.top.removeEventListener( 'click', quickEditCheckFocus, true ) ;
			window.top.removeEventListener( 'onfocus', quickEditCheckFocus, true ) ;
		}
		catch (e)
		{
			
		}
	}
	return false ;
}

