
var URLArray = new Array();
URLArray[0] = "sendnewsrelease.asp";
//URLArray[1] = "subscribereleaseboth.asp";
URLArray[1] = "subscribenewsdistribution.asp";
URLArray[2] = "newsdistributionlogin.asp";
URLArray[3] = "newsreleasemain.asp";
URLArray[4] = "newsreleaselogin.asp";
URLArray[5] = "showcase.asp";
URLArray[6] = "showcaselogin.asp";
URLArray[7] = "corporatedesign.asp";
URLArray[8] = "corporatedesignlogin.asp";
URLArray[9] = "hedgeevents.asp";
URLArray[10] = "hedgeeventslogin.asp";
URLArray[11] = "searchresults.asp";
URLArray[12] = "advancedsearch.asp";
URLArray[13] = "newsrelease.asp";
URLArray[14] = "hedgeweek.asp";
//URLArray[15] = "subscribereleaseboth.asp";
URLArray[15] = "subscribehedgeweek.asp";
URLArray[16] = "hedgeweeklogin.asp";
URLArray[17] = "hedgeclub.asp";
URLArray[18] = "hedgeclublogin.asp";
URLArray[19] = "hedgereports.asp";
URLArray[20] = "hedgereportslogin.asp";
URLArray[21] = "hedgetrack.asp";
URLArray[22] = "hedgetracklogin.asp";
URLArray[23] = "newsreleasecategory.asp";
URLArray[24] = "archive.asp";
URLArray[25] = "mynewsrelease.asp";
URLArray[26] = "feature.asp";
URLArray[27] = "hedgeweeknewsletter.asp";
URLArray[28] = "newsletterlogin.asp";




function CheckLogin(strURL) {
	CheckLogin(strURL,'');
}
function CheckLogin(strURL, strID) {
	if(strURL == "newsdistribution")
	{
		if(isPaid == "HedgeWire") {
			window.location.href = URLArray[0];
		}
		else if (isRegistered){
			window.location.href = URLArray[1];
		}
		else {
			window.location.href = URLArray[2] + "?" + strURL;
		}
	}
	else if(strURL == "newsrelease"){
		if (isRegistered){
			window.location.href = URLArray[3];
		}
		else {
			window.location.href = URLArray[4]  + "?" + strURL;
		}
	}else if(strURL == "showcase"){
		if(isRegistered) {
			window.location.href = URLArray[5];
		}
		else {
			window.location.href = URLArray[6] + "?" + strURL;
		}
	}else if(strURL == "corporatedesign"){
		if(isRegistered) {
			window.location.href = URLArray[7];
		}
		else {
			window.location.href = URLArray[8] + "?" + strURL;
		}
	}else if(strURL == "hedgeevents"){
		if(isRegistered) {
			window.location.href = URLArray[9];
		}
		else {
			window.location.href = URLArray[10] + "?" + strURL ;
		}
	}else if (strURL == "search"){
		if(validateSearchText(document.frmSearch, document.frmSearch.hidCommonWords.value)) {		
			if (isRegistered){				
				document.frmSearch.action = URLArray[11];
				return true;
			}
			else {
				//document.frmSearch.action = URLArray[4] + "?" + strURL + "," + strID;
				document.frmSearch.action = URLArray[11] + "?" + strURL + "," + strID;
				//window.location.href = URLArray[4] + "?" + strURL + "," + strID;				
				return true;
			}
		}
		else
			return false;
	}else if (strURL == "advancesearch"){
		if(isRegistered){
			window.location.href = URLArray[12];
		}
		else {
			window.location.href = URLArray[4] + "?" + strURL;
		}
	}else if (strURL == "news"){
		if(isRegistered)  {
			window.location.href = URLArray[13] + "?" + strID;
		}
		else {
			window.location.href = URLArray[4] + "?" + strURL + "," + strID;
		}
	}else if(strURL == "hedgeweek"){
		if((isPaid == "HedgeWire") || (isPaid == "HedgeWeek")) {
			window.location.href = URLArray[14];
		}
		else if (isRegistered){
			window.location.href = URLArray[15];
		}
		else {
			window.location.href = URLArray[16] + "?" + strURL ;
		}
	}else if(strURL == "hedgeclub"){
		if(isRegistered) {
			window.location.href = URLArray[17];
		}
		else {
			window.location.href = URLArray[18] + "?" + strURL ;
		}
	}else if(strURL == "hedgereports"){
		if(isRegistered) {
			window.location.href = URLArray[19];
		}
		else {
			window.location.href = URLArray[20] + "?" + strURL ;
		}
	}else if(strURL == "hedgetrack"){
		if(isRegistered) {
			window.location.href = URLArray[21];
		}
		else {
			window.location.href = URLArray[22];
		}
	}else if (strURL == "newscategory"){
		if(isRegistered)  {
			window.location.href = URLArray[23] + "?" + strID;
		}
		else {
			window.location.href = URLArray[4];
		}
	}else if (strURL == "archive"){
		if(isRegistered) {
			window.location.href = URLArray[24];
		}
		else {
			window.location.href = URLArray[4];
		}
	}else if(strURL == "mynewsrelease"){
		if(isPaid == "HedgeWire") {
			window.location.href = URLArray[25];
		}
		else if (isRegistered){
			window.location.href = URLArray[1];
		}
		else {
			window.location.href = URLArray[2];
		}
	}
	else if(strURL == "newsletter"){
		if (isRegistered){
			window.location.href = URLArray[27];
		}
		else {
			window.location.href = URLArray[28]  + "?" + strURL + "," + strID;
		}
	}
	else if(strURL == "Feature"){
		if (isRegistered){
			window.location.href = URLArray[26] + "?" + strID;
		}
		else {
			window.location.href = URLArray[4]  + "?" + strURL;
		}
	}	
}

