
function myReplace(sRemove,sAdd){var a = this.split(sRemove); return a.join(sAdd);}
String.prototype.replaceAll = myReplace;

////////////////////
var myFunction = new FFunction();
function FFunction(pLang){
	
	this.language			= "";
	this.PageCurentName		= "";
	this.PageCurentHref		= "";
	
	this.ActionSave			= "SAVE";
	this.ActionSaveData		= "SAVEDATA";
	this.ActionGenerate		= "GENERATE";
	this.ActionGenerateForm	= "GENERATEFORM";
	this.ActionCut			= "MOVE";
	this.ActionDelete		= "DELETE";
	this.ActionDeleteData	= "DELETEDATA";
	this.ActionEditData		= "EDITDATA";
	this.ActionNewData		= "NEWDATA";
	this.ActionInsertData	= "INSERTDATA";
	this.ActionCancelData	= "CANCELDATA";
	this.ActionSearchData	= "SEARCHDATA";
	this.ActionSearchClearData	= "SEARCHCLEARDATA";
	this.ActionCopy			= "COPY";
	this.ActionSelectAll	= "SELECTALL";
	this.ActionDeselectAll	= "DESELECTALL";
	this.ActionTargetDefine	= "TARGETDEFINE";
	this.ActionMoveToTarget	= "MOVETOTARGET";
	this.ActionCopyToTarget	= "COPYTOTARGET";
	this.ActionBack			= "JUMPTOTARGET";
	this.ActionCancel		= "CANCEL";
	this.ActionBack			= "BACK";
	this.ActionBrowse		= "BROWSE";
	this.ActionAccept		= "ACCEPT";
	this.ActionJoin			= "JOIN";
	this.ActionImageGet		= "IMGGET";
	this.ActionRssGet		= "RSSGET";
	this.ActionDataUpdate	= "DATASOURCEUPDATE";
	this.ActionShoppingCartProductAdd	= "SHOPPINGCARTPRODUCTADD";
	this.ActionShoppingCartProductDelete	= "SHOPPINGCARTPRODUCTDELETE";
	this.ActionShoppingCartProductDeleteAll	= "SHOPPINGCARTPRODUCTALL";
	this.ActionShoppingCartClose	= "SHOPPINGCARTCLOSE";
	this.ActionShoppingCartMaximize	= "SHOPPINGCARTMAXIMIZE";
	this.ActionShoppingCartMinimize	= "SHOPPINGCARTMINIMIZE";
	this.ActionShoppingCartCheckOut	= "SHOPPINGCARTCHECKOUT";
	this.ActionShoppingCartAccept	= "SHOPPINGCARTACCEPT";
	this.ActionSendByEmail	= "SENDBYEMAIL";
	this.FormActionDefault	= "";
	this.FormName			= "cmsFormControl";
	this.FormValidate		= true;
	this.InputNameNewsID	= "NEWS_ID";
	this.Msg				= "";
	this.Mode				= "";
	this.ModeDetail			= "DETAIL";
	
	//method
	this.Navigate				= FF_Navigate;
	this.Sort					= FF_Sort;
	this.Edit					= FF_Edit;
	this.Save					= FF_Save;
	this.Delete					= FF_Delete;
	this.New					= FF_New;
	this.Add					= FF_Add;
	this.Cancel					= FF_Cancel;
	this.Search					= FF_Search;
	this.SearchClear			= FF_SearchClear;
	this.NewsRefSave			= FF_NewsRefSave;
	this.sendToFriend			= FF_sendToFriend;
	this.linkContent			= FF_LinkContent;
	this.linkAll				= FF_LinkAll;
	this.UrlValidate			= FF_UrlValidate;
	this.PageCurrentSet			= FF_PageCurrentSet;
	this.PageCurrentParameterAdd= FF_PageCurrentParameterAdd;
	this.FormSubmit				= FF_FormSubmit;
	this.FormDataSubmit			= FF_FormDataSubmit;
	this.FormActionDefaultSet	= FF_FormActionDefaultSet;
	this.UrlModeValidate		= FF_UrlModeValidate;
	this.ModeSet				= FF_ModeSet;
	this.LanguageSet			= FF_LanguageSet;
	this.checkAll				= FF_checkAll;
	this.uncheckAll				= FF_uncheckAll;
	this.StringSumary			= FF_StringSumary;
	this.CopyToClipboard		= FF_CopyToClipboard;
	this.ShoppingCartProductAdd	= FF_ShoppingCartProductAdd;
	this.ShoppingCartProductDelete	= FF_ShoppingCartProductDelete;
	
	this.ShoppingCartClose		= FF_ShoppingCartClose;
	this.ShoppingCartMaximize	= FF_ShoppingCartMaximize;
	this.ShoppingCartMinimize	= FF_ShoppingCartMinimize;
	this.ShoppingCartCheckOut	= FF_ShoppingCartCheckOut;
	this.ShoppingCartAccept		= FF_ShoppingCartAccept;
	this.ShoppingCartClient		= FF_ShoppingCartClient;
	
	this.DatasourceUpdate		= FF_DatasourceUpdate;
	
	this.ComponentExtValidate	= FF_ComponentExtValidate;
	this.ComponentFileValidate	= FF_ComponentFileValidate;
	
	this.TopRedirect			= FF_TopRedirect;
}

