function clearText() 
{ 
	search1 = document.getElementById("Topnav2_Search_txtSearch");
	search2 = document.getElementById("Search2_txtSearch");
	
	if(search1 != null) {
		search1.value = "";
	}
	if(search2 != null) {
		search2.value ="";
	} 
	//document.form.Topnav2_Search_txtSearch.value = ""; 
	//document.form.Search2_txtSearch.value = ""; 
}     
	
function resetText() 
{ 
	search1 = document.getElementById("Topnav2_Search_txtSearch");
	search2 = document.getElementById("Search2_txtSearch");
	if((search1 != null) && (search2 != null)) {
		if(search1.value.length == 0){
			search1.value = search2.value;
		} else{
			search2.value = search1.value;
		}
	}	
}       

function ReturnNoSubmit(e) 
{	
  if(e == null || e.keyCode == null) {
    if(event == null) {
	  return false;
	}
	else {
	  if(event.keyCode == 13) {
	    return false;
	  }
	}
  }
  else if (e.keyCode == 13) {
    return false;
  }
  
  return true;
}

function KeyDownHandler(e) 
{	
  if(e == null || e.keyCode == null) {
	return false;
  }
  if (e.keyCode == 13) {
  
     //The following conditional is due to IE wanting to process the form, when
     //enter is pressed while selecting a suggestion with the enter key, before the
     //suggestion is populated in the search box.  The prevents this handler from
     //being processed while the suggestion box is open.
     if(actb_display) {
		return false;
	 }
  
     resetText();
     		 
	  if (e.target) {
	    targ = e.target;
	  } else if (e.srcElement) {
			targ = e.srcElement;
		}
				
		if (targ.nodeType == 3){   // defeat Safari bug 
			targ = targ.parentNode;
		}
		
		//alert(targ.id.indexOf("Search"));
		
		//	alert(document.getElementById(targ.id).value);
    if(targ.id.indexOf("Search")!=-1 ){
		//if(e.srcElement.id=='Topnav2_Search_txtSearch' )
		  var txtSearchObj=document.getElementById(targ.id);
			var txtSearchKey=txtSearchObj.value;
			var strLen=txtSearchKey.length;
						
						//To find whether '<' character is there in the search string
						if(txtSearchKey.indexOf("<")!=-1)
						{
							var index=txtSearchKey.indexOf("<");
							index=index+1
							if(index<strLen)
							{
								alert("Potentially unsafe content!Please modify the Search KeyWord");
								return false;
							}
						}
						//For handling situation if search string is too long
						if(strLen>100)
						{
							alert("The Search key word is too long.Please Enter a valid key word");
							return false;
						}
						var flag=false;
						if(txtSearchKey!=""&&txtSearchKey!=null)
						{
							//search string is not null
							for(var i=0;i<strLen;i++)
							{
								if(txtSearchKey.charAt(i)!=" ")
								{
									flag=true;
								}
							}
							if(flag==false)
							{
								//search string is having nothing other than blank spaces
								alert("Please Enter a valid search key word");
								return false;
							}
						}
						else
						{
							//search string is null
							alert("Please Enter a search key word");
							return false;
						}
						
						var btn = document.getElementById("Topnav2_Search_imgbtnSearch");
						e.cancelBubble = true;
						e.returnValue = false;
	
					btn.focus();
   					btn.click();
					}
				}
			}
			
			function SearchValidation(e)
			{	
				//event = (event) ? event : ((window.event) ? window.event : "")
				/* Removed AFLLeftMenu1
				if(event.srcElement.id=='AFLLeftMenu1_Topnav2_Search_imgbtnSearch' )
				*/
				if((e.srcElement == null) || (e.srcElement.id=='Topnav2_Search_imgbtnSearch') || (e.srcElement.id=='Search2_imgbtnSearch'))
				{
					/* Remeoved AFLLeftMenu1
					var txtSearchObj=document.getElementById("AFLLeftMenu1_Topnav2_Search_txtSearch")
					*/
					var txtSearchObj=document.getElementById("Topnav2_Search_txtSearch")
					var txtSearchKey=txtSearchObj.value;
					var strLen=txtSearchKey.length;

					//To find whether '<' character is there in the search string
					if(txtSearchKey.indexOf("<")!=-1)
					{

						var index=txtSearchKey.indexOf("<");
						index=index+1;
						if(index<strLen)
						{
							alert("Potentially unsafe content!Please modify the Search KeyWord");
							return false;
						}
					}

					//For handling situation if search string is too long
					if(strLen>100)
					{
						alert("The Search key word is too long.Please Enter a valid key word");
						return false;
					}
					var flag=false;
					if(txtSearchKey!=""&&txtSearchKey!=null)
					{
						//search string is not null
						for(var i=0;i<strLen;i++)
						{
							if(txtSearchKey.charAt(i)!=" ")
							{
								flag=true;
							}
						}
						if(flag==false)
						{
							//search string is having nothing other than blank spaces
							alert("Please Enter a valid search key word");
							return false;
						}
					}
					else
					{
						//search string is null
						alert("Please Enter a search key word");
						return false;
					}
					
					document.getElementById("Topnav2_Search_txtSearch").name = "Topnav2:Search:txtSearch";
					document.getElementById("Search2_txtSearch").name = "Search2:txtSearch";
				}
			}			

function open_popup(url, w, h, resize, scroll,wname) {
/* place this in onclick or href:  "javascript:open_popup('[url]','[width of window]','[height of window]','[resize option]','[scroll opiton]','[windowname]');"  */
  wname = (wname == null) ? "popwin" : wname.replace(new RegExp(/ /g), "");
  
  scroll = ((scroll == null)||(scroll=='')||(scroll==1)||(scroll=='1'))? 'yes':'no';
  resize = ((resize == null)||(resize=='')||(resize==1)||(resize=='1'))? 'yes':'no';
  var properties = "toolbar=0,scrollbars="+scroll+",location=0,statusbar=1,menubar=0,resizable="+resize;
  properties += ",width="+ w +",height="+ h;
  child = window.open(url,wname,properties);
  child.focus();
}

function swap(img,isrc) {
  if (!document.images) return;

	if( document.images[img] != null ) 
	  document.images[img].src = isrc;
}
			
function ShowLogOutPopUP() {
  open_popup("LogOutPopUp.aspx","350","250","1","logout");
//  window.showModalDialog("LogOutPopUp.aspx",null, "dialogWidth=350px;dialogHeight=250px")
}

//Script taken from http://www.multicastmedia.com/Launchers/KNOTLaunch.js to link to the KnotTV
document.write('<SCRIPT LANGUAGE=JavaScript>var javascript_version = 1.0;</SCRIPT>');
document.write('<SCRIPT LANGUAGE=JavaScript1.1>javascript_version = 1.1;</SCRIPT>');
document.write('<style>.launcher {border:0; cursor: pointer; cursor: hand;}</style>');

var newwin;
function LaunchKNOT()
{
var winname;
var winurl;
var winfeatures;
winfeatures = "width=352, height=708, resizable=0"
winurl = "http://www.multicastmedia.com/launchers/KNOTTV.htm";
	newwin = window.open(winurl,winname,winfeatures);
	if(javascript_version > 1.0)
	{
 		setTimeout('newwin.focus();',250);
	}
}
