//Navigates to chosen URL for Multilanguage Button and Image controls
function NavigateTo(url)
{
	if(url != "")
		document.location = url;
	else
		return;
}
// s: ServiceSearch.ascx
document.write('<div id="tooltip" style="Z-Index:2000; BORDER-RIGHT: #666666 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #666666 1px solid; PADDING-LEFT: 1px; VISIBILITY: hidden; PADDING-BOTTOM: 1px; FONT: 12px Arial,Helvetica,sans-serif; BORDER-LEFT: #666666 1px solid; COLOR: #333333; PADDING-TOP: 1px; BORDER-BOTTOM: #666666 1px solid; POSITION: absolute; BACKGROUND-COLOR: #ffffcc; layer-background-color: #ffffcc"></div>');
var posX = 0;
var posY = 0;
var AdvancedSearchImagePath = "";

function DisableDiv()
{
	document.getElementById("SearchTable").style.display = 'none';
	//document.getElementById("lblWait").style.display = 'block';
}

function showToolTip(x)
{
	
    var lobjCurrentDropdown = window.event.srcElement;
    posX = getX(lobjCurrentDropdown);
    posY = getY(lobjCurrentDropdown);
    
    if (x==1) //A tooltip must be shown
    {    
		if (lobjCurrentDropdown.length > 0)
		{
			if (lobjCurrentDropdown.selectedIndex >= 0)
				document.all.tooltip.innerHTML = lobjCurrentDropdown.options[lobjCurrentDropdown.selectedIndex].text;
			else
			{
				document.all.tooltip.innerHTML = '';
				document.all.tooltip.style.visibility = "hidden";
			}
		}
		else 
		{
			document.all.tooltip.innerHTML = '';
			document.all.tooltip.style.visibility = "hidden";
		}	
        
        document.all.tooltip.style.left = posX + 2;
        document.all.tooltip.style.top = posY - 20;
        document.all.tooltip.style.visibility = "visible";
    }
    else
    { //A tootip must not be shown
        document.all.tooltip.style.visibility = "hidden";
    }
}

function getX(obj){
    return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );
}
function getY(obj)
{
    return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );
}
// e: ServiceSearch.ascx

function submitenter(e)
{
	var keycode;

	if(window.event) 
		keycode = window.event.keyCode;
	else if(e) 
		keycode = e.which;
	else 
		return true;

	if (keycode == 13)
		return false;
	else
		return true;
}
// s: Linkers
function OpenPostingPickerPopUp(rootPath,CTLid)
{ 
	//alert(rootPath);
	url="/ClalitCMS/Controls/LinkagePickerPopUp.aspx?multiSelect=true&parentID="+ CTLid +"&rootPath="+rootPath;
			
	winId = window.open(url,"LinksPicker","height=600,width=500,left=100,top=100,scrollbars=1;status=0,menubar=0");
	if (window.newWin)
			   newWin.focus();
}

function OpenChannelPickerPopUp()
{ 

	url="/ClalitCMS/Controls/ChannelPickerPopUp.aspx?multiSelect=true";
			
	winId = window.open(url,"LinksPicker","height=600,width=500,left=100,top=100,scrollbars=1;status=0,menubar=0");
	if (window.newWin)
			   newWin.focus();

}

function OpenNewPostingsPickerPopUp(CTLid)
{ 
	alert(CTLid);
	
	url="/ClalitCMS/Controls/NewPostingsPicker.aspx?multiSelect=true&parentID="+ CTLid;
			
	winId = window.open(url,"NewPostingsPicker","height=600,width=900,left=100,top=100,scrollbars=1;status=0,menubar=0");
	if (window.newWin)
		 newWin.focus();
}

