//My String Prototype
function myReplace(sRemove,sAdd){var a = this.split(sRemove); return a.join(sAdd);}
String.prototype.replaceAll = myReplace;
function myEndWith(pEndWith){return (this.lastIndexOf(pEndWith)==this.length-pEndWith.length);}
String.prototype.endWith = myEndWith;
function myStartWith(pStartWith){return (this.indexOf(pStartWith)==0);}
String.prototype.startWith = myStartWith;

function myTrimAll(){var s = this;
	while (s.substring(0,1) == ' '){s = s.substring(1, s.length);}
	while (s.substring(s.length-1, s.length) == ' '){s = s.substring(0,s.length-1);}
	return s;
}
String.prototype.trimAll = myTrimAll;


////////////////////
var myFunction = new FFunction();
function FFunction(pLang){
	
	this.language			= "";
	this.PageCurrentTitle	= "";
	this.PageCurrentName	= "";
	this.PageCurrentParam	= "";
	this.AddToPath			= "";
	
	this.ActionSave			= "SAVE";
	this.ActionSaveProperties	= "SAVEPROPERTIES";
	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.ActionRefManage	= "REFMANAGE";
	this.DeleteCache		= "DELETECACHE";
	this.ActionShoppingCartCustomInfo = "SHOPPINGCARTCUSTOMINFO";
	this.ActionShoppingCartCustomInfoSave = "SHOPPINGCARTCUSTOMINFOSAVE";
	this.ActionShoppingCartProductAdd	= "SHOPPINGCARTPRODUCTADD";
	this.ActionShoppingCartProductDelete	= "SHOPPINGCARTPRODUCTDELETE";
	this.ActionShoppingCartProductDeleteAll	= "SHOPPINGCARTPRODUCTALL";
	this.ActionShoppingCartShippingModeSave	= "SHIPPINGMODESAVE";
	this.ActionShoppingCartClose	= "SHOPPINGCARTCLOSE";
	this.ActionShoppingCartMaximize	= "SHOPPINGCARTMAXIMIZE";
	this.ActionShoppingCartMinimize	= "SHOPPINGCARTMINIMIZE";
	this.ActionShoppingCartCheckOut	= "SHOPPINGCARTCHECKOUT";
	this.ActionShoppingCartAccept	= "SHOPPINGCARTACCEPT";
	this.ActionShoppingCartPrint	= "SHOPPINGCARTPRINT";
	this.ActionSendByEmail	= "SENDBYEMAIL";
	this.FormActionDefault	= "";
	this.FormName			= "cmsFormControl";
	this.FormValidate		= true;
	this.InputNameNewsID	= "NEWS_ID";
	this.Msg				= "";
	this.Mode				= "";
	this.ModeDetail			= "DETAIL";
	
	this.ShoppingCartIsMinimise = false;
	this.ShoppingCartHref = "";
	
	
	//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.ShoppingCartShippingModeSave	= FF_ShoppingCartShippingModeSave;
	
	this.ShoppingCartClose		= FF_ShoppingCartClose;
	this.ShoppingCartMaximize	= FF_ShoppingCartMaximize;
	this.ShoppingCartMinimize	= FF_ShoppingCartMinimize;
	this.ShoppingCartCheckOut	= FF_ShoppingCartCheckOut;
	this.ShoppingCartAccept		= FF_ShoppingCartAccept;
	this.ShoppingCartPrint		= FF_ShoppingCartPrint;
	this.ShoppingCartCustomInfo	= FF_ShoppingCartCustomInfo;
	this.ShoppingCartCustomInfoSave	= FF_ShoppingCartCustomInfoSave;
	this.ShoppingCartSend		= FF_ShoppingCartSend;
	this.ShoppingCartPayment	= FF_ShoppingCartPayment;
	this.ShoppingCartClient		= FF_ShoppingCartClient;
	
	this.DatasourceUpdate		= FF_DatasourceUpdate;
	
	this.ComponentExtValidate	= FF_ComponentExtValidate;
	this.ComponentFileValidate	= FF_ComponentFileValidate;
	
	this.TopRedirect			= FF_TopRedirect;
	this.TopLocation			= FF_TopLocation;
}

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 HtmlConvertToSend(pFormName,pElementName){
	var sValue = document.forms[pFormName].elements[pElementName].value;
	sValue = sValue.replaceAll("<","%3C");
	sValue = sValue.replaceAll(">","%3E");
	document.forms[pFormName].elements[pElementName].value = sValue;
}
function HtmlConvertFromReceive(pFormName,pElementName){
	var sValue = document.forms[pFormName].elements[pElementName].value;
	sValue = sValue.replaceAll("%3C","<");
	sValue = sValue.replaceAll("%3E",">");
	document.forms[pFormName].elements[pElementName].value = sValue;
}

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(bGlobalLink) {
	var href = "";
	if(bGlobalLink){
		if(self.name.toUpperCase() != 'FRMCONTENT')
			href = "cmsFrameMain.aspx" + this.PageCurrentParam
	}
	else{
		if (top != self)
			href = self.location.href
	}
	if(href!="")
		top.location.href = href;
}

