var __doc__;
var __frm__;

function CallbackForStoryAssetListing()
		{
			
			eval(returnControlId('Search_ascx') + '_' + 'StoryAssetListingCallback').Callback();
			var searchCallbackdiv = returnControlId('Search_ascx') + '_' + 'StoryAssetListingCallback_div';
			var strCallbackimg="";
			var strImgName="";
			if($().hidmediaType.value == 'Stories')
			{
			 strImgName = "StoriesHeaderText.gif";
			}
			if($().hidmediaType.value == 'Video')
			{
			 strImgName = "VideosHeaderText.gif";
			}
			if($().hidmediaType.value == 'Stills')
			{
			  strImgName = "StillsHeaderText.gif";
			}
			if($().hidmediaType.value == 'Audio')
			{
			 strImgName = "AudioHeaderText.gif";			 
			}
			strCallbackimg += "<table width=\"564\" class=\"whiteColor\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"
			strCallbackimg += "   <tr>"
			strCallbackimg += "	<td><img src=\"" + strjsImagePath + "nw.gif\" width=\"5\" height=\"10\"></td>"
			strCallbackimg += "	<td style=\"width: 100%;\"><img src=\"" + strjsImagePath + "s.gif\" width=\"1\" height=\"10\"></td>"
			strCallbackimg += "	<td><img src=\"" + strjsImagePath + "en.gif\" width=\"5\" height=\"10\"></td>"
			strCallbackimg += "   </tr>"
			strCallbackimg += "   <tr>"
			strCallbackimg += "	<td><img src=\"" + strjsImagePath + "s.gif\" width=\"5\" height=\"5\"></td>"
			strCallbackimg += "	<td style=\"width: 100%;\">"
			strCallbackimg += "	    <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"
			strCallbackimg += "		<tr>"
			strCallbackimg += "		    <td><img src=\"" + strjsImagePath + "s.gif\" width=\"4\" height=\"1\"></td>"
			strCallbackimg += "		    <td style=\"width: 100%;\">"
			strCallbackimg += "		    <!-- heading start -->"
			strCallbackimg += "			<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"
			strCallbackimg += "			    <tr>"
			strCallbackimg += "				<td>"
			strCallbackimg += "				    <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"
			strCallbackimg += "					<tr>"
			strCallbackimg += "					    <td width=\"71%\">"
			strCallbackimg += "						<img name=\"imgSearch1\" id=\"imgSearch1\" src=\"" + strjsImagePath + strImgName + "\" >"
			strCallbackimg += "					    </td>"
			strCallbackimg += "					    <td style=\"width: 100%;\"><img src=\"" + strjsImagePath + "s.gif\" width=\"1\" height=\"1\"></td>"
			strCallbackimg += "					    <td style=\"font-size:10px;\"></td>"
			strCallbackimg += "					    <td><img src=\"../imgs/spinner.gif\" width=\"16\" height=\"16\" border=\"0\" /></td>"
			strCallbackimg += "					</tr>"
			strCallbackimg += "				    </table>"
			strCallbackimg += "				 </td>"
			strCallbackimg += "			    </tr>"
			strCallbackimg += "			</table>"
			strCallbackimg += "		    <!-- heading end -->"
			strCallbackimg += "		    </td>"
			strCallbackimg += "		    <td><img src=\"" + strjsImagePath + "s.gif\" width=\"4\" height=\"1\"></td>"
			strCallbackimg += "		</tr>"
			strCallbackimg += "	    </table>"
			strCallbackimg += "	 </td>"
			strCallbackimg += "	 <td><img src=\"" + strjsImagePath + "s.gif\" width=\"5\" height=\"20\"></td>"
			strCallbackimg += "   </tr>"
			strCallbackimg += "   <tr>"
			strCallbackimg += "	<td><img src=\"" + strjsImagePath + "ws.gif\" width=\"5\" height=\"5\"></td>"
			strCallbackimg += "	<td style=\"width: 100%;\"><img src=\"" + strjsImagePath + "s.gif\" width=\"1\" height=\"5\"></td>"
			strCallbackimg += "	<td><img src=\"" + strjsImagePath + "se.gif\" width=\"5\" height=\"5\"></td>"
			strCallbackimg += "   </tr>"
			strCallbackimg += "</table>"
		
			if( $(searchCallbackdiv) != null)
		    $(searchCallbackdiv).innerHTML = strCallbackimg;
		    
		}

// General Java Script functions //

function getCookie(NameOfCookie)
{	
try
{
   if (document.cookie.length > 0) {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;      
        return document.cookie.substring(begin, end);
    } 
  }
  return null;
 }
 catch(ex)
 {
 
 } 
}

function setCookie(NameOfCookie, value, expiredays,path) {
try
{
	var ExpireDate = new Date ();	
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + value + 
    ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) +
    ((path) ? "; path=" + path : "" );
 }
 catch(ex)
 {
 
 }   
}

