///////////////////////////////////////////////////////////////////////
//     25/09/2003                                                    //
//                                                                   //
//     This script was designed by Avi Ben Shoshan			         //
//                                                                   //
//     This Script Icludes General JS Function For The Project	     //
///////////////////////////////////////////////////////////////////////

function OpenPopUp(sPath,sLeft,sTop,sWidth,sHeight)
{
	var winHandle;
	var sHtml;
	winHandle = window.open(sPath,'PopUp','width='+ sWidth +',height='+ sHeight +',top='+ sTop +',left='+ sLeft +',scrollbars=1,status=1');
	winHandle.focus();
}

// ---- Function To Return Selected Posting Or Channel In CMS
// Return Value - The Selected Item
//var strAppPath = Request.ApplicationPath;
//var strExistingTarget ='קיים נתיב';
//var strTitle = 'נושא';
//var strSubTitle = 'תת נושא';
//var iDialogType = סוג תיבת הדו-שיח :
//		0 - Channels Dialog : Default
//		1 - Templates Dialog
//		2 - Reasource Dialog
//		3 - All
function onClickBrowse(strAppPath,strExistingTarget,strTitle,strSubTitle,iDialogType)
{

	// for Internal Links dialog
	var IDS_DEFAULT_OPEN_POSITION = ",dialogTop=50,dialogWidth=300"
	var IDS_WIN_INTLINKS_FEATURES = "width=450,height=500" + IDS_DEFAULT_OPEN_POSITION;
	var IDS_IEWIN_INTLINKS_FEATURES = "dialogWidth:450px;dialogHeight:500px;status:yes" + IDS_IE_DIALOG_DEFAULT_POSITION;
	// IE Modal/Modeless dialog will use this string
	var IDS_IE_DIALOG_DEFAULT_POSITION = ",dialogTop=50,dialogWidth=300"

	//  args = "ExistingTarget;Title;SubTitle"
	var aAttributes = new Array();
	aAttributes[0] = strExistingTarget;
	aAttributes[1] = strTitle;
	aAttributes[2] = strSubTitle;

	try
	{
		if(iDialogType >=0){}
		else
		iDialogType = '0'; // Default Value
	}
	catch(e){iDialogType = '0';} // Default Value
	// Call InternalLinks.aspx with "wbc_caller=IEModal" query string to indicate that
	// we called it with IE's showModalDialog() call instead of JavaScript window.open()
	// Also, need to set NRMODE to Unpublished in order for the tree to display offline objects
	var strDlgRet = window.showModalDialog(strAppPath + "/CmsManagment/InternalLinks/InternalLinks.aspx" + "?NRMODE=Unpublished&wbc_caller=IEModal&DlgMode=" + iDialogType, 
												aAttributes, IDS_IEWIN_INTLINKS_FEATURES);
	if (strDlgRet != "Cancel")
	{
		return strDlgRet;
	}
}

// ---- Function To Return Selected MetaTable From MetaTables Values
// Return Value - The Selected Item
//var strAppPath = Request.ApplicationPath;
//var strExistingTarget ='קיים נתיב';
//var strTitle = 'נושא';
//var strSubTitle = 'תת נושא';
//var iDialogType = סוג תיבת הדו-שיח :
//		0 - Channels Dialog : Default
//		1 - Templates Dialog
//		2 - Reasource Dialog
//		3 - All
function selectMetaTable(strAppPath)
{

	// for Internal Links dialog
	var IDS_DEFAULT_OPEN_POSITION = ",dialogTop=50,dialogWidth=300"
	var IDS_WIN_INTLINKS_FEATURES = "width=550,height=450" + IDS_DEFAULT_OPEN_POSITION;
	var IDS_IEWIN_INTLINKS_FEATURES = "dialogWidth:650px;dialogHeight:450px;status:yes" + IDS_IE_DIALOG_DEFAULT_POSITION;
	// IE Modal/Modeless dialog will use this string
	var IDS_IE_DIALOG_DEFAULT_POSITION = ",dialogTop=50,dialogWidth=300"

	try
	{
		if(iDialogType >=0){}
		else
		iDialogType = '0'; // Default Value
	}
	catch(e){iDialogType = '0';} // Default Value
	// Call InternalLinks.aspx with "wbc_caller=IEModal" query string to indicate that
	// we called it with IE's showModalDialog() call instead of JavaScript window.open()
	// Also, need to set NRMODE to Unpublished in order for the tree to display offline objects
	var strDlgRet = window.showModalDialog(strAppPath + "/CmsManagment/MetaData/GenMetaDataSelectTables.aspx" + "?wbc_caller=IEModal&DlgMode=" + iDialogType, 
												'', IDS_IEWIN_INTLINKS_FEATURES);
	if (strDlgRet != "Cancel")
	{
		return strDlgRet;
	}
}