function FF_TopLocation(pHref){
	top.location.href = pHref;
}

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){
			if(document.forms[pFormName].elements[i].checked!=Check){
				document.forms[pFormName].elements[i].checked=Check;
				CMSEditComponentCheckSet(document.forms[pFormName].elements[i]);
			}
		}
	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, p_bForm) {
	var strTo = p_strTo || '';
	var strName = p_strName || this.PageCurrentTitle;
	var strHref = p_strHref || "cmsFrameMain.aspx" + this.PageCurrentParam;
	var bForm = p_bForm || false;
	
	var imgUrlValidate = new Image();
	imgUrlValidate.src = strHref;
	if(bForm){
		this.EmailTitle = strName;
		this.EmailHref = imgUrlValidate.src;
		top.frmMain.frmContent.document.location = "cmsContent.aspx?Lang=" + this.language + "&ParentID=EmailSendTo";
	}
	else
		popupMail(strTo,'','',strName,imgUrlValidate.src)
}

function FF_LinkContent(){
	this.CopyToClipboard("cmsContent.aspx" + this.PageCurrentParam);
}
function FF_LinkAll(){
	this.CopyToClipboard("cmsFrameMain.aspx" + this.PageCurrentParam);
}

function FF_UrlValidate(p_strHref) {
	return unescape(p_strHref);
}

function FF_PageCurrentSet(p_sPageTitle,p_Location)
{
	this.PageCurrentTitle = p_sPageTitle;
	this.PageCurrentParam = p_Location.search;
	var aPathname = p_Location.pathname.split("/");
	this.PageCurrentName = aPathname[aPathname.length-1];
}