function getParameter(queryString, parameterName) {
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	if ( queryString.length > 0 ) {
		// Find the beginning of the string
		begin = queryString.indexOf ( parameterName );
		// If the parameter name is not found, skip it, otherwise return the value
		if ( begin != -1 ) {
			// Add the length (integer) to the beginning
			begin += parameterName.length;
			// Multiple parameters are separated by the "&" sign
			end = queryString.indexOf ( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length
			}
			// Return the string
			return unescape ( queryString.substring ( begin, end ) );
		}
		// Return "null" if no parameter has been found
		return "";
	}
}

function CMSBaseParamGet(){
	var QueryString = document.location.search;
	var Param = "";
	
	Param = "?Lang=" + getParameter(QueryString, "Lang")
	Param += "&ParentID=" + getParameter(QueryString, "ParentID")
	Param += "&SectionID=" + getParameter(QueryString, "SectionID")
	return Param;
}




function FF_StringSumary(pString,pMaxLength){
	var MaxLength = pMaxLength || 250;
	var sString = pString || "";
	
	if(pString.length > MaxLength)
		sString = pString.substring(0,MaxLength) + "...";
	
	return sString;
}

function FF_TopRedirect() {
if (top != self)
    top.location.href = self.location.href
}

function FF_checkAll(p_FormName,pChkName) {
	var strFormName = p_FormName || this.FormName;
	var strChkName = pChkName || "ItemID";
	
	FF_checked(true,strFormName,strChkName)
}

function FF_uncheckAll(p_FormName,pChkName) {
	var strFormName = p_FormName || this.FormName;
	var strChkName = pChkName || "ItemID";
	
	FF_checked(false,strFormName,strChkName)
}

function FF_checked(Check,pFormName,pChkName) {

	var len = document.forms[pFormName].length;
	for(var i=0 ; i<len ; i++)
		if (document.forms[pFormName].elements[i].name==pChkName)
			document.forms[pFormName].elements[i].checked=Check;
	bCheck = !Check
}

function FF_FormActionDefaultSet(pAction) {
	this.FormActionDefault = pAction;
}
function FF_LanguageSet(pAction) {
	this.language = pAction;
}
function FF_ModeSet(pMode) {
	this.Mode = pMode;
}

function FF_sendToFriend(p_strTo,p_strName, p_strHref) {
	var strTo = p_strTo || '';
	var strName = p_strName || this.PageCurentName;
	var strHref = p_strHref || "cmsFrameMain.aspx" + this.PageCurentHref;
	
	var imgUrlValidate = new Image();
	imgUrlValidate.src = strHref;
    popupMail(strTo,'','',strName,imgUrlValidate.src)
}