// ---- Function To print a warning DIV when MSIE-Popup blocker, blocks a JS - window.open() 
function createPopupDiv()
{
	var objDiv = document.createElement('div'); 
	objDiv.id="divExplain";
	objDiv.style.borderRight="navy 4px solid";
	objDiv.style.borderLeft="navy 4px solid";
	objDiv.style.borderBottom="navy 4px solid";
	objDiv.style.borderTop="navy 4px solid";
	objDiv.style.left="250px";
	objDiv.style.top="180px";
	objDiv.style.position="absolute";
	objDiv.style.backgroundColor="white";
	objDiv.style.color="navy";
	
	objDiv.style.width="408";
	objDiv.style.height="180";
   	objDiv.style.visibility="visible";
   	

   	objDiv.innerHTML = "<table>" +
	"<tr><td width='25' height='25' style='BORDER-RIGHT: 2px solid; BORDER-TOP: 2px solid; BORDER-LEFT: 2px solid; BORDER-BOTTOM: 2px solid; BACKGROUND-COLOR: silver' align='right' handlefor='divExplain' class='handle'><IMG src='../Images/PopupAllow.gif' align='middle' width='27' height='25' ></td>" +
		"<td style='BORDER-RIGHT: 2px solid; BORDER-TOP: 2px solid; BORDER-LEFT: 2px solid; BORDER-BOTTOM: 2px solid' align='center' handlefor='divExplain' class='handle' width='300'>&nbsp;<b>Microsoft - Pop-ups Blocker</b></td>" +
		"<td width='25' height='25' style='BORDER-RIGHT: 2px solid; BORDER-TOP: 2px solid; BORDER-LEFT: 2px solid; BORDER-BOTTOM: 2px solid; BACKGROUND-COLOR: silver' align='right' onmousemove='this.style.cursor=\"hand\";' onmouseout='this.style.cursor=\"default\";'><IMG alt='סגור' onclick='divExplain.style.visibility=\"hidden\";;' src='../Images/Close.gif' align='middle' width='25' height='25'></td>" +
	"</tr>" +
	"<TR><TD style='FONT-SIZE: 5px' colSpan='2'>&nbsp;</TD></TR>" +
	"<TR><TD dir='rtl' colSpan='2'>גרסת הדפדפן שברשותכם מונעת פתיחת</TD></TR>" +
	"<TR><TD dir='rtl' colSpan='2'>&nbsp;&nbsp;&nbsp; 'חלונות קופצים' !</TD></TR>" +
	"<TR><TD style='FONT-SIZE: 8px' colSpan='2'>&nbsp;</TD></TR>" +
	"<TR><TD dir='rtl' colSpan='2'>בכדי לאפשר פעילות זו עליכם :</TD></TR>" +
	"<TR><TD style='FONT-SIZE: 5px' colSpan='2'>&nbsp;</TD></TR>" +
	"<TR><TD dir='rtl' vAlign='middle' colSpan='2'>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;ללחוץ על הצלמית &nbsp;<IMG style='WIDTH: 30px; HEIGHT: 25px' src='../Images/PopUp.gif'>&nbsp;בראש הדפדפן .</TD></TR>" +
	"<TR><TD dir='rtl' vAlign='middle' colSpan='2'>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;לבחור ב : '... Always Allow Pop-ups From This Site ' .</TD></TR>" +
	
	"<TR><TD dir='rtl' vAlign='middle' colSpan='2'>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;או ב : 'Temporarily Allow Pop-ups' .</TD></TR>" +
	"<TR><TD dir='rtl' vAlign='middle' colSpan='2'>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;בהצלחה .	</TD></TR>" +
	"<TR><TD style='FONT-SIZE: 10px' colSpan='2'>&nbsp;</TD></TR>" +
	"<TR><TD style='FONT-SIZE: 10px;BORDER-RIGHT: 2px solid; BORDER-TOP: 2px solid; BORDER-LEFT: 2px solid; BORDER-BOTTOM: 2px solid' colSpan='3'>&nbsp;</TD></TR>" +
	"</table>";
	
	try
	{
		var pageForm = document.forms[0];
		if (typeof(pageForm) == "undefined")
			document.body.appendChild(objDiv);
		else
			pageForm.appendChild(objDiv);
	}
	catch(ex)
	{
		document.body.appendChild(objDiv);
	}
}
			
// create the prototype on the String object
String.prototype.trim = function() 
{
 // skip leading and trailing whitespace
 // and return everything in between
  var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}			