function pcs_getCookie(strName) {
	var rgCookies= document.cookie.split("; ");
	for (var i= 0; i < rgCookies.length; i++) {
		var aCrumb= rgCookies[i].split("=");
		if (aCrumb[0] == strName) {
			return unescape(aCrumb[1]);
		}
	}
	return "";
}

function pcs_setCookie(strName, strValue) {
	document.cookie= strName + "=" + escape(strValue) + ";expires=" + pcs_getExpiredDateString() + ";";
}

function pcs_getExpiredDateString() {
	var cur_date= new Date();
	var year= cur_date.getFullYear()
	var month= cur_date.getMonth() + 1;
	var day= cur_date.getDate();
	var exp_date= new Date(year, month, day);
	return exp_date.toUTCString();
}

function pcs_ToggleZone(strZoneID, strImgID, strDashID, bFlag) {
	var oZone= document.all[strZoneID];
	var oImg= document.all[strImgID];
	if (oZone == null || oImg == null) return;
	var strDisplay= pcs_getCookie("ZoneDisplay_" + strDashID);
	if (strDisplay == "") strDisplay= "block";
		
	if (bFlag == null) {
		if (strDisplay == "block") strDisplay= "none";
		else strDisplay= "block";
	}
		
	oZone.style.display= strDisplay;
	pcs_setCookie("ZoneDisplay_" + strDashID, strDisplay);
		
	if (strDisplay == "block") oImg.src = '~/Images/Kernel/Colapse_Left.gif';
	else oImg.src = '~/Images/Kernel/Expand_Left.gif';
}

function pcs_Start() {
	try {
		var vs= document.all["__VIEWSTATE"];
		window.status= "ViewState: ";
	} catch (e) {}
}

function OpenPermissionManager(Value, Name, Source, SubSource, ShowRights) {
	if (ShowRights == null) ShowRights= true;
	var strQuery= "AGP.Net/Components/PermissionManager/PermissionManagerForm.aspx?ObjectValue=" + Value + "&Name=" + Name + "&Source=" + Source + "&SubSource=" + SubSource;
	if (typeof(WorkspaceUrl) != "undefined") strQuery= WorkspaceUrl + strQuery;
	if (ShowRights == false) strQuery+= "&ShowRights=0";
	return window.showModalDialog(strQuery, "", "font-family:Verdana; font-size:12; dialogHeight:445px;dialogWidth:600px;status:no;help:no;scroll:no;");
}

function OpenPartStorageManager(WorkspaceRoot, wpID, IsEditMode) {
	var strControlUrl= WorkspaceRoot + "AGP.Net/Components/AdvPortalManager/PartStorageEditor/PartStorageControl.ascx";
	var query= "wpID=" + wpID;
	if (IsEditMode == true) query+= "&edit=1";
	var res= res_RunModalControl(WorkspaceRoot, strControlUrl, 750, 550, query, "Part Storage Editor");
	return (res == true);
}
