function GetPage(PageName)
{
    document.NaviForm.action = PageName;
	document.NaviForm.submit();
}

function CategorySearch(CatID)
{
	document.NaviForm.CategoryID.value = CatID;
	document.NaviForm.txtSearch.value = '';
	document.NaviForm.action="Releases.aspx";
	document.NaviForm.submit();
}

function TextSearch(SearchText)
{
	document.NaviForm.CategoryID.value = 0;
	document.NaviForm.txtSearch.value = SearchText;
	document.NaviForm.action="Releases.aspx";
	document.NaviForm.submit();
}

function Logout(PageName)
{
	document.NaviForm.SessionID.value = 0;
	document.NaviForm.action = PageName;
	document.NaviForm.submit();
}

function DisplayAttachment(jobid, seqno, key) 
{
	var win = window.open("DisplayAttachment.aspx?j=" + jobid + "&s=" + seqno + "&k=" + key, "Medianet", "height=600,width=800,location=yes,toolbar=yes,menubar=yes,directories=no,scrollbars=yes,resizable=yes,copyhistory=no");
	win.focus();
}

function DisplayVideo(url) 
{
	var win = window.open(url, "Medianet", "height=600,width=1024,location=yes,toolbar=yes,menubar=yes,directories=no,scrollbars=yes,resizable=yes,copyhistory=no");
	win.focus();
}

function DisplayMultimedia(url) 
{
	var win = window.open(url, "Medianet", "height=800,width=1024,location=yes,toolbar=yes,menubar=yes,directories=no,scrollbars=yes,resizable=yes,copyhistory=no");
	win.focus();
}

sfHover = function()
{
    var obj = document.getElementById("main_nav");
    
    if (obj != null)
    {
	    var sfEls = obj.getElementsByTagName("LI");
	    for (var i=0; i<sfEls.length; i++)
	    {
		    sfEls[i].onmouseover=function()
		    {
			    this.className+=" sfhover";
		    }
		    sfEls[i].onmouseout=function()
		    {
			    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		    }
	    }
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function doMenu(item)
{
    obj=document.getElementById(item);
    col=document.getElementById("xbutton");
    if (obj.style.display=="none")
    {
        obj.style.display="block";
        col.innerHTML="Collaspe";
    }
    else
    {
        obj.style.display="none";
        col.innerHTML="Expand";
    }
}

function trim(str)
{
  var temp = str;
  while(left(temp, 1)== " ") {temp = temp.substring(1)}
  while(right(temp, 1) == " ") {temp = temp.substring(0, temp.length - 1)}
  return temp;
}

function left(str, n)
{
  return str.substring(0, n);
}

function right(str, n)
{
  return str.substring(str.length - n);
}

function IsEmpty(str)
{
  if (str == "" || str == null) {return true;}
  return false;	
}

function IsAlphaNumericWithSpaceOptionalValue(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){return true;}
  if (!temp.match(/^[a-zA-Z0-9 ]+$/)){alert(fieldName + ' is not a valid alpha numeric value'); return false;}
  return true;
}

function IsAlphaNumericValue(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){alert(fieldName + ' must be supplied'); return false;}
  if (!temp.match(/^[a-zA-Z0-9]+$/)){alert(fieldName + ' is not a valid alpha numeric value'); return false;}
  return true;
}

function IsAlphaNumericWithSpaceValue(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){alert(fieldName + ' must be supplied'); return false;}
  if (temp.match(/[^a-zA-Z0-9 ]/)){alert(fieldName + ' is not a valid alpha numeric value'); return false;}
  return true;
}

function IsValidKeyword(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){return true;}
  if (temp.match(/[^a-zA-Z0-9 &,_\-\.$:]/)){alert(fieldName + ' is not a valid alpha numeric value'); return false;}
  return true;
}

function IsValidMultilineString(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){return true;}
  if (temp.match(/<|>|[^\x20-\x7e\t\r\n]/)){alert(fieldName + ' is not valid.' + ' Only alphanumeric characters, punctuation (excluding < and >), tab and newline characters are allowed for this field.'); return false;}
  return true;
}

function IsValidStringValue(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){alert(fieldName + ' must be supplied'); return false;}
  if (temp.match(/<|>|[^\x20-\x7e]/)) {alert(fieldName + ' is not valid.' + ' Only alphanumeric characters and punctuation characters (excluding < and >) are allowed for this field.'); return false;}
  return true;
}

function IsValidOptionalStringValue(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){return true;}
  if (temp.match(/<|>|[^\x20-\x7e]/)) {alert(fieldName + ' is not valid.' + ' Only alphanumeric characters and punctuation characters (excluding < and >) are allowed for this field.'); return false;}
  return true;
}

function IsNumericValue(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){alert(fieldName + ' must be supplied'); return false;}
  if (!temp.match(/^\d{1,}$/)) {alert(fieldName + ': wrong format'); return false;}
  return true;
}

function IsEmailAddress(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){alert(fieldName + ' must be supplied'); return false;}
  if (!temp.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {alert(fieldName + ': wrong format'); return false;}
  return true;
}

function IsMultipleEmailAddress(fieldName, str)
{
  var temp = trim(str);
  if (temp == "" || temp == null){alert(fieldName + ' must be supplied'); return false;}
  if (!temp.match(/^[a-zA-Z0-9_\-\.@;]+$/)){alert(fieldName + ' is not valid.'  + ' Only alphanumeric characters and _-.@; are allowed for this field.'); return false;}
  var emails = temp.split(";");
  var e;
  for (i=0;i<emails.length-1;i++)
  {
    e = trim(emails[i]);
    if (!e.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {alert(fieldName + ' ' + emails[i] + ': wrong format'); return false;}
  }  
  e = trim(emails[emails.length-1]);
  if (e != "")
  {
    if (!e.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {alert(fieldName + ' ' + e + ': wrong format'); return false;}
  }
  return true;
}

function IsPhoneNumber(fieldName, str)
{
  //var s = str.replace(" ","");
  var s = str.replace(/ /g,"");
  var temp = trim(s);
  if (temp == "" || temp == null){alert(fieldName + ' must be supplied'); return false;}
  if (!temp.match(/^\d{8,}$/)) {alert(fieldName + ': please enter valid Phone Number including an area code'); return false;}
  return true;
}

function CheckPageNo()
{
	var msgErrPageNoRange = "Wrong page number.";
	var f = document.aspnetForm;
	if (!IsNumericValue('Go to Page', f.ctl00$contentLeftRight$contentBody$txtGoToPage.value)){return false;}
	var pageno =  new Number(f.ctl00$contentLeftRight$contentBody$txtGoToPage.value);
	var total = new Number(f.ctl00$contentLeftRight$contentBody$hfldPageCount.value);
	if ((pageno > 0)&&(pageno <= total)){return true;}
	else {
		alert(msgErrPageNoRange);
		return false;
	}
}

function PageLinkClicked(pageno)
{
	var page =  document.getElementById("ctl00_contentLeftRight_contentBody_txtGoToPage");
	page.value = pageno;
}

function CheckEnter(e)
{ 
    var keynum;
    
    if(window.event) // IE
        keynum = e.keyCode;
    else if(e.which) // Netscape/Firefox/Opera
        keynum = e.which;

    if(keynum == 13)
    { //if generated character code is equal to ascii 13 (if enter key)
        if (CheckPageNo())
            __doPostBack('ctl00$contentLeftRight$contentBody$aGo','');
        return false 
    }
    else
        return true 

}