function FF_LinkContent(){
	this.CopyToClipboard("cmsContent.aspx" + this.PageCurentHref);
}
function FF_LinkAll(){
	this.CopyToClipboard("cmsFrameMain.aspx" + this.PageCurentHref);
}

function FF_UrlValidate(p_strHref) {
	return unescape(p_strHref);
}

function FF_PageCurrentSet(p_strName, p_strHref){this.PageCurentName=p_strName; this.PageCurentHref=p_strHref;}

function FF_PageCurrentParameterAdd(p_strParamName,p_strParamValue){
	if(this.PageCurentHref.toUpperCase().indexOf(p_strParamName.toUpperCase()) == -1)
		this.PageCurentHref += "&" + p_strParamName + "=" + p_strParamValue;
}

function FF_NewsRefSave(p_strItemID){
	document.forms[this.FormName].elements[this.InputNameNewsID].value = p_strItemID;
	myFunction.FormSubmit(this.ActionSave)
}

function FF_FormSubmit(pCMSAction,pFormAction,pFormTarget,pFormChange){
	var strCMSAction	= pCMSAction || "";
	var strFormAction	= pFormAction || "";
	var strFormTarget	= pFormTarget || "";
	var strFormChange	= pFormChange || "";
	
	var bPerform	= true;
	var strFormName	= this.FormName;
	
	if(strFormChange!=""){
		if(document.forms.length > 1){
			try{
			strFormName = document.forms[strFormChange].name;
			}
			catch(e){
				try{
					strFormName = document.forms[1].name;
				}catch(e){strFormName = "";}
			}
			if(strFormName!=""){
				document.forms[strFormName].action = this.FormActionDefault;
			}
		}
	}
	
	strCMSAction = strCMSAction.toUpperCase();
	switch(strCMSAction){
		case this.ActionDelete:
			bPerform = confirm(CLanguage(this.language).MsgEditDelete);
			break;
		case this.ActionDeleteData:
			bPerform = confirm(CLanguage(this.language).MsgEditDelete);
			break;
		case this.ActionDeselectAll:
			this.uncheckAll(strFormName);
			bPerform = false;
			break;
		case this.ActionSelectAll:
			this.checkAll(strFormName);
			bPerform = false;
			break;
		case this.ActionGenerate:
			if(!confirm(CLanguage(this.language).MsgEditGenerate)){
				strCMSAction = this.ActionSave;
			}
			break;
	}
	
	if(bPerform){
		if(strFormAction=="") strFormAction = document.forms[strFormName].action || "";
		if(strFormAction=="") strFormAction = this.FormActionDefault;
		
		if(strCMSAction!=""){
			var aFormAction = strFormAction.split("?");
			strFormAction = aFormAction[0] + "?" + "Action=" + strCMSAction + "&" + aFormAction[1];
		}
		if(document.forms[strFormName].onsubmit > "")
			document.forms[strFormName].onsubmit();
		
		if(!this.FormValidate){
			alert(this.Msg);
		}
		else{
		
			if(strFormTarget!="") document.forms[strFormName].target = strFormTarget;
			if(strFormAction!="") document.forms[strFormName].action = strFormAction;

			document.forms[strFormName].submit();
		}
	}
}
function FF_Sort(p_strContainerID, p_strInputName_SortFieldName, p_strSortFieldName, p_strInputName_Sort , p_strSort){
		
	var strAction  = document.forms[this.FormName].action || "";
	if(strAction=="")
		strAction = top.myFunction.FormActionDefault;
	strAction += "#ref" + p_strContainerID
	document.forms[this.FormName].action = strAction

	
	document.forms[this.FormName].elements[p_strInputName_SortFieldName].value = p_strSortFieldName;
	document.forms[this.FormName].elements[p_strInputName_Sort].value = p_strSort;
	document.forms[this.FormName].elements['cmsContainerID'].value = p_strContainerID;
	document.forms[this.FormName].submit();
}


