/************Search Scope only************************/

function LogoImage()
{

       var pageurl =window.location.href;
      // alert(pageurl);
      				
		if(pageurl.indexOf('SearchResult.aspx')!= -1) 
		{		 
     //	 document.getElementById("ctl00_onetidHeadbnnr").src="http://www.cab.org.in/images/logo.gif";	      
     
         RemoveUserNameFromSearchResult();
         
		}
		
	
}
 function RemoveUserNameFromSearchResult() {
        try {
            var tempElements = document.getElementsByTagName('P');
            var TagFound;
            for (var Count = 0; Count < tempElements.length; Count++) {
                if (tempElements[Count].attributes['class'] != null) {
                    var CssClass = tempElements[Count].attributes['class'].value;
                    if (CssClass == 'srch-Metadata') {
                        try {
                            
                            var obj = tempElements[Count];
                            //alert(obj.innerText);
                            var where_is_closing = obj.innerHTML.lastIndexOf(">");
                            var tempstr = obj.innerHTML.substring(0, where_is_closing);
                            obj.innerHTML = tempstr;
                            
                        }
                        catch (ex) { }

                    }
                }
            }

        }
        catch (ex) {
            //alert(ex.message);
        }

    }


/************END of Search Scope only************************/







/* This function is added for hiding the breadcrum for 
 AuthenticationPages/Register.aspx and 
 AuthenticationPages/ForgotPassword.aspx pages-- added by susmita...*/

function func()
{	
var PageURL=window.location.href;

if(PageURL.indexOf("/AuthenticationPages/Register.aspx")!=-1)
	{
		document.getElementById("breadcrumb").style.display = "none";
	}
else if(PageURL.indexOf("/AuthenticationPages/ForgotPassword.aspx")!=-1)
	{
		document.getElementById("breadcrumb").style.display = "none";
	}
	
//hideContentviewpage();
}

function hideContentviewpage()
{
//alert(window.location);
var PageURL=window.location.href;

if(PageURL.indexOf('/layouts/viewlsts.aspx')!= -1) 
		{
		window.location="http://www.cab.org.in/default.aspx";
		}

} 

	function HideDiscussionForumToolBar()
	{			
		var TableArray = document.getElementsByTagName('table');		
		var TableFoundCount= 0;				
		
		for(var tableCount=0; tableCount<TableArray.length ; tableCount++ )
		{
			//Check For Left navigation with control Id 'CurrentNav'
			if( TableArray[tableCount].id.indexOf('toolBarTbl') != -1 ) 
			{ 
				// Control Find than increase Count.
				TableFoundCount ++;	
				//alert(TableArray[tableCount].id);
				var toolbar = document.getElementById(TableArray[tableCount].id);
				//alert(toolbar);
				toolbar.style.display = 'none';
				break;		
			}
			
			/*
			if(TableArray[tableCount].attributes['class']!=null)
	        { 
	    		var CssClass = TableArray[tableCount].attributes['class'].value;	          				
	    		if(CssClass =='ms-MenuUIItemTable') 
			    {	
			    	var MenuTable = TableArray[tableCount];
			    	var MenuInnerHtml = MenuTable.innerHTML;
			    	alert(MenuInnerHtml);
			    }
			 }
			 */ 			
		}
		
		HideViewPropertiesLink();
		HideReplylinkafterlogin();

		//HideModifySharedWebPart();
		//RemoveLinktoItem();
		//RemoveGroupByLinktoItem();

		
		
	}		
	
//	ms-MenuUIItemTableCell
//mp1_0_3
	  // This function is to increase the width of the Advance Serach Page Results Search Control Table Width.
 /*	  function HideViewPropertiesLink()
	{			
		var AnchorTagArray = document.getElementsByTagName('A');		
		var TagFound;		
		
		for(var Count=0; Count<AnchorTagArray.length ; Count++ )
		{
			var obj = AnchorTagArray[Count];     
            var id = obj.id;
			if( id.indexOf('DisplayLink') != -1 ) 
			{ 				
				TagFound = document.getElementById(id);		
				TagFound.style.display = 'none';
			}			
		}		
	}

	*/
		///// function Return By Harshal Desai - 16-11-2009
	/// To SHOW the Login/Signin alert message image.
	//// Befor login it prompt message of user login.
   function HideViewPropertiesLink()
	{			
		var AnchorTagArray = document.getElementsByTagName('A');		
		var TagFound;		
		
		for(var Count=0; Count<AnchorTagArray.length ; Count++ )
		{
			var obj = AnchorTagArray[Count];     
            var id = obj.id;  
                             
		 	if( id.indexOf('DisplayLink') != -1) 
			{ 		
					TagFound = document.getElementById(id);		
					var ParentId = TagFound.parentNode;
						
					TagFound.style.display = 'none';
				
	
					var anchorTag =document.createElement("a");
					anchorTag.id = "ReplyImage"+ Count;
					anchorTag.setAttribute("onClick", "alert('Plese login/signin to Reply this Post.'); return false;");
					anchorTag.setAttribute("title", "ReplayImage");
					anchorTag.setAttribute("href","javascript:alert('Plese login/signin to Reply this Post.'); ");
					anchorTag.style.display="block";
					
					ParentId.appendChild(anchorTag);
				    //Assign different attributes to the element.							
					var replyImage = document.createElement("img");
	
				    replyImage.setAttribute("src", "http://www.cab.org.in/_layouts/images/reply.gif");
				    replyImage.setAttribute("name", "replayimage");
					replyImage.setAttribute("border", "0");
				 
				    //Append the element in page (in span).
				    anchorTag.appendChild(replyImage );	
							
					
					var spaceTxt = document.createTextNode(" ");
					anchorTag.appendChild(spaceTxt); 
					
					var replayTextTag = document.createElement("nobr");
					anchorTag.appendChild(replayTextTag);		
					
					var boldText = document.createElement("b");
					replayTextTag.appendChild(boldText); 
	
					var txt = document.createTextNode("Reply");
					boldText.appendChild(txt); 		
			}			
		}			
	}
	
		