function SetChosenChannels(sGuids, parentID)
{	
	document.getElementById(parentID+"_txtSelectedGuids").value=sGuids;
	document.getElementById(parentID+"_btnUpdateSelectedLinks").click();

	winId=null;
}
function SetControlsMode(obj)
{
	if (typeof(curtxtWinWidth)!="undefined")
	{
		oControl=eval('document.all.'+curtxtWinWidth);
		
		if (obj.selectedIndex==0)
			oControl.disabled=false;
		else
			oControl.disabled=true;			
	}
	if (typeof(curtxtWinHeight)!="undefined")
	{
		oControl=eval('document.all.'+curtxtWinHeight);
		if (obj.selectedIndex==0)
			oControl.disabled=false;
		else
			oControl.disabled=true;	
											
	}			
}
function SetChosenItem(sGuids,sTitle,sUrl)
{
	if (typeof(curtxtLink)!="undefined")
	{
		oControl=eval('document.all.'+curtxtLink);
		oControl.value=sUrl;
	}
	if (typeof(curtxtToolTip)!="undefined")
	{
		oControl=eval('document.all.'+curtxtToolTip);
		oControl.value=sTitle;
	}
	if (typeof(curtxtDisplayName)!="undefined")
	{
		oControl=eval('document.all.'+curtxtDisplayName);
		oControl.value=sTitle;
	}
	if (typeof(curtxtGuid)!="undefined")
	{
		oControl=eval('document.all.'+curtxtGuid);
		oControl.value=sGuids;
		
	}
	if (typeof(curchkIsBold)!="undefined")
	{
		oControl=eval('document.all.'+curchkIsBold);
		oControl.value=sGuids;
		
	}
	winId=null;
}
function OpenLinkPopup(LinksSiteRootPath)
{
	rootPath = LinksSiteRootPath;
	
	//alert(rootPath);
	
	url="/ClalitCMS/Controls/LinkagePickerPopUp.aspx?multiSelect=false&rootPath="+rootPath;
	//alert(url);
	winId = window.open(url,"PostingPicker","height=600,width=500,left=100,top=100,scrollbars=1;status=0,menubar=0");
	//winId = window.open("<%=Request.ApplicationPath%>/Controls/HyperLinkPopUp.aspx" ,"HyperLinkPopUp","height=600,width=500,left=100,top=100,scrollbars=1;status=0,menubar=0");
	

}
function SetSelectedUrl(strURL)
{
	
	if (typeof(curUrlTextBox)!="undefined")
	{
		oControl=eval('document.all.'+curUrlTextBox);
		oControl.value=strURL;
	}
}
function SetNewSortingOrder(itemsSortArr, parentID)
{
	document.getElementById(parentID+"_txtLinksOrderArr").value=itemsSortArr;
	document.getElementById(parentID+"_btnChangeLinksSortOrder").click();
		
	winId=null;

}
function EditRow(ParentID, NodeID,Guid,ItemTitle, LinkUrl, ToolTip, WindowType,sWidth,sHeigth)
{
	document.getElementById(ParentID +"_EditModeTR").style.display = "block";
	document.getElementById(ParentID +"_EditModeTR").scrollIntoView();
	
	document.getElementById(ParentID +"_txtGuid").value = Guid;
	document.getElementById(ParentID +"_txtNodeID").value = NodeID;
	document.getElementById(ParentID +"_txtDisplayName").value = ItemTitle;
	document.getElementById(ParentID +"_txtLink").value = LinkUrl;
	document.getElementById(ParentID +"_txtToolTip").value = ToolTip;
	
	
	var combo = document.getElementById(ParentID +"_ddlWindowType");
	

	for(var i=0; i < combo.options.length; i++)
	{
		if(WindowType == combo.options[i].value)
			combo.options.selectedIndex = i;
	}

	document.getElementById(ParentID +"_txtWinWidth").value = sWidth;
	document.getElementById(ParentID +"_txtWinHeight").value = sHeigth;

	
	//var response = LinkerAdvanced.EditRow(letter);    
}		
	
function RemoveRow(ParentID, NodeID)
{
	document.getElementById(ParentID +"_txtNodeID").value = NodeID;
	document.getElementById(ParentID +"_DeleteButton").click();
}
// e: Linkers

// s: Thumbnails.ascx
var imgButtonOn = new Image();
var imgButtonOff = new Image();

imgButtonOn.src = "/ClalitCMS/images/thumb_Button_over.gif";
imgButtonOff.src = "/ClalitCMS/images/thumb_Button.gif";

function Rollover(cellID, mode)
{
	var Cell = document.getElementById(cellID);
	if(Cell != "undefined")
	{
		if(mode == 'on')
			Cell.className='ThumbnailsCtlButton_over';
		else	
			Cell.className='ThumbnailsCtlButton';
	}
}
// e: Thumbnails.ascx
// s: WorldsMenu.ascx
function DoNav(theUrl)
{
	document.location.href = theUrl;  
}
// e: WorldsMenu.ascx

// s: WorldHomePageTemplate.aspx
//global param - holds the value of the click button
var clickedButtonId;
//called from the popup window (PostingPickerPopUp.aspx)

function SetChosenPosting(sChannels, callingTextboxId)
{	
	
	var TextBox = document.getElementById(callingTextboxId);
	if(TextBox)
	{
		TextBox.value=sChannels;
	}
	winId=null;
}

function OpenPostingPopUp(buttonId)
{
	clickedButtonId = buttonId;
	winId = window.open("/ClalitCMS/Popups/WorldMainArticlePickerPopUp.aspx","PostingPicker","height=600,width=500,left=100,top=100,scrollbars=1;status=0,menubar=0");
}
//property that return the id of the clicked button
function getClickButtonId()
{
    return clickedButtonId; 
}
// e: WorldHomePageTemplate.aspx

// s: SideBarImageLink.ascx
var win = null;
function OpenNewWindow(Wurl,Wheight,Wwidth)
{
	LeftPosition = (screen.width) ? (screen.width-Wwidth)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-Wheight)/2 : 0;
	
	settings = 'height='+Wheight+',width='+Wwidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=1,resizable=1,toolbars=0,statusbars=0,menubars=0'
	win = window.open(Wurl,"WWW",settings)

}
// e: SideBarImageLink.ascx