function FF_FormDataSubmit(p_strContainerID,p_strAction){
	var strParameters = document.forms[this.FormName].elements['cmsParameters'].value;
	
	this.FormName = "CONTAINER_" + p_strContainerID;
	//this.FormActionDefault = top.myFunction.FormActionDefault + "#ref" + p_strContainerID;
	this.FormActionDefault = this.UrlModeValidate(top.myFunction.FormActionDefault,p_strContainerID,'CONTAINER');
	this.FormActionDefault += "#ref" + p_strContainerID;
	
	document.forms[this.FormName].elements['cmsContainerID'].value = p_strContainerID;
	document.forms[this.FormName].elements['cmsParameters'].value = strParameters;
	this.FormSubmit(p_strAction);
}

/* ShoppingCart method */
function FF_ShoppingCartProductAdd(pItemID,pIsCallByProduct){
	var sCallByProduct = pIsCallByProduct || false;
	
	var sTarget = "";
	var sAction = "cmsShoppingCartManagement.aspx";
	if(pIsCallByProduct){
		if(isShoppingCartFrameExist()){
			sTarget = "frmShoppingCart";
		}
		else{
			sTarget = ShoppingCartRedirectFrame;
			sAction = ShoppingCartRedirectPage;
		}
	}
	document.forms[this.FormName].action = sAction + CMSBaseParamGet() + "&ItemID=" + pItemID + "#ref" + pItemID;
	this.FormSubmit(this.ActionShoppingCartProductAdd,"",sTarget);
}

function FF_ShoppingCartProductDelete(pItemID, pAll){
	var bDeleteAll = pAll || false;
	
	var strAction  = document.forms[this.FormName].action || "";
	if(strAction=="")
		strAction = top.myFunction.FormActionDefault;
	strAction += "&ItemID=" + pItemID
	document.forms[this.FormName].action = strAction
	
	var Action = this.ActionShoppingCartProductDelete;
	if(bDeleteAll)
		Action = this.ActionShoppingCartProductDeleteAll
		
	this.FormSubmit(Action)
}

function FF_ShoppingCartClose(){
	
	var sTarget = "";
	var sAction = "";
	if(isShoppingCartFrameExist()){
		sTarget = ShoppingCartRedirectFrame;
		sAction = ShoppingCartRedirectPage;
	}
	else{
		sTarget = "frmContent";
		sAction = "cmsShoppingCartManagement.aspx";
	}

	this.FormActionDefault = sAction + CMSBaseParamGet();
	this.FormSubmit(this.ActionShoppingCartClose,"",sTarget);
}

function FF_ShoppingCartMaximize(){
	
	var sTarget = "";
	var sAction = "";
	if(isShoppingCartFrameExist()){
		sTarget = ShoppingCartRedirectFrame;
		sAction = ShoppingCartRedirectPage;
	}
	else{
		sTarget = "frmContent";
		sAction = "cmsShoppingCartManagement.aspx";
	}
	
	this.FormActionDefault = sAction + CMSBaseParamGet();
	this.FormSubmit(this.ActionShoppingCartMaximize,"",sTarget);
}

function FF_ShoppingCartMinimize(){
	var sTarget = ShoppingCartRedirectFrame;
	var sAction = ShoppingCartRedirectPage + CMSBaseParamGet();

	this.FormActionDefault = sAction;
	this.FormSubmit(this.ActionShoppingCartMinimize,"",sTarget);
}
function FF_ShoppingCartCheckOut(){
	var sTarget = "frmContent";
	var sAction = "cmsShoppingCartManagement.aspx" + CMSBaseParamGet();
	
	this.FormActionDefault = sAction;
	this.FormSubmit(this.ActionShoppingCartCheckOut,"",sTarget);
}

function FF_ShoppingCartClient(){
	this.FormActionDefault = "cmsShoppingCartManagement.aspx?Lang=" + this.language + "&ParentID=CMSShoppingCart";
	this.FormSubmit();
}

function FF_ShoppingCartAccept(){
	this.FormActionDefault = top.myFunction.FormActionDefault;
	this.FormSubmit(this.ActionShoppingCartAccept);
}