//// function Return By Harshal Desai - 16-11-2009
/// To Hide the Login/Signin alert message image.
////After login user can redirect to Reply post page. 
	
function HideReplylinkafterlogin()
	{			
		var AnchorTagArray = document.getElementsByTagName('A');		
		var tagReplyFound='false';
		for(var Count=0; Count<AnchorTagArray.length ; Count++ )
		{
			var obj = AnchorTagArray[Count];     
            var id = obj.id;  
		 	if( id.indexOf('ReplyLink') != -1)
			{ 		
				tagReplyFound= 'true';
				
			}	
			if( id.indexOf('DisplayLink') != -1)
			{ 		
				tagDisplayFound = 'true';
				
			}			
		}
		if(tagReplyFound == 'true')
		{			
			var imgTagArray = document.getElementsByTagName('A');		
			var TagFound;	
			for(var imgCount=0; imgCount<imgTagArray.length ; imgCount++ )
			{	var obj_img = imgTagArray[imgCount];     
	            var id_img = obj_img.id;  
	                       
			 	if( id_img.indexOf('ReplyImage') != -1)
				{ 		
						TagFound = document.getElementById(id_img);
						TagFound.style.display = 'none';
				}
						
			}
		}
		

	}		

	
	
	



//following script for finding and replacing text

function RemoveLinktoItem()
{
	try
	{
		var tempElements = document.getElementsByTagName('td'); 
		var TagFound;	
		for(var Count=0; Count<tempElements.length ; Count++ )
		{
				if(tempElements[Count].attributes['class']!=null)
				{
					var CssClass = tempElements[Count].attributes['class'].value;	          				
	    			if(CssClass =='ms-disc-bordered') 
					{
						var obj=tempElements[Count];
						var objinnerhtml=obj.innerHTML;
						var splitedobject=obj.getElementsByTagName('a');
						//alert(splitedobject[0].innerHTML);
						obj.innerHTML=splitedobject[0].innerHTML;
					}
				}
		}
		
	}
	catch(ex)
	{
		//alert(ex.message);
	}
}
	

function RemoveGroupByLinktoItem()
{
	try
	{
		var tempElements = document.getElementsByTagName('td'); 
		var TagFound;	
		for(var Count=0; Count<tempElements.length ; Count++ )
		{
				if(tempElements[Count].attributes['class']!=null)
				{
					var CssClass = tempElements[Count].attributes['class'].value;	          				
	    			if(CssClass =='ms-gb') 
					{
						try
						{
						var obj=tempElements[Count];
						var objinnerhtml=obj.innerHTML;
						var splitedobject=obj.getElementsByTagName('a');
						splitedobject[1].innerHTML="";
						splitedobject[2].attributes['href'].value="javascript: ;";
						var temphtml=obj.innerHTML;
						temphtml=temphtml.replace(":&nbsp;"," ");
						
						obj.innerHTML=temphtml;
						}
						catch(ex){}
						
					}
					if(CssClass =='ms-gb2') 
					{
						try
						{
						var obj=tempElements[Count];
						var objinnerhtml=obj.innerHTML;
						var splitedobject=obj.getElementsByTagName('a');
						splitedobject[1].innerHTML="";
						splitedobject[2].attributes['href'].value="javascript: ;";
						var temphtml=obj.innerHTML;
						temphtml=temphtml.replace(":&nbsp;"," ");
						
						obj.innerHTML=temphtml;
						}
						catch(ex){}
						
					}

				}
		}
		
	}
	catch(ex)
	{
		//alert(ex.message);
	}
}

	
	
//hiding Search and Search box from Root site Only
function HideSearchIfRootWeb()
{
	if("Hindi"==readCookie("SiteState"))
	{
		document.getElementById("DivSearchText").style.display="none";
		document.getElementById("DivSearchBox").style.display="none";
	}
}
	
	
	
	
	
	
	
	

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0)
		{
		 	return c.substring(nameEQ.length,c.length);
		 	
		 }
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


	/*
	document.onkeydown = keydown; 
function keydown(evt)
{ 
if (!evt) 
evt = event;
if (evt.ctrlKey && evt.altKey && evt.keyCode==115)
{ 
// CTRL+ALT+F4 
alert("CTRL+ALT+F4");
} 
*/

/*
window.onbeforeunload = function()
{
	if((window.event.clientX<0)||(window.event.clientY<0))
		eraseCookie("SiteState");
		
		//alert(window.event.keyCode);
		
}
*/


/*
var bAltF4AsLast = false;

function Check_Alt_Plus_F4(objEvent)
{
try {
	var sKey;

	if(window.event) {
		sKey = window.event.keyCode;
		window.event.returnValue = false;
	}
	else if(objEvent) {
		sKey = objEvent.which;
	}
	
	var objEvent = objEvent || window.event;
	
	if(sKey == 115 && objEvent.altKey) {
		alert("You clicked Alt + F4");
	
		bAltF4AsLast = true;
	}
	else {
		bAltF4AsLast = true;
	}
	}
	catch(ex) {
		alert(ex.toString());
	}
}

document.onkeydown = Check_Alt_Plus_F4;
*/