function FF_PageCurrentParameterAdd(p_strParamName,p_strParamValue){
	if(this.PageCurrentParam.toUpperCase().indexOf(p_strParamName.toUpperCase()) == -1)
		this.PageCurrentParam += "&" + 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,pParamters){
	var strCMSAction	= pCMSAction || "";
	var strFormAction	= pFormAction || "";
	var strFormTarget	= pFormTarget || "";
	var strFormChange	= pFormChange || "";
	var strParamters	= pParamters || "";
	
	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(strParamters!="")
				strFormAction+= "&" + strParamters;
				
			
		
			if(strFormTarget!="") document.forms[strFormName].target = strFormTarget;
			if(strFormAction!=""){
				var sNeedAddToPath = "";
				if(!strFormAction.toUpperCase().startWith("HTTP"))
					sNeedAddToPath = this.AddToPath;
				document.forms[strFormName].action = sNeedAddToPath + 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 */
var _hPriceMatrixValues = {};
var _PriceMatrixText = "text";
var _PriceMatrixValue = "value";
var _PriceMatrixId = "id";
function PriceMatrixValueApply(pControl,pFormName,pControlTargetName,pUniqueID){
	var ControlTarget = document.forms[pFormName].elements[pControlTargetName];
	var ValueId = pUniqueID + pControl.options[pControl.selectedIndex].value;
	switch(ControlTarget.type){
		case "select-one":
			var iSelectedIndex = ControlTarget.selectedIndex
			
			//clear myControl options
			for(var i=ControlTarget.options.length-1;i>=0;i--){
				ControlTarget.options.remove(i);
			}
			
			//create new options from _hPriceMatrixValues object
			for(var i=0; i<_hPriceMatrixValues[ValueId].length; i++){
				
				var sText = _hPriceMatrixValues[ValueId][i][_PriceMatrixText];
				var sValue = _hPriceMatrixValues[ValueId][i][_PriceMatrixValue];
				var sId = _hPriceMatrixValues[ValueId][i][_PriceMatrixId];
				ControlTarget.options.add(new Option(sText+" : "+sValue,sId));
			}
			
			if(ControlTarget.options.length>1)
				ControlTarget.selectedIndex = iSelectedIndex;
			else
				ControlTarget.selectedIndex = 0;
			break;
			
		case "text":
		case "hidden":
			ControlTarget.value = _hPriceMatrixValues[ValueId][_PriceMatrixId];
			document.forms[pFormName].elements[pControlTargetName+'Price'].value = _hPriceMatrixValues[ValueId][_PriceMatrixValue];
			break;
	}
}
function PriceMatrixValueAdd(pUniqueID,pType,pText,pValue,pID){
	switch(pType){
		case "select-one":
			if(_hPriceMatrixValues[pUniqueID]==null || _hPriceMatrixValues[pUniqueID]==""){
				_hPriceMatrixValues[pUniqueID] = new Array(0);
			}
				
			_hPriceMatrixValues[pUniqueID][_hPriceMatrixValues[pUniqueID].length] = {};
			var h = _hPriceMatrixValues[pUniqueID][_hPriceMatrixValues[pUniqueID].length-1];
			h[_PriceMatrixText] = pText;
			h[_PriceMatrixValue] = pValue;
			h[_PriceMatrixId] = pID;
			_hPriceMatrixValues[pUniqueID][_hPriceMatrixValues[pUniqueID].length-1] = h;
		break;
		
		case "text":
		case "hidden":
			_hPriceMatrixValues[pUniqueID] = {};
			var h = _hPriceMatrixValues[pUniqueID];
			h[_PriceMatrixText] = pText;
			h[_PriceMatrixValue] = pValue;
			h[_PriceMatrixId] = pID;
			_hPriceMatrixValues[pUniqueID] = h;
		break;
	}
	
}
function ShoppingCartValueSet(pControlSource,pControlTargetName0,pControlTargetName1,pFormName){
	var aValue = pControlSource.options[pControlSource.selectedIndex].value.split("|");
	document.forms[pFormName].elements[pControlTargetName0].value = aValue[0];
	document.forms[pFormName].elements[pControlTargetName1].value = aValue[1];
}

function ShoppingCartShippingProcess(pContainerID,pSendLocationID){
	var SendLocationID = pSendLocationID || "";
	try{
		var fInfo = document.forms[0];
		
		var inputs = document.getElementsByTagName("input")
		for(var i=0;i<inputs.length;i++){
			if(inputs[i].name.startWith("Shipping")){
				inputs[i].onkeyup = function() {ShoppingCartShippingSet(inputs,null,pContainerID);};
			}
		}
		fInfo.onsubmit = function() {ShoppingCartShippingSet(inputs,true,pContainerID);};
		fInfo.elements["cmsSendLocation"][0].onclick = function() {ShoppingCartShippingShow(inputs,pContainerID);};
		fInfo.elements["cmsSendLocation"][1].onclick = function() {ShoppingCartShippingShow(inputs,pContainerID);};
		
		
		//For check box
		if(SendLocationID!=""){
			try{
				fInfo.elements["cmsSendLocationChk"].checked = document.forms[0].elements["cmsSendLocation"][1].checked;
				fInfo.elements["cmsSendLocationChk"].onclick = function() {ShoppingCartShippingChkOnClick(inputs,pContainerID);};
				document.getElementById("cc"+SendLocationID).className="hidden";
			}catch(e){}
		}
		
		
		ShoppingCartShippingSet(inputs,null,pContainerID);
	}catch(e){}
}

function ShoppingCartShippingChkOnClick(pInputs,pContainerID){
	var fInfo = document.forms[0];
	fInfo.elements["cmsSendLocation"][1].checked = fInfo.elements["cmsSendLocationChk"].checked;
	fInfo.elements["cmsSendLocation"][0].checked = !fInfo.elements["cmsSendLocation"][1].checked
	ShoppingCartShippingShow(pInputs,pContainerID);
}

function ShoppingCartShippingShow(pInputs,pContainerID){
	try{
		var className = document.getElementById("cc"+pContainerID).className;
		if(className.indexOf("hidden")>-1){
			className = className.replaceAll("hidden","").trimAll();
			className += " visible";
		}else{
			className = className.replaceAll("visible","").trimAll();
			className += " hidden";
			for(var i=0;i<pInputs.length;i++){
				if(pInputs[i].name.startWith("Shipping"))
					pInputs[i].value="";
			}
		}
		document.getElementById("cc"+pContainerID).className = className;
	}catch(e){}
}

function ShoppingCartPaymentHandle(pContainerID,pContainerInProcessID){
	ShoppingCartVisibilityToggle(pContainerInProcessID);
	var fInfo = document.forms[0];
	fInfo.onsubmit = function() {ShoppingCartPaymentInProcess(pContainerID,pContainerInProcessID);};
}
function ShoppingCartPaymentInProcess(pContainerID, pContainerInProcessID){
	ShoppingCartVisibilityToggle(pContainerID);
	ShoppingCartVisibilityToggle(pContainerInProcessID);
}
function ShoppingCartVisibilityToggle(pContainerID){
	try{
		var className = document.getElementById("cc"+pContainerID).className;
		if(className.indexOf("hidden")>-1){
			className = className.replaceAll("hidden","").trimAll();
			className += " visible";
		}else{
			className = className.replaceAll("visible","").trimAll();
			className += " hidden";
		}
		document.getElementById("cc"+pContainerID).className = className;
	}catch(e){}
}

function ShoppingCartShippingShow2(pInputs,pContainerID){
	try{
		if(document.getElementById("cc"+pContainerID).className=="hidden"){
			document.getElementById("cc"+pContainerID).className = "visible";
		}else{
			document.getElementById("cc"+pContainerID).className = "hidden";
			for(var i=0;i<pInputs.length;i++){
				if(pInputs[i].name.startWith("Shipping"))
					pInputs[i].value="";
			}
		}
	}catch(e){}
}

function ShoppingCartShippingSet(pInputs,pForceEmptyOnly,pContainerID){
	try{
		var ForceEmptyOnly = pForceEmptyOnly || false;
		var iIndex = 0;
		for(var i=0;i<pInputs.length;i++){
			if(pInputs[i].name.startWith("Shipping") && pInputs[i].value!=""){
				iIndex = 1;
			}
		}
		if(!(iIndex==1&&ForceEmptyOnly) && document.forms[0].elements["cmsSendLocation"][1].checked!="checked"){
			document.forms[0].elements["cmsSendLocation"][iIndex].checked="checked";
			ForceEmptyOnly=false;
		}
			
		if(!ForceEmptyOnly){
			if(iIndex==1)
				document.getElementById("cc"+pContainerID).className = "visible";
			else
				document.getElementById("cc"+pContainerID).className = "hidden";
		}
	}catch(e){}
}

function trimAll(sString){
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}


function FF_ShoppingCartShippingModeSave(pControlSource){
	var sAction = "cmsShoppingCartManagement.aspx" + CMSBaseParamGet()
	sAction += "&" + pControlSource.name + "=" + pControlSource.options[pControlSource.selectedIndex].value;
	
	this.FormSubmit(this.ActionShoppingCartShippingModeSave,sAction);
}

function FF_ShoppingCartProductAdd(pItemID,pIsCallByProduct,pShoppingCartProductID){
	var bCallByProduct = pIsCallByProduct || false;
	var sShoppingCartProductID = pShoppingCartProductID || "";
	
	var sTarget = "";
	var sAction = "cmsShoppingCartManagement.aspx";
	if(bCallByProduct){
		if(isShoppingCartFrameExist()){
			sTarget = "frmShoppingCart";
		}
		else{
			sTarget = ShoppingCartRedirectFrame;
			sAction = ShoppingCartRedirectPage;
		}
	}
	sAction += CMSBaseParamGet() + "&ItemID=" + pItemID
	if(sShoppingCartProductID!="")
		sAction += "&ShoppingCartID=" + sShoppingCartProductID;
	sAction += "#ref" + pItemID
	
	try{
		var cmsForm = document.forms[this.FormName];
		var myForm = document.forms['f'+pItemID];
		
		for(var i = 0; i < myForm.elements.length; i++){
			var name = myForm.elements[i].getAttribute("name");
			for(var j = 0; j < cmsForm.elements.length; j++){
				if(cmsForm.elements[j].name == name)
					cmsForm.removeChild(cmsForm.elements[j]);
			}
			var el = myForm.elements[i].cloneNode(true);
			if(el.type=="select-one")
				el.selectedIndex = myForm.elements[i].selectedIndex;
			cmsForm.appendChild(el)
		}
	}catch(e){
		/*alert(e.name);
		alert(e.description);
		alert(e.number);
		alert(e.message);*/
	}
	this.FormSubmit(this.ActionShoppingCartProductAdd,sAction,sTarget);
}

function FF_ShoppingCartProductDelete(pItemID, pAll){
	var bDeleteAll = pAll || false;
	var Action = this.ActionShoppingCartProductDelete;
	if(bDeleteAll)
		Action = this.ActionShoppingCartProductDeleteAll
		
	this.FormSubmit(Action,"cmsShoppingCartManagement.aspx" + CMSBaseParamGet() + "&ItemID=" + pItemID + "#ref" + pItemID);
	
}

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,this.FormActionDefault,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,this.FormActionDefault,sTarget);
}