var ShoppingCartRedirectFrame = "_top"
var ShoppingCartRedirectPage = "cmsFrameMain.aspx"
function isShoppingCartFrameExist(){
	var bExist = false;
	try{
		var Exist = top.frames["frmShoppingCart"].name;
		bExist = true;
		ShoppingCartRedirectFrame = "_top"
		ShoppingCartRedirectPage = "cmsFrameMain.aspx"
	}
	catch(e){
		try{
			var Exist = parent.frames["frmShoppingCart"].name;
			bExist = true;
			ShoppingCartRedirectFrame = "frmMain"
			ShoppingCartRedirectPage = "cmsFrameContent.aspx"
		}
		catch(e){
			bExist = false;
		}
	}
	return bExist;
}
/* END ShoppingCart method */


function FF_UrlModeValidate(pUrl,pItemID,p_ItemType){
	var Url = pUrl;
	if(this.Mode==this.ModeDetail){
		Url += "&Mode=" + this.ModeDetail + "&ItemID=" + pItemID + "&ItemType=" + p_ItemType;
	}
	return Url;
}

function FF_Navigate(p_strContainerID,First){
	document.forms["cmsFormControl"].elements["cmsContainerID"].value = p_strContainerID;
	document.forms["cmsFormControl"].elements["cmsFirst"].value = First;
	
	var strAction  = document.forms["cmsFormControl"].action || "";
	if(strAction=="")
		strAction = this.UrlModeValidate(top.myFunction.FormActionDefault,p_strContainerID,'CONTAINER');
	if(p_strContainerID!="")
		strAction += "#ref" + p_strContainerID;

	document.forms["cmsFormControl"].action = strAction;
	document.forms["cmsFormControl"].submit();
}

function FF_Edit(p_strContainerID){
	this.FormDataSubmit(p_strContainerID,this.ActionEditData)
}

function FF_Save(p_strContainerID){
	this.FormDataSubmit(p_strContainerID,this.ActionSaveData)
}

function FF_Delete(p_strContainerID){
	this.FormDataSubmit(p_strContainerID,this.ActionDeleteData)
}

function FF_Add(p_strContainerID){
	this.FormDataSubmit(p_strContainerID,this.ActionInsertData)
}

function FF_New(p_strContainerID){
	this.FormDataSubmit(p_strContainerID,this.ActionNewData)
}

function FF_Cancel(p_strContainerID){
	this.FormDataSubmit(p_strContainerID,this.ActionCancelData)
}

function FF_Search(p_strContainerID){
	this.FormDataSubmit(p_strContainerID,this.ActionSearchData)
}

function FF_SearchClear(p_strContainerID){
	this.FormDataSubmit(p_strContainerID,this.ActionSearchClearData)
}


function FF_DatasourceUpdate(p_strDatasourceID){
		
	var strAction  = document.forms[this.FormName].action || "";
	if(strAction=="")
		strAction = top.myFunction.FormActionDefault;
	
	strAction += "&Action=" + this.ActionDataUpdate
	document.forms[this.FormName].action = strAction

	document.forms[this.FormName].elements['cmsDatasourceID'].value = p_strDatasourceID;
	document.forms[this.FormName].submit();
	//this.FormSubmit(this.ActionDataUpdate);
}


function FF_FileExtValidate(Extention, ExtAllAccepted, ExtException){
	
	var bValidate = true;
	var strExtention = "|" + Extention.toUpperCase() + "|";
	var strExtException = "|" + ExtException.toUpperCase() + "|";
	
            if(ExtAllAccepted){
                if(ExtException != "" && strExtException.indexOf(strExtention) >= 0)
                    bValidate = false;
            }else{
            
                if(strExtException.indexOf(strExtention) < 0)
                    bValidate = false;
            }

	return bValidate;
}

function FF_ComponentFileValidate(FileName, ExtentionAccept, ExtentionExcept){
	var aFilename = FileName.split(".");
	var strExtention;
	if(aFilename.length > 0)
		strExtention = aFilename[aFilename.length - 1];
		
	this.ComponentExtValidate(strExtention, ExtentionAccept, ExtentionExcept);
	if(!this.FormValidate)
		alert(this.Msg);
}