function CheckForm()
{
	document.frmLogin.txtUserName.value = stripBlanks(document.frmLogin.txtUserName.value);
	document.frmLogin.txtPassword.value = stripBlanks(document.frmLogin.txtPassword.value);
	if(document.frmLogin.txtUserName.value == "") {
		alert("Please enter the User Name.");
		document.frmLogin.txtUserName.focus();
		return false;
	}
	if(document.frmLogin.txtPassword.value == "") {
		alert("Please enter the Password.");
		document.frmLogin.txtPassword.focus();
		return false;
	}	
	
	//document.frmLogin.submit()
	return true;

}

function CheckForm()
{
	document.frmLogin.txtUserName.value = stripBlanks(document.frmLogin.txtUserName.value);
	document.frmLogin.txtPassword.value = stripBlanks(document.frmLogin.txtPassword.value);
	if(document.frmLogin.txtUserName.value == "") {
		alert("Please enter the User Name.");
		document.frmLogin.txtUserName.focus();
		return false;
	}
	if(document.frmLogin.txtPassword.value == "") {
		alert("Please enter the Password.");
		document.frmLogin.txtPassword.focus();
		return false;
	}	
	
	//document.frmLogin.submit()
	return true;

}

function CheckLoginForm()
{	
	document.frmCheckLogin.txtUserName.value = stripBlanks(document.frmCheckLogin.txtUserName.value);
	document.frmCheckLogin.txtPassword.value = stripBlanks(document.frmCheckLogin.txtPassword.value);
	if(document.frmCheckLogin.txtUserName.value == "") {
		alert("Please enter the User Name.");
		document.frmCheckLogin.txtUserName.focus();
		return false;
	}
	if(document.frmCheckLogin.txtPassword.value == "") {
		alert("Please enter the Password.");
		document.frmCheckLogin.txtPassword.focus();
		return false;
	}
	return true;
}


function openHelpWindow(strURL)
{
	var FileName = "helptext.htm#" + strURL

	if (screen.width == "800")
	{
		winStatus = window.open(FileName,'NewWindow','menubar=no,toolbar=no,location=no,hotkeys=no,status=yes,copyhistory=no,width=120,height=120,scrollbars=yes,top=0,left=0')
	}
	else
	{
		winStatus = window.open(FileName,'NewWindow','menubar=no,toolbar=no,location=no,hotkeys=no,status=yes,copyhistory=no,width=280,height=250,scrollbars=yes,top=175,left=240')
	}
}