function delCookie (NameOfCookie,path) {	
 try
 {
  if (getCookie(NameOfCookie)) {	
	var Days=3*24*60*60*1000;
	var expDate=new Date()
	expDate.setTime(expDate.getTime()-Days);
    document.cookie = NameOfCookie + "=" +
    ((path) ? "; path=" + path : "" ) +
    "; expires=" + expDate.toUTCString;
  }  
}
catch(ex)
{

}
}

function DoCookieStuff(cookiename,maxSearchValue)
{
try
{
	if(maxSearchValue<0)
	{
		return 0;
	}
	else
	{
		if(cookie_check()==1)
		{
			times_visited=eval(getCookie(cookiename))+1;	
			if (times_visited >maxSearchValue) 
			{	
				if(times_visited-maxSearchValue==1)
				{					
					setCookie(cookiename,times_visited,365,"/");  
				}	
 				return 1;
			}
			else
			{	
				//setCookie(cookiename,times_visited,null,"/");  
				setCookie(cookiename,times_visited,365,"/");  
				return 0;
			}
		}
		else
		{
			return 1;
		}	
	}
}
catch(ex)
{

}
}

function cookie_check()
{
try
{
	document.cookie = "tnmcookie=set"
	if (document.cookie.indexOf("tnmcookie=set")!=-1)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
catch(ex)
{

}
}

function getNetscapeNavVersion()
{
try
{
	return navigator.userAgent.substr(navigator.userAgent.lastIndexOf('/')+1,1)
}
catch(ex)
{

}
}

function swapImgRestore(ctrlname,imgname) { 				
try
{
	ctrlname.src=imgname;				
}
catch(ex)
{

}
}

function swapImage(ctrlname,imgname) {
try
{
	ctrlname.src=imgname;	
}
catch(ex)
{

}
}

function LoginIsEmail(objForm, strLabel)
{
try
{
	bRet = true;
	if (typeof objForm == 'object')
	{
		strTextString  = objForm.value
	}
	else
		strTextString =  new String(objForm)

	if (strTextString.length > 4) 
	  {
		strInfo = strTextString.substring(strTextString.length-4);
		if (strInfo.toUpperCase() == 'INFO' || strInfo.toUpperCase() == 'AERO')
		{
			strTextString = strTextString.substring(0,strTextString.length-1);
		}
	 }

	var objReg1 = eval("/[\\s]|(" + strSpecialChar.charAt(0) + strSpecialChar.charAt(5) + "*" + strSpecialChar.charAt(0) + ")|(\\" +  strSpecialChar.charAt(5) + "\\" +  
	strSpecialChar.charAt(5) + ")|(" + strSpecialChar.charAt(0) + "\\" + strSpecialChar.charAt(5) + ")|(\\" + strSpecialChar.charAt(5) + strSpecialChar.charAt(0) + ")|(^\\" + strSpecialChar.charAt(5) + ")/")
	var objReg2 = eval("/^" + strSpecialChar.charAt(5) + "+\\" + strSpecialChar.charAt(0) + "(\\" + strSpecialChar.charAt(12) + "?)[" +  strAlpha + strNumeric + "\\" + strSpecialChar.charAt(4) + "\\" + strSpecialChar.charAt(5) + "]+\\" + strSpecialChar.charAt(5) + "([" + strAlpha + "]{" +  strNumeric.charAt(2) + "," + strNumeric.charAt(3) + "}|[" + strNumeric + "]{" + strNumeric.charAt(1) + "," + strNumeric.charAt(3) + "})(\\" + strSpecialChar.charAt(13) + "?)$/")
	var objReg3 = eval("/["+ strAlpha + strNumeric + "\\" + strSpecialChar.charAt(5)+ "\\" + strSpecialChar.charAt(4) + strSpecialChar.charAt(14) +"]/")

	if (!objReg1.test(strTextString) && objReg2.test(strTextString))
	{
		var arrTemp = strTextString.split('@')
		for (var i=0; i < arrTemp[0].length; i++)
		{
			strTestChar = arrTemp[0].charAt(i);
			/*if(strTestChar == "'")
			{
				setFocus(objForm, "Please enter a valid " +  strLabel + ".");
				return false;
				break;
			}*/
			
			if (!objReg3.test(strTestChar))
			{
				bRet = false;
				break;
			}
			else    //security spec
			{
			bRet = true;
			}
		}
	
		//bRet = true;
	}
	else
		bRet = false;
	if (!bRet)			
		setFocus(objForm, "Please enter a valid " + strLabel + ".");
	return bRet;
}
catch(ex)
{

}
}
/* Search Functions */

//strSourceName		::	Name of the Source
//strSourceId		::	ID of the Source
//strAssetTypeId	::	Identifier for Stories/Asset(V-A-S)


function changePageForSource(strSourceName,strSourceId,strAssetTypeId)
{	
	try
	{		
				
		var strAssetTypeIdToPass;
		
		if (strAssetTypeId == '0')
		{
			strAssetTypeIdToPass = "Stories";
		}
		if (strAssetTypeId == '1')
		{
			strAssetTypeIdToPass = "Video";
		}
		if (strAssetTypeId == '2')
		{
			strAssetTypeIdToPass = "Audio";
		}
		if (strAssetTypeId == '3')
		{
			strAssetTypeIdToPass = "Stills";
		}
		
		//alert(strAssetTypeIdToPass);
		//$().hidmediaType.value = "Stories";
		$().hidmediaType.value = strAssetTypeIdToPass;
		$().hidSearchClick.value = "BySource";
		$().hidIsSearchClick.value = true;
		// here it is being used to set the current page nubmer to 1 :: in "StrandardSearch.ascx.vb"
		$().hidNewTabClick.value = true;
			/* Search Trail */
	$().hidSearchTrail.value =  strSourceName + '~Source~' + strSourceId;
	$().hidSearchTrailRequired.value = "1";
	$().hidSearchTrailClicked.value = "0";
	/* Ani */
		
		/* Nullify all values */
		$().hidSearchQuery.value = "";
		$().hidReSearch.value = "";
		$().hiddropdownchanged.value = "";
		$().hidRecordsPerPage.value = "";
		$().hidRefineResultId.value = "";
		$().hidParentId.value = "";
		$().hidChildId.value = "";
		$().hidResType.value = "";
		$().hidSearchSource.value = "";
		$().hidSearchBeats.value = "";
		$().hidSearchCriteria.value = "";
		$().hidSearchToDate.value = "";
		$().hidSearchFromDate.value ="";
		/*                    */
		var strId ;		
		strId = '+AND+EQUAL{'+strSourceId+'}:SourceID';
		$().hidRefineResultId.value = $().hidRefineResultId.value +''+ strId;
		//remove entry from Search Box
		var objcontrolid = returnControlId('StandardSearch_ascx');
		$(objcontrolid + '_txtKeywords').value = ""
		
		if(IsPageSubmitRequire == 'TRUE')
		{
			//alert("Submit Required");
			$().hidSubmitRequired.value = "1";
			document.forms[0].action ="../Search/SearchResults.aspx";
			document.forms[0].method = "post";
			document.forms[0].submit();
			//alert("After Submit");
		}
		else
		{
			CallHeaderTab();
			AJAX_MethodForSearch();
		}
		//AJAX_MethodForSearch();
		return false;
	}
	catch(ex)
	{

	}
}

/* Most Popular Player Start */
function MPP_ViewDetail(strStoryId,strStoryGuid)
{
	var strQueryString = "../Releases/StoryDetailPage.aspx?GUID=" + strStoryGuid;
	//var strQueryString = "../Releases/StoryDetailPage.aspx?GUID=cf8ab468-0da2-4435-8d04-05ef9ecc37c1&amp;ID=3099&amp;Screen=STORY-DETAIL&amp;CustomPage=0";
	//alert(strQueryString);
	TitleRedirect(strQueryString);
}
/* Most Popular Player End */



/*Hide Div*/
function HideDIV(obj)
{
	//alert(obj);
	var divObj = $("DIV_" + obj);
	divObj.style.display = "none";
}

/**/

/* To Hide Cart Icons*/
function checkForStoryCartCheckboxes()
	{
		var sthChkFlag="0";
		var arrStoryIds = document.getElementsByTagName("input");
		for (var i=0; i<arrStoryIds.length; i++)
		{
			if (arrStoryIds[i].id.substring(0,4)=='chk_')
			{
				sthChkFlag="1";
			}
		}
	
		if (sthChkFlag=="0")
		{ 	
				if ($("divAddToCart") != null)
				{
					$("divAddToCart").style.display = 'none'; 
				}
				if ($("divAddToCartBottom") != null)
				{
					$("divAddToCartBottom").style.display = 'none'; 
				}	
				
				
		}
	}


function checkForAssetCartCheckboxes()
	{ 
		var sthChkFlag="0";
		var arrAssetIds = document.getElementsByTagName("input");
		for (var i=0; i<arrAssetIds.length; i++)
		{
			if (arrAssetIds[i].id.substring(0,4)=='chk_')
			{
				sthChkFlag="1";
			}
		}
		if (sthChkFlag=="0")
		{ 
				if ($("divAssetAddToCart") != null)
				{
					$("divAssetAddToCart").style.display = 'none'; 
				}
				if ($("divAssetAddToCartBottom") != null)
				{
					$("divAssetAddToCartBottom").style.display = 'none'; 
				}	
		}
	}

/**/
function $(__strId__)
	{
		__doc__ = (typeof __doc__ == "object") ? __doc__ : document;
		__frm__ = (typeof __frm__ == "object") ? __frm__ : (typeof __doc__.forms[0] == "undefined") ? __frm__ : __doc__.forms[0].elements;

		if (arguments.length < 1)
			return __frm__;
		else
			return __doc__.getElementById(__strId__);
	}