function FF_ShoppingCartMinimize(){
	var sTarget = ShoppingCartRedirectFrame;
	var sAction = ShoppingCartRedirectPage + CMSBaseParamGet();

	this.FormActionDefault = sAction;
	this.FormSubmit(this.ActionShoppingCartMinimize,this.FormActionDefault,sTarget);
}
function FF_ShoppingCartCheckOut(){
	var sTarget = "frmContent";
	var sAction = "cmsShoppingCartManagement.aspx" + CMSBaseParamGet();
	
	this.FormActionDefault = sAction;
	this.FormSubmit(this.ActionShoppingCartCheckOut,this.FormActionDefault,sTarget);
}

function FF_ShoppingCartClient(){
	this.FormActionDefault = "cmsShoppingCartManagement.aspx?Lang=" + this.language + "&ParentID=CMSShoppingCart";
	this.FormSubmit("",this.FormActionDefault);
}

function FF_ShoppingCartPayment(){
	this.FormActionDefault = "cmsShoppingCartManagement.aspx?Lang=" + this.language + "&ParentID=CMSShoppingCart&SectionID=T0602C30838PB1421PM";
	this.FormSubmit("",this.FormActionDefault);
}

function FF_ShoppingCartAccept(){
	this.FormActionDefault = "cmsShoppingCartManagement.aspx" + CMSBaseParamGet();
	this.FormSubmit(this.ActionShoppingCartAccept,this.FormActionDefault,"_self");
}
function FF_ShoppingCartPrint(){
	var domain = document.location.href.substring(0,document.location.href.lastIndexOf("/") + 1).replaceAll("https://","http://");
	this.FormActionDefault = "cmsShoppingCartManagement.aspx?Lang=" + this.language;
	try{
		this.FormActionDefault = domain + this.FormActionDefault;
		this.FormSubmit(this.ActionShoppingCartPrint,this.FormActionDefault,"_new");
	}
	catch(e){
		this.FormActionDefault = domain.replaceAll("http://","https://") + this.FormActionDefault;
		this.FormSubmit(this.ActionShoppingCartPrint,this.FormActionDefault,"_new");
	}
}