function openCheckLogin(strURL)
{
	var FileName = "passwordprotected.asp#" + strURL

	if (screen.width == "800")
	{
		winStatus = window.open(FileName,'NewWindow','menubar=no,toolbar=no,location=no,hotkeys=no,status=no,copyhistory=no,width=350,height=240,scrollbars=no,top=0,left=0')
	}
	else
	{
		winStatus = window.open(FileName,'NewWindow','menubar=no,toolbar=no,location=no,hotkeys=no,status=no,copyhistory=no,width=350,height=240,scrollbars=no,top=175,left=240')
	}
}

/* enable disable starts here */ 
function BrowserCheck()
{
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b

}
function checkEvent(e)
{
	if (e.target !="")
	{
		if (ver.b == 'ns')
		{
			if (e.target.name)
			{
				if (arrElementsStatus[e.target.name] == 'readonly')
				{
					e.target.blur();
					return false;
				}
				else
				{
					return true;
				}
			}
		}
		else
		{
			return true;
		}
	}
}

var netscapeItems;
ver = new BrowserCheck()
var o;
var arrElementsStatus = new Array();
var arrElementsNames = new Array();
var arrListBoxValue = new Array();

if (ver.b == 'ns')
{
	this.document.captureEvents(Event.MOUSEDOWN);
	this.document.captureEvents(Event.FOCUS);
	this.document.onMouseDown=checkEvent;
	this.document.onFocus=checkEvent;
}

function disabletextbox(objName)
{
	if (ver.b == 'ns')
	{
  	  this.arrElementsStatus[objName.name] = 'readonly';
	}
	else
	{
	    objName.disabled = 1;
	}
}

function enabletextbox(objName)
{
	if (ver.b == 'ns')
	{
	    this.arrElementsStatus[objName.name] = 'editable';
	}
	else
	{
	    objName.disabled = 0;
	}
}

/* enable disable ends here */


function closeWind()
{
	window.opener.location.href = "disclaimerregister.htm";
	window.close();
}

function SubmitCategory_Form()
{
	if(frmNewsCategory.category.value == "1")
		document.frmNewsCategory.action = "fundoffunds.htm"
	else if (frmNewsCategory.category.value == "2")
		frmNewsCategory.action = "hedgefunds.htm"
	else if (frmNewsCategory.category.value == "3")
		frmNewsCategory.action = "privateclientassetmanager.htm"
	else if (frmNewsCategory.category.value == "4")
		frmNewsCategory.action = "riskanalysis.htm"
	else if (frmNewsCategory.category.value == "5")
		frmNewsCategory.action = "structuredproducts.htm"
	
	document.frmNewsCategory.submit();
		
}

function SubmitArchiveCategory_Form()
{
	if(frmArchive.category.value == "1")
		document.frmArchive.action = "archive.htm"
	else if (frmArchive.category.value == "2")
		frmArchive.action = "hedgefundsarchive.htm"
	else if (frmArchive.category.value == "3")
		frmArchive.action = "privateclientassetmanagerarchive.htm"
	else if (frmArchive.category.value == "4")
		frmArchive.action = "riskanalysisarchive.htm"
	else if (frmArchive.category.value == "5")
		frmArchive.action = "structuredproductsarchive.htm"
	
	document.frmArchive.submit();
		
}



