var gl_MultiAttachUrl;
var gl_MultiAttachText;
var gl_btnInvisibleAttachment;
var gl_selectedUrl;

// Define new WBC_setThinEditIEImage function which will be used instead of the CMS predefined one.
function WBC_setThinEditIEAttachment(strPhName, strURL, strDispText) 
{
	
	// "MultiAttachUrl", "MultiAttachText" are Global variables that represent
	// the ClientID of the TextBoxes ( We "Plant" the in the code behind..)
	// This is done because when the Controls reside inside a ".ascx" control
	// their ID's are not simple "txtMultiAttachUrl" but the name of the Conrol
	// prefixes them : e.g -> Ctrl1_txtMultiAttachUrl.
	//document.all[MultiAttachUrl].value = strURL;
	document.all[gl_MultiAttachUrl].value = strURL;
	//document.all[MultiAttachText].value = strDispText;
	document.all[gl_MultiAttachText].value = strDispText;		


	// We fire this event so that we can get to the Event Handler in the Code behind.
	document.all[gl_btnInvisibleAttachment].fireEvent('onclick');
}

function OpenLinkWindow(sUrl,sWinType,sWidth,sHeight)
{	
	//alert('OpenLinkWindow');
	//alert(sWinType + "--" + sUrl);
	if (sWinType=="_self")
	{
	//alert('in');
		window.location.href=sUrl;
	}
	else
	{
		var props='left=200,top=100,height=450,scrollbars=no,width=' + sWidth + ',height='+ sHeight;
		var newWin = window.open('',"MyNewWin",props);
		if (window.newWin)
			newWin.focus();
	}
}


function OpenLinkPopup(sGlobalPath)
{
	//alert('OpenLinkPopup');
	var newWin = window.open(sGlobalPath+"/Popups/HyperLinkPopUp.aspx","","left=200,top=100,height=460,scrollbars=yes,width=450,resizable");
	if (window.newWin)
		newWin.focus();
}


function SetSelectedUrl(strURL)
{
	
	if (typeof(curUrlTextBox)!="undefined")
		{
		
			oControl=eval('document.all.'+curUrlTextBox);
			oControl.value=strURL;
		}
}


// Open a modal dialog to choose a Link.		
function OpenLink(strURL)
{
	//alert('OpenLink');	
	var returnValue = window.showModalDialog(strURL,"","dialogWidth:620px;dialogHeight:360px;status:no");
	
	if(returnValue != "Cancel" && typeof(returnValue) != "undefined")
	{
		var returnValue_array = returnValue.split(";");
		//return;
		// "returnValue_array[7]" contains the name of the clientID of "txtMultiLinkUrl".
		document.all[returnValue_array[7]].value = returnValue;
		
		// The event is fired so a server event will be fired after that
		// to anable to take the variables returned to the TextBox and
		// add them to the DataGrid in the CODE BEHIND.
		// "returnValue_array[8]" contains the name of the clientID of "btnGetLink".
		document.all[returnValue_array[8]].fireEvent('onclick');
	}
}