function FF_ShoppingCartCustomInfo(){
	var sAction = "cmsShoppingCartManagement.aspx" + CMSBaseParamGet();
	
	this.FormActionDefault = sAction;
	this.FormSubmit(this.ActionShoppingCartCustomInfo,this.FormActionDefault,"_self");
}
function FF_ShoppingCartCustomInfoSave(){
	var sAction = "cmsShoppingCartManagement.aspx" + CMSBaseParamGet();
	
	this.FormActionDefault = sAction;
	this.FormSubmit(this.ActionShoppingCartCustomInfoSave,this.FormActionDefault,"_self");
}


function FF_ShoppingCartSend(){
	this.FormActionDefault = top.myFunction.FormActionDefault;
	this.FormSubmit(this.ActionSendByEmail,this.FormActionDefault);
}

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){
	var cmsForm = document.forms["cmsFormControl"];
	cmsForm.elements["cmsContainerID"].value = p_strContainerID;
	cmsForm.elements["cmsFirst"].value = First;
	
	var strAction  = cmsForm.action || "";
	if(strAction=="")
		strAction = this.UrlModeValidate(top.myFunction.FormActionDefault,p_strContainerID,'CONTAINER');
	if(p_strContainerID!="")
		strAction += "#ref" + p_strContainerID;
		
	var form = document.forms["CONTAINER_" + p_strContainerID];
	try{
		for(var i = 0; i < form.elements.length; i++){
			if(form.elements[i].type == "hidden"){
				var name = form.elements[i].name;
				
				var exists = false;
				for(var j = 0; j < cmsForm.elements.length; j++){
					if(cmsForm.elements[j].name == name)
						exists = true;
				}
				if(!exists){
					cmsForm.innerHTML += "<input type=\"hidden\" name=\"" + name + "\" value=\"" + form.elements[i].value + "\">";
				}
			}
		}
	}catch(e){}
	

	cmsForm.action = strAction;
	cmsForm.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 log(pPageName,pPageUrl,pPageID,pLevel,pAddToPath){
	var url = pAddToPath + "cmsLog.aspx?PageName=" + pPageName + "&PageUrl=" + encode(pPageUrl) + "&PageID=" + pPageID + "&PageLevel=" + pLevel;
	if(_logNavPath!=""){
		url += "&PageNavPath=" + _logNavPath;
		_logNavPath = "";
	}
	url += "&uId=" + Math.random()*4;
	document.images.imgLog.src = url;
}
var _logNavPath = "";
function logNavPath(pPageName){
	if(_logNavPath!="")
		_logNavPath += "/";
	_logNavPath += pPageName;
}

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) {
	alert('asdasd');
	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;
}