function contentsInit() 
	{
		document.frames.Contents.document.designMode = "On";	
		
	}
	function format(process) 
	{
	  //if (process == 1)
	  //{
		document.frames.Contents.document.execCommand(process);
		document.frames.Contents.focus();
	  //}		
	}
	function format1(fontname)
	{
		document.frames.Contents.document.execCommand('FontName', false, fontname)
		document.frames.Contents.focus();
	}
		
	function format2(heading)
	{	
		//document.frames.Contents.document.execCommand('FontName', false, "Arial")
		
			if(heading == "1")
			{
				document.frames.Contents.document.execCommand('FontSize', false, "1")
			}
			else if(heading == "2")
			{
				document.frames.Contents.document.execCommand('FontSize', false, "2")
			}
			else if(heading == "3")
			{
				document.frames.Contents.document.execCommand('FontSize', false, "3")
			}
			else if(heading == "4")
			{
				document.frames.Contents.document.execCommand('FontSize', false, "4")
			}
			else if(heading == "5")
			{
				document.frames.Contents.document.execCommand('FontSize', false, "5")
			}
			else if(heading == "6")
			{
				document.frames.Contents.document.execCommand('FontSize', false, "6")
			}
			else if(heading == "7")
			{
				document.frames.Contents.document.execCommand('FontSize', false, "7")
			}
			else
			{
				document.frames.Contents.document.execCommand('FontSize', false, "1")
			}
			document.frames.Contents.focus();
		
		
	}
	function format3(List)
	{
		if(List == "1")
		{
			document.frames.Contents.document.execCommand('InsertOrderedList', false, "List")			
		}
		if(List == "2")
		{
			document.frames.Contents.document.execCommand('InsertUnorderedList', false, "List")
		}
		document.frames.Contents.focus();	
	}
	function format4(link)
	{
		if(link == "Link")
		{
			document.frames.Contents.document.execCommand('CreateLink')
		}
		if(link == "UnLink")
		{
			document.frames.Contents.document.execCommand('UnLink')
		}
		document.frames.Contents.focus();
	}
	function format5(forecolor)
	{
		document.frames.Contents.document.execCommand('ForeColor', false, forecolor)
		document.frames.Contents.focus();
	}
	function format6(edit)
	{
		if(edit == "Cut")
		{
			document.frames.Contents.document.execCommand('Cut', false)
		}
		if(edit == "Copy")
		{
			document.frames.Contents.document.execCommand('Copy', false)
		}
		if(edit == "Paste")
		{
			document.frames.Contents.document.execCommand('Paste', false)
		}
		if(edit == "SelectAll")
		{
			document.frames.Contents.document.execCommand('SelectAll', false)
		}
		document.frames.Contents.focus();
	}
	function format7(justify)
	{
		if(justify == "JustifyLeft")
		{
			document.frames.Contents.document.execCommand('JustifyLeft')
		}
		if(justify == "JustifyCenter")
		{
			document.frames.Contents.document.execCommand('JustifyCenter')
		}
		if(justify == "JustifyRight")
		{
			document.frames.Contents.document.execCommand('JustifyRight')
		}
		document.frames.Contents.focus();
	}
	
	
	function foreColor()
	{
		var arr = showModalDialog("selcolor.htm","","font-family:Arial; font-size:12; dialogWidth:30em; dialogHeight:34em" );
		if (arr != null) 
		document.frames.Contents.document.execCommand('ForeColor',false,arr);	
	}
	
/*  content editor ends here */	
function BrowserCheck()
{
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b

}