function FF_ComponentExtValidate(Extention, ExtentionAccept, ExtentionExcept){
	this.FormValidate = true
	var strAccept = ExtentionAccept;
	var strExcept = ExtentionExcept;

	if((strAccept == "*" && strExcept == "*") || (strAccept == "" && strExcept == ""))
		this.FormValidate = false;
	else{
		if(strAccept == "*" || strAccept == "")
			this.FormValidate = FF_FileExtValidate(Extention, true, strExcept);
		else if(strAccept != "")
			this.FormValidate = FF_FileExtValidate(Extention, false, strAccept);
	}
	
	if(!this.FormValidate)
		this.Msg = CLanguage(this.language).MsgEditExtNoValid;
}
//////////////////////////

/*function inFrame(Href){
	parent.frames["frmContent"].location.href = Href;
}
		
function inFrameMulti(Href){
	parent.frames["frmContent"].location.href = "cmsContent.aspx" + Href;;
	parent.frames["frmNavigator"].location.href = "cmsNavigator.aspx" + Href;
}*/



function popupMail(p_strTo, p_strCc, p_strBcc, p_strSubject, p_strBody) {

    // BUILD MAIL MESSAGE COMPONENTS 
    var s = "?";
    var doc = "mailto:"
    if(p_strTo!="")	doc+= p_strTo;
    
    if(p_strCc!=""){
		doc+= s + "cc=" + p_strCc;
		s = "&";}
    if(p_strBcc!=""){
		doc+= s + "cc=" + p_strBcc;
		s = "&";}
	if(p_strSubject!=""){
		doc+= s + "subject=" + escape(p_strSubject);
		s = "&";}
	if(p_strBody!=""){
		doc+= s + "body=" + escape(p_strBody);
		s = "&";}

    // POP UP EMAIL MESSAGE WINDOW
    window.location = doc;
} 


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function encode(str) {
	var result = "";
	
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) == " ") result += "+";
		else result += str.charAt(i);
	}
	
	return escape(result);
}

function decode(str) {
	return unescape(str.replace(/\+/g, " "));
}

var aEditorLoad = new Array(0);
function EditorLoadAdd(myFunction){
	aEditorLoad[aEditorLoad.length] = myFunction;
}
function EditorLoad(){
	for (var i = 0; i < aEditorLoad.length; i++) {
		aEditorLoad[i]();
	}
}

var aEditorGet = new Array(0);
function EditorGetAdd(myFunction){
	aEditorGet[aEditorGet.length] = myFunction;
}
function EditorGet(){
	for (var i = 0; i < aEditorGet.length; i++) {
		aEditorGet[i]();
	}
}


var icoImg = new Array(0);
var icoImgKey = new Array(0);

function ImgCacheAdd(key,src){
	var i;
	for(i=0;i<icoImgKey.length;i++){
		if(icoImgKey[i] == key){
			return;
		}
	}
	
	icoImgKey[i] = key
	icoImg[i] = new Image();
	icoImg[i].src = src;
}

function over(name, key){
	var ImgKey;
	
	for(i=0;i<icoImgKey.length;i++){
		if(icoImgKey[i] == key){
			ImgKey = i;
		}
	}
	eval('document.images[name].src = icoImg[ImgKey].src')
}
function out(name, key){	
	var ImgKey;
	for(i=0;i<icoImgKey.length;i++){
		if(icoImgKey[i] == key){
			ImgKey = i;
		}
	}
	eval('document.images[name].src = icoImg[ImgKey].src')
}

function saveImageAs (url,name) {
       if (!document.execCommand) {
           alert('Sorry.Your browser doesn\'t support this action.'); return;
     }
       tgt = document.frames['dummy'];
       tgt.location = url;
       tgt.name = name;
       setTimeout('tgt.document.execCommand("SaveAs",false,name)', 500);
  }
  