/* Cookie */
function setCookie(name, value, exp_y, exp_m, exp_d, path, domain, secure){
	var cookie_string = name + "=" + escape ( value );

	if(exp_y){
		var expires = new Date ( exp_y, exp_m, exp_d );
		cookie_string += "; expires=" + expires.toGMTString();
	}

	if(path)
		cookie_string += "; path=" + escape ( path );

	if(domain)
		cookie_string += "; domain=" + escape ( domain );
  
	if(secure)
		cookie_string += "; secure";
  
	document.cookie = cookie_string;
}

function getCookie(cookie_name){
	var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

	if(results)
		return (unescape(results[1]));
	else
		return null;
}

function deleteCookie(cookie_name){
	var cookie_date = new Date();
	cookie_date.setTime(cookie_date.getTime() - 1);
	document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function helpOpen(pHref){
	var iWidth = "400";
	var sParameters = "resizable=no,toolbar=no,scrollbars=yes,status=no";
	sParameters +=  ",width=" + iWidth;
	var win = window.open(pHref, "Help",sParameters);
	win.moveTo(screen.availWidth-iWidth,0);
	win.focus();
}
/* Cookie */

/* DateDiff */
function StringToDate(pDate){
	var d = new Date();
	d.setYear(pDate.substring(0,4));
	d.setMonth(pDate.substring(5,7)-1);
	d.setDate(pDate.substring(8,10));
	d.setHours(pDate.substring(11,13));
	d.setMinutes(pDate.substring(14,16));
	d.setSeconds(pDate.substring(17,19));
	return d
}


function dateDiff(pDate1, pDate2) {
	date1 = pDate1;
	date2 = pDate2;
	diff  = new Date();

	diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

	timediff = diff.getTime();

	weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
	timediff -= weeks * (1000 * 60 * 60 * 24 * 7);

	days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
	timediff -= days * (1000 * 60 * 60 * 24);

	hours = Math.floor(timediff / (1000 * 60 * 60)); 
	timediff -= hours * (1000 * 60 * 60);

	mins = Math.floor(timediff / (1000 * 60)); 
	timediff -= mins * (1000 * 60);

	secs = Math.floor(timediff / 1000); 
	timediff -= secs * 1000;
	var dif = "";
	if(weeks>0){
		dif = weeks + " semaine";
		if(weeks>1)
			dif += "s";
	}
	if(days>0){
		if(dif!="")
			dif += ", ";
		dif += days + " jour";
		if(days>1)
			dif += "s";
	}
		
	if(hours>0 || mins>0 || secs>0){
		if(dif!="")
			dif += ", ";
		dif += hours + "h " + mins + "min " + secs + " sec";
	}
	
	return dif;
}

/* IFrame */
function getIFrameDoc(pIFrame){
	var IFrameDoc;
	if (pIFrame.contentDocument) {
		// For NS6
		IFrameDoc = pIFrame.contentDocument; 
	} else if (pIFrame.contentWindow) {
		// For IE5.5 and IE6
		IFrameDoc = pIFrame.contentWindow.document;
		} else if (pIFrame.document) {
			// For IE5
			IFrameDoc = pIFrame.document;
		} 

	return IFrameDoc;
}