function print(pUrl) {
	var h = 800;
	var w = 750;
	
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+', scrollbars=yes'
	URL = window.location.href;
	
	//alert(URL);
	
	if(URL.search("&lg=" != -1)){
		URL = URL.substr(0, URL.search("&lg="));
	}
	
		
	
	if(URL.indexOf('?') > 0){
		var url = URL+"&lg=Print";	
	}
	else{
		var url = URL+"?lg=Print";
	}
	;
	
	

	var win = window.open(pUrl, "print", winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

}



function gotoURL(pUrl) {
	var aUrl = pUrl.split("_atarget_");
	var tUrl = '';
	if(aUrl.length>1) {
		pUrl = aUrl[0];
		tUrl = aUrl[1];
	}
	if (tUrl == '') { 
		location.href = pUrl;
	} else {
		nWindow = window.open(pUrl,tUrl);
	}
}
	

function postLogin()
{
	document.mainform.action="/login.aspx";
	document.mainform.method="post";
	document.mainform.submit();
}

function postSearch(searchStr,searchSite){
if(searchSite == undefined){
var searchSite = "";
}
    
if(searchStr != ""){
    document.forms[0].__VIEWSTATE.disabled = true;
    document.forms[0].btnQuickSearch.disabled = true;
    document.mainform.method="get";
    
	//document.mainform.__VIEWSTATE.value = "";
	//document.mainform.inputQuickSearch.value = searchStr;
	//document.mainform.method="post";
	//document.mainform.action="/search.aspx?search="+searchStr;
	//document.mainform.submit();
	var searchAll = "";
	if(document.forms[0].searchAll){
	for (i=0;i<document.forms[0].searchAll.length;i++) {
	if (document.forms[0].searchAll[i].checked) {
		searchAll = document.forms[0].searchAll[i].value;
	}
    }
	}
	
	location = "/search.aspx?q="+searchStr+searchAll+searchSite;
}
else{
	return false
}
}

function checkEnter(e,caller) //e is event object passed from function invocation
{

	var characterCode //literal character code will be stored in this variable

	if(e && e.which ||e.which == 0)
	{ //if which property of event object is supported (NN4)
	
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13)//if generated character code is equal to ascii 13 (if enter key)
	{ 
	    if(document.all){
		    e.returnValue=false;
            e.cancel = true;
        }
        else{
         e.preventDefault();
        }
        var obj = document.getElementById(caller);
        if(obj){        
            
            if(obj.click){
		        obj.click();
		    }
		}
		return false
	}
	else
	{
		return true
	}
		
}


function findArchivedNewsByDate(query){
	theForm = document.mainform;
	sdObj = theForm.start_day;
	smObj = theForm.start_month;
	syObj = theForm.start_year;
	edObj = theForm.end_day;
	emObj = theForm.end_month;
	eyObj = theForm.end_year;

	sd = sdObj.options[sdObj.selectedIndex].value;
	sm = smObj.options[smObj.selectedIndex].value;
	sy = syObj.options[syObj.selectedIndex].value;
	ed = edObj.options[edObj.selectedIndex].value;
	em = emObj.options[emObj.selectedIndex].value;
	ey = eyObj.options[eyObj.selectedIndex].value;
//20051205
	window.location.href ="/News/Archive.aspx?startDate="+sy+sm+sd+"&endDate="+ey+em+ed+query;
}



/* Functions for Subscribe for Schedule section  */
function changeSubscriptionFrequency(frequencyPeriod) {

    var divDaily = document.getElementById("divDaily");
    var divWeekly = document.getElementById("divWeekly");
    var divMonthly = document.getElementById("divMonthly");
  
	if (frequencyPeriod == "1") {
		divDaily.style.display = "inline";
		divWeekly.style.display = "none";
		divMonthly.style.display = "none";
	}
	else if (frequencyPeriod == "2") {
		divDaily.style.display = "none";
		divWeekly.style.display = "inline";
		divMonthly.style.display = "none";
	}
	else if (frequencyPeriod == "3") {
		divDaily.style.display = "none";
		divWeekly.style.display = "none";
		divMonthly.style.display = "inline";
	}
}


function subscribeScheduleValidation(source, arguments)
{
	var fullUrl = '' + this.location;
	if ((fullUrl.indexOf("fromRegion") > 0) && (fullUrl.indexOf("toRegion") > 0) ) 
	{
		arguments.IsValid=true;
	}
	else 
	{
		arguments.IsValid=false;
	}

}


/* PopUp Email*/


function showSource(pUrl,w,h) {
	window.name = "mainWindow";
	var l= getWindowPosition("width")-(w/2);
	var t= getWindowPosition("height")-(h/2);
	var popup = window.open(pUrl, 'popup', 'width='+w+',height='+h+',left='+l+',top='+t+', resizable=yes');          
	
}


function getWindowPosition(dim){
  var myWidth = 0, myHeight = 0;
// a little check cos IE doens't support window innerWidth

  if(typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
 
    theTop = document.documentElement.scrollTop;
    theHeight = window.innerHeight/2;
  
	theLeft = document.documentElement.scrollLeft;
    theWidth  = window.innerWidth/2;
    
    myWidth = theLeft+theWidth;
    myHeight = theTop+theHeight;

  }
  else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight )) {
    //IE 6+ in 'standards compliant mode'
    theTop = document.documentElement.scrollTop;
    theHeight = document.documentElement.clientHeight/2;
  
	theLeft = document.documentElement.scrollLeft;
    theWidth  = document.documentElement.clientWidth/2;
       
    myWidth = theLeft+theWidth;
    myHeight = theHeight+theTop;

  } else if( document.body && (document.body.clientWidth || document.body.clientHeight )) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  if(dim == 'width'){
	return myWidth;
  }
  else{
	return myHeight;
  }

}



function getBodyContent() {
			
		var openerWindow = opener.window.document.getElementById("content");
		
		//For Port2Port Search details window get content from "results" div
		if (!openerWindow) {
			openerWindow = opener.window.document.getElementById("details");
		}
		
		var content = openerWindow.innerHTML;
		
		var imgTag = /<img[^>]*>/g;
		var imgTagCaps = /<IMG[^>]*>/g;
		var imgTagClose = /<\/img[^>]*>/g;
		var imgTagCapsClose = /<\/IMG[^>]*>/g;
		var sendByEmail = /<A class=print[^>]*>[^>]*<\/A>/g;
		var sendByEmail2 = /<a [^>]* class="print">[^>]*<\/a>/g;
		var printAsPDF = /<A [^>]*>[^>]*Print as PDF<\/A>/g;
		var printAsPDF2 = /<a [^>]*print[^>]*>[^>]<\/a>/g;
		
		var strippedHTML = content.replace(imgTag,"");
		strippedHTML = strippedHTML.replace(imgTagCaps,"");
		strippedHTML = strippedHTML.replace(imgTagClose,"");
		strippedHTML = strippedHTML.replace(imgTagCapsClose,"");
		strippedHTML = strippedHTML.replace(sendByEmail,"");
		strippedHTML = strippedHTML.replace(sendByEmail2,"");
		strippedHTML = strippedHTML.replace(printAsPDF,"");
		strippedHTML = strippedHTML.replace(printAsPDF2,"");
		
		document.getElementById("emailContent").value = strippedHTML;
		
		
}




/****/



/* PopUp Port 2 Port Search*/

function p2pPopupOpen(url) {

	var ref = window.open(url,'Mailenven','toolbar=false,menubar=false,resizable=yes,scrollbars=yes,top=250,left=200,width=500,height=500');
	ref.focus();

}


