///<cartouche>
///	<copyright>(c) 2004 - PSA Peugeot Citroen </copyright>
///	<project>Web Services et Sites Com - Lot 0</project>
///	<class>CWWCMSToMediatheque.js
///		<summary>Custom placeholder héritant du placeholder HtmlPlaceHolderControl
///		Permet d'accèder à l'application médiathèque
///		</summary>
///	</class>
///	<author>
///		<name>Damien PHILIPPON</name>
///		<company>Atos Origin</company>
///		<ID></ID>
///	</author>
///	<version information>
///		<version number="1.0" date="10/06/2004" author="DP">
///			<summary>Base version</summary>
///		</version>
///	</version information>
///</cartouche>

var IDS_QPARAM_PHNAME = "wbc_phname";
var IDS_QPARAM_PHTYPE = "wbc_phtype";
var IDS_QPARAM_DESKRES = "wbc_deskres";
var IDS_QPARAM_REFRESHTREE = "FreshTree";
var IDS_QPARAM_PHWIDTH = "wbc_phwidth";
var IDS_QPARAM_PHHEIGHT = "wbc_phheight";
var IDS_WIN_GALLERY = "WBC_wndGallery";
var IDS_WIN_GALLERY_FEATURES = ""; 
//var PSA_GALLERY_URL = "http://localhost:80/Mediatheque/default.aspx?"
//var PSA_GALLERY_URL = "http://75A07439:8085/Mediatheque2/default.aspx?"
//var PSA_GALLERY_URL = "http://75A07439:8085/Mediatheque2/default.aspx?"

//var IDS_FRAMEWORK_NEW_VIRTUAL_PATH = "/CmsWebApplication1/CMS/WebAuthor";

//	Open a new attachment gallery window
function PSA_launchAttachmentGallery(strPostingQueryString, strPhName, strPhType, bAllowUpload, bAttachIcon, bAllowVideo) {
	var strURL;
	var strGalleryUrl = PSA_GALLERY_URL;
	strURL = strGalleryUrl + strPostingQueryString + "&" + IDS_QPARAM_PHNAME + "=" + encodeURI(strPhName) + "&" + IDS_QPARAM_PHTYPE + "=" +  strPhType + "&" + IDS_QPARAM_DESKRES + "=" + bAllowUpload + "&" + IDS_QPARAM_ATTACHICON + "=" + bAttachIcon + "&" + IDS_QPARAM_VIDEO + "=" + bAllowVideo + "&" + IDS_QPARAM_REFRESHTREE + "=True";
	PSA_openWindowOnFocus(strURL, IDS_WIN_GALLERY, 'left=0,top=0,width=922,height=691,resizable,scrollbars,status=yes');
}

function PSA_launchResourceGallery(strPostingQueryString, strPhName, strPhType, bAllowUpload, strWidth, strHeight) {
	var strURL;
	var strGalleryUrl = PSA_GALLERY_URL;
	strURL = strGalleryUrl + strPostingQueryString + "&" + IDS_QPARAM_PHNAME + "=" + encodeURI(strPhName) + "&" + IDS_QPARAM_PHTYPE + "=" +  strPhType + "&" + IDS_QPARAM_DESKRES + "=" + bAllowUpload + "&" + IDS_QPARAM_REFRESHTREE + "=True" + "&" + IDS_QPARAM_PHWIDTH + "=" + strWidth + "&" + IDS_QPARAM_PHHEIGHT + "=" + strHeight;
		//alert(strURL);
	leftPosition = (screen.width)?(screen.width-900)/2:100;
	topPosition=100;
	PSA_openWindowOnFocus(strURL, IDS_WIN_GALLERY, 'left=' + leftPosition + ',top=' + topPosition + ',width=900,height=500,resizable,scrollbars,status=yes');
}

function PSA_openWindowOnFocus(strURL, strWinTarget, strWinFeatures) 
{
	var pWindow = window.top.open(strURL, strWinTarget, strWinFeatures);
	if (pWindow)
		pWindow.focus();
}

// Checks if browser is IE
function PSA_isIE() {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return true;
	} else {
		return false;
	}
}

// Checks if browser is Netscape
function PSA_isNetscape() {
	if (navigator.appName.indexOf("Netscape") != -1) {
		return true;
	} else {
		return false;
	}
}

var IDS_WIDTH_OFFSET = 30;
var IDS_HEIGHT_OFFSET = 30;

var IDS_HTTP_PROTOCOL = "http://";

//	Adds an attachment to a Single Attachment placeholder
function PSA_setSingleAttachment(strPhName, strURL, strDispText) {
	__CMS_PostbackForm["NCPH_" + strPhName].value = strURL;
	__CMS_PostbackForm["NCPHAttach_" + strPhName].value = strURL.substring(strURL.lastIndexOf("/")+1);

	PSA_setAttachmentProp(strPhName, strDispText);
}
/*
function PSA_setThinEditIEImage(strPhName, strURL, strHRef, strAltText) {
	var strMultiPurposeTag;
	if ( strAltText != "" ) {
		strMultiPurposeTag = "<img src=\"" + strURL + "\" border=\"0\" alt=\"" + strAltText + "\">";
	} else {
		strMultiPurposeTag = "<img src=\"" + strURL + "\" border=\"0\">";
	}				
	if ((strHRef != "") && (strHRef != IDS_HTTP_PROTOCOL)) {
		strMultiPurposeTag = "<a href=\"" + strHRef + "\">" + strMultiPurposeTag + "</a>";
	}
	if (typeof document.all["NCPHRICH_" + strPhName] != 'undefined') {
		document.all["NCPHRICH_" + strPhName].insertHtml(strMultiPurposeTag);
	}
	else
	{
		if (typeof document.all["ICPH_Img_" + strPhName] != 'undefined') {
			document.all["ICPH_Img_" + strPhName].src = strURL;
			//SHT
			document.forms['myForm'].elements["btn" + strPhName].value = 'Générer vignette';
			//eval("sUrl" + strPhName +"=sUrl" + strPhName + ".sustr(0,sUrl"+ strPhName + ".indexOf('&imageurl'))+&imageurl=' + encodeURIComponent(strUrl)")
			var oc = document.forms['myForm'].elements["sUrl" + strPhName].substr(0,document.forms['myForm'].elements["sUrl" + strPhName].indexOf("&imageurl"));
			document.forms['myForm'].elements["sUrl" + strPhName] = oc + '&imageurl=' + encodeURIComponent(strUrl);
			//
		}
		if (typeof document.all["ICPH_ImgLink_" + strPhName] != 'undefined') {
			document.all["ICPH_ImgLink_" + strPhName].value = strURL;
		}
	}	
}
*/
// ---- [Public] insert an Attachment through the placeholder DOM
function PSA_setThinEditIEAttachment(strPhName, strURL, strDispText) {
	var strMyDispText = strDispText;
	if (strMyDispText == "") {
		strMyDispText = strURL;
	}
	document.all["NCPHRICH_" + strPhName].insertHtml("<a href=\"" + strURL + "\">" + strMyDispText + "</a>");
}

//	This function sets the attachment properties
function PSA_setAttachmentProp(strPhName, strDispText) {
	if (strDispText == null) {
		strDispText = "";
	}
	__CMS_PostbackForm["NCPHDispText_" + strPhName].value = strDispText;
}