function checkAll(p_sFormName,p_sChkName) {
	bCheck = true;
	SetChecked(p_sFormName,p_sChkName)
}
function uncheckAll(p_sFormName,p_sChkName) {
	bCheck = false;
	SetChecked(p_sFormName,p_sChkName)
}


var bCheck = true;
function SetChecked(p_sFormName,p_sChkName) {

	var len = document.forms[p_sFormName].length;
	for(var i=0 ; i<len ; i++)
		if (document.forms[p_sFormName].elements[i].name==p_sChkName)
			document.forms[p_sFormName].elements[i].checked=bCheck;
	bCheck = !bCheck
}


function Sort(p_sFormName, p_sInputName_SortFieldName, p_sSortFieldName, p_sInputName_Sort , p_sSort){
	myFunction.Sort(p_sFormName, p_sInputName_SortFieldName, p_sSortFieldName, p_sInputName_Sort , p_sSort);
}

function FileManagement(ParentID,ID,Action,Option){
	var bSubmit = true;
	var sTarget = "_self";
	var strFormName = "CONTAINER_" + ParentID
	
	var sAction  = "cmsFileManagement.aspx?Action=" + Action + "&" + document.forms[strFormName].elements["cmsUrlParameters"].value
	if(Action == "VIEWINBROWSER" || Action == "VIEWHISTORY") sTarget = "_new"
	
	if(Action == "DELETE")
		bSubmit = confirm("Voulez-vous vraiment supprimer ce fichier?");
		
	if(Action == "NAVIGATE")
		document.forms[strFormName].elements["cmsFirst"].value = Option;
	
	if(Action == "GETVERSION")
		document.forms[strFormName].elements["cmsFileVersion"].value = Option;
	
	if(bSubmit){
		document.forms[strFormName].action = sAction
		document.forms[strFormName].target = sTarget
		document.forms[strFormName].elements["hidItemID"].value = ID;
		document.forms[strFormName].submit();
	}
}

//Obsolete
function FormManage(ListID,First){
	//myFunction.Navigate(ListID,First);
	document.forms["cmsFormControl"].elements["cmsContainerID"].value = ListID;
	document.forms["cmsFormControl"].elements["cmsFirst"].value = First;
	
	var strAction  = document.forms["cmsFormControl"].action || "";
	if(strAction=="")
		strAction = top.myFunction.FormActionDefault;
	if(ListID!="")
		strAction += "#ref" + ListID;

	document.forms["cmsFormControl"].action = strAction;
	document.forms["cmsFormControl"].submit();
}

function FormControlManage(pPageAction,Action,pPageTarget){
	var strPageAction = pPageAction || "";
	var strPageTarget = pPageTarget || "";
	var  strFormName = "cmsFormControl";
	
	if(strPageTarget!="") document.forms[strFormName].action = strPageTarget;
	if(strPageTarget!="") document.forms[strFormName].target = strPageTarget;
	
	myFunction.FormSubmit(strFormName,Action);
}



function WindowOpen(p_sAction, p_iWidth, p_iHeight,p_sParameters,p_bMoveTo){
	var iWidth = p_iWidth || "450";
	var iHeight = p_iHeight || "550";
	var bMoveTo = p_bMoveTo || false;
	
	//var sParameters = "";
	//if(p_sParameters!="") sParameters =  p_sParameters + ",Width=" + iWidth +  ",Height=" + iHeight;
	//if(sParameters=="") sParameters = "resizable=yes,toolbar=no,scrollbars=yes,status=no,Width=" + iWidth +  ",Height=" + iHeight;
	
	var sParameters =  "width=" + iWidth +  ",height=" + iHeight;
	if(p_sParameters!="") sParameters += "," + p_sParameters
	
	var sWinName = "myNewWindow";
	var win = window.open(p_sAction, sWinName,sParameters);
	
	//win.moveTo((screen.availWidth - iWidth) / 2,(screen.availHeight - iHeight) / 2);
	if (parseInt(navigator.appVersion) >= 4 && bMoveTo) win.moveTo((screen.width/2)-(iWidth/2+10),(screen.height/2)-(iHeight/2+20));
	win.focus();
}