function show_calendar(str_target, str_datetime) 
{
	//alert ( str_datetime );
	var arr_months = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
	var week_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)	
	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	
	var dt_next_year = new Date(dt_datetime);
	dt_next_year.setYear(dt_datetime.getFullYear()+1);	
	
	var dt_prev_year = new Date(dt_datetime);
	dt_prev_year.setYear(dt_datetime.getFullYear()-1);	


	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var intYear = dt_datetime.getFullYear();
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>Calendar</title>\n"+
		"</head>\n"+
		"<body topmargin = '5' bgcolor=\"#ffffff\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#e67200\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#e67200\"><a onfocus = 'this.blur()' href=\"javascript:window.opener.show_calendar('"+
		str_target+"', '"+ dt2dtstr(dt_prev_year)+"');\">"+
		"<img src=\"..\\images\\previousyear.jpg\"  border=\"0\""+
		" alt=\"Previous Year\"></a>" +		
		"<a onfocus = 'this.blur()' href=\"javascript:window.opener.show_calendar('"+
		str_target+"', '"+ dt2dtstr(dt_prev_month)+"');\">"+
		"<img src=\"..\\images\\previousmonth.jpg\"  border=\"0\""+
		" alt=\"Previous Month\"></a></td>\n"+				
		"	<td bgcolor=\"#e67200\"  align = \"center\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\"><b>"
		+arr_months[dt_datetime.getMonth()]+" " + intYear  + "</b></font></td>\n"+
		"	<td bgcolor=\"#e67200\" align=\"right\"><a onfocus = 'this.blur()' href=\"javascript:window.opener.show_calendar('"
		+str_target+"', '"+dt2dtstr(dt_next_month)+"');\">"+
		"<img src=\"..\\images\\nextmonth.jpg\"  border=\"0\""+
		" alt=\"Next Month\"></a>" + 
		"<a onfocus = 'this.blur()' href=\"javascript:window.opener.show_calendar('"
		+str_target+"', '"+dt2dtstr(dt_next_year)+"');\">"+
		"<img src=\"..\\images\\nextyear.jpg\"  border=\"0\""+
		" alt=\"Next Year\"></a>" + 
		"</td>\n</tr></table>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\"><tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#fb8c20\">"+
		"<font color=\"#000000\" face=\"arial, tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	var intWeek = 0;
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#f8c25a\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#f5d9a7\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener.document."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'; window.close();\">"+
					"<font color=\"#000000\" face=\"courier, arial, tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener.document."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'; window.close();\">"+
					"<font color=\"#B0B8C6\" face=\"courier, arial, tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
		intWeek ++;
	}
	// print calendar footer
	str_buffer += 
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n"; 

	
		/* "<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
		"<font color=\"White\" face=\"courier, arial,tahoma, verdana\" size=\"2\">"+
		"Time: <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+
		"\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" +
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n"; */
	var vWinCal = window.open("", "Calendar", "width=270,height=175,status=no,resizable=no" );

	if( intWeek < 5)
		vWinCal.resizeTo(270, intWeek * 49 );	
	else if( intWeek == 5)
		vWinCal.resizeTo(270, intWeek * 43 );
	else
		vWinCal.resizeTo(270, intWeek * 40 );
	vWinCal.opener = self;
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) 
{
	var re_date = /^(\d+)\-(\d+)\-(\d+)/;
	if (!re_date.exec(str_datetime))
		return alert("Invalid Datetime format: "+ str_datetime);
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) 
{
	var intMonth;
	if((dt_datetime.getMonth()+1) <= 9)
		intMonth = "0" + (dt_datetime.getMonth()+1);
	else
		intMonth = (dt_datetime.getMonth()+1);

	var intDate;
	if( dt_datetime.getDate() <= 9)
		intDate = "0" + dt_datetime.getDate();	
	else
		intDate = dt_datetime.getDate();

	return (new String (intDate+"-"+(intMonth)+"-"+dt_datetime.getFullYear()+" "));
}
function dt2tmstr (dt_datetime) 
{
	return (new String (
			dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

function openWindowGraph(strURL)
{

	if (screen.width == "800")
	{
		winStatus = window.open(strURL,'NewWindow','menubar=no,toolbar=no,location=no,hotkeys=no,status=yes,copyhistory=no,width=670,height=400,scrollbars=yes,top=0,left=0')
	}
	else
	{
		winStatus = window.open(strURL,'NewWindow','menubar=no,toolbar=no,location=no,hotkeys=no,status=yes,copyhistory=no,width=670,height=560,scrollbars=yes,top=0,left=0')
	}
}


function openWindow(strURL)
{

	if (screen.width == "800")
	{
		winStatus = window.open(strURL,'NewWindow','menubar=no,toolbar=no,location=no,hotkeys=no,status=yes,copyhistory=no,width=790,height=400,scrollbars=yes,top=0,left=0')
	}
	else
	{
		winStatus = window.open(strURL,'NewWindow','menubar=no,toolbar=no,location=no,hotkeys=no,status=yes,copyhistory=no,width=850,height=560,scrollbars=yes,top=0,left=0')
	}
}

function btnCancel()
{
	document.location.href="welcome.asp"
}

function NextPage(URL)
{
	document.location.href = URL
}
	

function isempty(strToCheck)
{
	
	var bStringEmpty = true;	
	if( strToCheck != null )
	{
		//getting the length of the string
		var nLength = strToCheck.length	
		//checking the length of the contents of the text box
	
		if(nLength > 0)
		{
			
			for(i=0;i<nLength;i++)
			{
				if (strToCheck.charAt(i) != " " && strToCheck.charAt(i) != "\t" && strToCheck.charCodeAt(i) != 13 && strToCheck.charCodeAt(i) != 10 )
				{
					bStringEmpty = false;
					break;
				}
			}
		}
	}
	return bStringEmpty;
}

var win = null;

function NewWindow(mypage,myname,w,h)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable=no'
	win = window.open(mypage,myname,settings)
}

function popupnewwindow(newlink)
{
	if(screen.width==800 && screen.height==600)
		window.open(newlink,null,"height=250,width=600,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,top=100,left=120");
	else
		window.open(newlink,null,"height=250,width=700,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,top=100,left=200");

}

function btnPreLoginCancel()
{
	document.location.href="index.asp"
}

function sponsorRedirect(URL)
{
	popupnewwindow(URL)
}


/**  To check the whether search text is valid */


function validateSearchText(frmSearch,strCommonWords) {
	if(frmSearch.name == "frmSearch")
	{
		frmSearch.txtSearchText.value = stripBlanks(frmSearch.txtSearchText.value);
		if(frmSearch.txtSearchText.value == "")
		{
			alert('Please enter a key word.');
			frmSearch.txtSearchText.focus();
			return false;
		}
	}
	else 
	{
		frmSearch.txtSearchText.value = stripBlanks(frmSearch.txtSearchText.value);
		if(frmSearch.selCategory.value == "-NA-")
		{
			alert('Please select a News Release Category')
			frmAdvanceSearch.selCategory.focus();
			return false;
		}
		if(frmSearch.txtSearchText.value == "")
		{
			alert('Please enter a key word.');
			frmSearch.txtSearchText.focus();
			return false;
		}
	}
	var strSearchText = stripBlanks(frmSearch.txtSearchText.value);
	var strArrayCommonWords = strCommonWords.split(", ")
	for (var wordCount = 0 ; wordCount < strArrayCommonWords.length; wordCount++ ) {
		if (strSearchText == strArrayCommonWords[wordCount]) {
			frmSearch.txtSearchText.focus();
			alert("The key word '" + strSearchText + "' is a common word. This cannot be searched");
			return false;
		}
	}
	return true;
}
/** End of the function */

function stripBlanks(Source)
{
 	var newString;
	var i;
	var j;
	var blank;
	blank = " ";
	newString = "";
	if(Source == null) Source = " ";
	aString = Source;	
	for (i=0; i<aString.length; i++)
	{ 
		if (aString.charAt(i) != blank && aString.charCodeAt(i)!= 13 && aString.charCodeAt(i) != 10 )
		{
			break;
		}
	}
	for (j=aString.length-1; j>=0; j--)
	{
		if (aString.charAt(j) != blank   && aString.charCodeAt(j)!= 13 && aString.charCodeAt(j) != 10 )
		{
				break;
		}
	}
	for(k=i;k<=j;k++)
	{
		newString += aString.charAt(k);
	}	
	return newString;	
}


// ---------------- Country Listing Array -----------------------------------

var arrUKCounty = new Array();	
	arrUKCounty[0] = "Alderney";
	arrUKCounty[1] = "Avon";
	arrUKCounty[2] = "Bedfordshire";
	arrUKCounty[3] = "Berkshire" ;
	arrUKCounty[4] = "Borders";
	arrUKCounty[5] = "Buckinghamshire";
	arrUKCounty[6] = "Cambridgeshire";
	arrUKCounty[7] ="Central";
	arrUKCounty[8] = "Cheshire";
	arrUKCounty[9] = "Cleveland";
	arrUKCounty[10] = "Clwyd";
	arrUKCounty[11] = "Cornwal";
	arrUKCounty[12] = "County Antrim";
	arrUKCounty[13] = "County Armagh";
	arrUKCounty[14] = "County Down";
	arrUKCounty[15] = "County Durham";
	arrUKCounty[16] = "County Fermanagh";
	arrUKCounty[17] = "County Londonderry";
	arrUKCounty[18] = "County Tyrone";
	arrUKCounty[19] = "Cumbria";
	arrUKCounty[20] = "Derbyshire";
	arrUKCounty[21] = "Devon";
	arrUKCounty[22] = "Dorse";
	arrUKCounty[23] = "Dumfries & Galloway";
	arrUKCounty[24] = "Dyfed";
	arrUKCounty[25] = "East Sussex";
	arrUKCounty[26] = "Essex";
	arrUKCounty[27] = "Fife";
	arrUKCounty[28] = "Glamorgan";
	arrUKCounty[29] = "Gloucester";
	arrUKCounty[30] = "Grampian";
	arrUKCounty[31] = "Greater London";
	arrUKCounty[32] = "Greater Manchester";
	arrUKCounty[33] = "Guernsey";
	arrUKCounty[34] = "Gwent";
	arrUKCounty[35] = "Gwynedd";
	arrUKCounty[36] = "Hampshire";
	arrUKCounty[37] = "Hereford & Worcester";
	arrUKCounty[38] = "Hertfordshire";
	arrUKCounty[39] = "Highlands";
	arrUKCounty[40] = "Humberside";
	arrUKCounty[41] = "Isle of Man";
	arrUKCounty[42] = "Isle of Wight";
	arrUKCounty[43] = "Jersey";
	arrUKCounty[44] = "Kent";
	arrUKCounty[45] = "Lancashire";
	arrUKCounty[46] = "Leicestershire";
	arrUKCounty[47] = "Lincolnshire";
	arrUKCounty[48] = "Lothian";
	arrUKCounty[49] = "Merseyside";
	arrUKCounty[50] = "Norfolk";
	arrUKCounty[51] = "North Yorkshire";
	arrUKCounty[52] = "Northamptonshire";
	arrUKCounty[53] = "Northumberland";
	arrUKCounty[54] = "Nottinghamshire";
	arrUKCounty[55] = "Orkney";
	arrUKCounty[56] = "Oxfordshire";
	arrUKCounty[57] = "Powys";
	arrUKCounty[58] = "The Sark";
	arrUKCounty[59] = "Shetland";
	arrUKCounty[60] = "Shropshire";
	arrUKCounty[61] = "Somerset";
	arrUKCounty[62] = "South Glamorgan";
	arrUKCounty[63] = "South Yorkshire";
	arrUKCounty[64] = "Staffordshire";
	arrUKCounty[65] = "Strathclyde";
	arrUKCounty[66] = "Suffolk";
	arrUKCounty[67] = "Surrey";
	arrUKCounty[68] = "Tayside";
	arrUKCounty[69] = "Tyne & Wear";
	arrUKCounty[70] = "Warwickshire";
	arrUKCounty[71] = "West Glamorgan";
	arrUKCounty[72] = "West Midlands";
	arrUKCounty[73] = "West Sussex";
	arrUKCounty[74] = "West Yorkshire";
	arrUKCounty[75] = "Western Isles";
	arrUKCounty[76] = "Wiltshire";

var arrUSState = new Array();
	arrUSState[0] = "Alabama";
	arrUSState[1] = "Alaska";
	arrUSState[2] = "Arizona";
	arrUSState[3] = "Arkansas";
	arrUSState[4] = "California";
	arrUSState[5] = "Colorado";
	arrUSState[6] = "Connecticut";
	arrUSState[7] = "Delaware";
	arrUSState[8] = "Florida";
	arrUSState[9] = "Georgia";
	arrUSState[10] = "Hawaii";
	arrUSState[11] = "Idaho";
	arrUSState[12] = "Illinois";
	arrUSState[13] = "Indiana";
	arrUSState[14] = "Iowa";
	arrUSState[15] = "Kansas";
	arrUSState[16] = "Kentucky";
	arrUSState[17] = "Louisiana";
	arrUSState[18] = "Maine";
	arrUSState[19] = "Maryland";
	arrUSState[20] = "Massachusetts";
	arrUSState[21] = "Michigan";
	arrUSState[22] = "Minnesota";
	arrUSState[23] = "Mississippi";
	arrUSState[24] = "Missouri";
	arrUSState[25] = "Montana";
	arrUSState[26] = "Nebraska";
	arrUSState[27] = "Nevada";
	arrUSState[28] = "New Hampshire";
	arrUSState[29] = "New Jersey";
	arrUSState[30] = "New Mexico";
	arrUSState[31] = "New York";
	arrUSState[32] = "North Carolina";
	arrUSState[33] = "North Dakota";
	arrUSState[34] = "Ohio";
	arrUSState[35] = "Oklahoma";
	arrUSState[36] = "Oregon";
	arrUSState[37] = "Pennsylvania";
	arrUSState[38] = "Rhode Island";
	arrUSState[39] = "South Carolina";
	arrUSState[40] = "South Dakota";
	arrUSState[41] = "Tennessee";
	arrUSState[42] = "Texas";
	arrUSState[43] = "Utah";
	arrUSState[44] = "Vermont";
	arrUSState[45] = "Virginia";
	arrUSState[46] = "Washington";
	arrUSState[47] = "West Virginia";
	arrUSState[48] = "Wisconsin";
	arrUSState[49] = "Wyoming";
	
//-------------------------------- End of Country Listing Array ----------------------------


function addObjects(source,destination, sourceName)  
{	
	var index;
	var index1;  
	var newoption;
	var isNew;
	var boxLength;
	var selectedItem;
	var selectedText;
	var selectedValue;
	if(source.length  == 0)  
    { 
		alert("There is no " + sourceName + " to be distributed.");
		source.focus();
		return false;
    }  
	if(source.value == '')  
    { 
		alert("Please select the group to be added from the " + sourceName  + " before clicking on the Add button.");
		source.focus();
		return false;
    }  
    else
    { 
		var boxLength = destination.length;		
    }
 	for (index1 = 0; index1 < source.length ; index1++) 
	{
		isNew = true;		 
		if (source.options[index1].selected)
	 	{
	 		selectedItem = source.options[index1];		
			selectedText = source.options[index1].text;		
			selectedValue = source.options[index1].value;		
			if (boxLength != 0)
			{
				for (index = 0; index < boxLength; index++) 
				{  
					thisitem = destination[index].value;					
					if (thisitem == selectedValue) 
					{						
						isNew = false;						
						break;
					}     
				}
			}	
			if (isNew) 
			{
			    newoption = new Option(selectedText, selectedValue, false,false);
			    destination.options[boxLength] = newoption;			  
			} 			
			boxLength = destination.length;
		}
	}
	source.value = "";
	source.selectedIndex = -1;
}
function removeObjects(source, sourceName) 
{
	var x;
    var boxLength = source.length;
    if (boxLength == 0)
		{
			alert("There is no " + sourceName +  " to be removed.");
			source.focus();
			return;
		}    
	arrSelected = new Array();
	var count = 0;
		for (i = 0; i < boxLength; i++) 
		{
			if (source.options[i].selected) 
			{
				arrSelected[count] = source.options[i].value;
			}
			count++;			
		}		
		if (source.value =="")
			{
				alert("Please select the " + sourceName +  " to be removed before clicking on the Remove button.");
				source.focus();
				return;
			}					
		for (i = 0; i < boxLength; i++) 
		{
			for (x = 0; x < arrSelected.length; x++) 
			{
				if (source.options[i].value == arrSelected[x]) 
				{
					source.options[i] = null;
				}	
			}
				boxLength = source.length;
		}       
}


/* Current date script */

var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()+1
if (month<10)
month="0"+month
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym



/* End Of Current date Script */


function ValidateMaxLength(source,intLength,strSourceName)
{
	if (source.value.length > intLength)
	{
	
		alert("Please enter only " + intLength + " characters in " + strSourceName + "." );
		source.focus();	
		source.select();
		return false;
	}
	else
	{
		return true;
	}	
}


function ConvertProperCase(Field)
{
	var tmpStr;
	tmpStr=Field.value;
	tmpStr = stripBlanks(Field.value);
	Field.value=tmpStr;
	tmpStr = tmpStr.substr(0,1).toUpperCase() + tmpStr.substr(1,tmpStr.length);
	Field.value=tmpStr;
}

function ConvertName(Field)
{
	
 /*var index;
 var tmpStr;
 var tmpChar;
 var preString;
 var postString;
 var strlen;

 tmpStr = Field.value.toLowerCase();
 strLen = tmpStr.length;
	if (strLen > 0)  
	{
		for (index = 0; index < strLen; index++)  
		{
			if (index == 0)  
			{
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}
			else 
			{
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))  
				{
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
         			}
      			}
   		}
	}
	Field.value = tmpStr;
*/

	var tmpStr;

	tmpStr=Field.value;
	tmpStr = stripBlanks(Field.value);
	Field.value=tmpStr;
	
	tmpStr = tmpStr.substr(0,1).toUpperCase() + tmpStr.substr(1,tmpStr.length).toLowerCase();
	Field.value=tmpStr;


	
}