//get div
function F_DivGet(Key){
	if(is.ns) return document.layers[Key];
	else return document.all[Key].style;
}

// show and hide div
//function F_DivShow(Key){
//	if (is.ns) F_DivGet(Key).visibility = "show";
//	else if (is.ie) F_getDiv(Key).visibility = "visible";
//}
//
//function F_DivHide(Key){
//	if (is.ns) F_DivGet(Key).visibility = "hide"
//	else if (is.ie) F_getDiv(Key).visibility = "hidden"
//}

// show and hide div
//.offsetWidth
var iHeight = -1;
var iTop = -1;
var iLeft = -1;
var iRight = -1;
var iBottom = -1;
function update(Div){
	if (iTop = -1){
	iTop = Div.offsetTop;
	iLeft = Div.offsetLeft;
	iRight = iLeft + Div.offsetWidth;
	iBottom = iTop + Div.offsetHeight;
	}
}
function F_DivShow(Div){
	update(Div);
	
	if (is.ns) Div.visibility = "show";
	else if (is.ie) Div.style.visibility = "visible";
	
	F_clipTo(Div,iTop,iRight,iBottom,iLeft)
}

function F_DivHide(Div){
	update(Div);
	
	F_clipTo(Div,iTop,iRight,iTop + 1 ,iLeft)
	if (is.ns) Div.visibility = "hide"
	else if (is.ie)	Div.style.visibility = "hidden"
}

// BrowserCheck Object
function BrowserCheck() {
	var b = navigator.appName;
	if (b=="Netscape") this.b = "ns";
	else if (b=="Microsoft Internet Explorer") this.b = "ie";
	else this.b = b;
	this.version = navigator.appVersion;
	this.v = parseInt(this.version);
	this.ns = (this.b=="ns" && this.v>=4);
	this.ns4 = (this.b=="ns" && this.v==4);
	this.ns5 = (this.b=="ns" && this.v==5);
	this.ie = (this.b=="ie" && this.v>=4);
	this.ie4 = (this.version.indexOf('MSIE 4')>0);
	this.ie5 = (this.version.indexOf('MSIE 5')>0);
	this.min = (this.ns||this.ie);
}
is = new BrowserCheck();

function F_clipTo(Div,p_iTop,p_iRight,p_iBottom,p_iLeft)
{
	var oObject = Div.clip;
	
	if(is.ie)	//clip:rect(top,right,bottom,left)
		oObject = "rect(" + p_iTop + "px "+ p_iRight +"px " + p_iBottom + "px " + p_iLeft + "px)";
	else{
		oObject.top = p_iTop;
		oObject.right = p_iRight;
		oObject.bottom = p_iBottom;
		oObject.left = p_iLeft;
	}
}

function FF_CopyToClipboard(meintext){
	if (window.clipboardData) {
		// the IE-manier
		window.clipboardData.setData("Text", meintext);

		// waarschijnlijk niet de beste manier om Moz/NS te detecteren;
		// het is mij echter onbekend vanaf welke versie dit precies werkt:
	} else if (window.netscape) { 
		// dit is belangrijk maar staat nergens duidelijk vermeld:
		// you have to sign the code to enable this, or see notes below 
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

		// maak een interface naar het clipboard
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;

		// maak een transferable
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		// specificeer wat voor soort data we op willen halen; text in dit geval
		trans.addDataFlavor('text/unicode');

		// om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig   om het in op te slaan
		var str = new Object();
		var len = new Object();

		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

		var copytext=meintext;

		str.data=copytext;

		trans.setTransferData("text/unicode",str,copytext.length*2);

		var clipid=Components.interfaces.nsIClipboard;

		if (!clip) return false;

		clip.setData(trans,null,clipid.kGlobalClipboard);
	}
	alert(CLanguage(this.language).MsgClipboard + "\n\n" + meintext);
	return false;
}