var slideShowSpeed = 200;// Set slideShowSpeed (milliseconds)		


function f_open_window_max(aURL)
{
   var sOptions;
   sOptions = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes, location=yes, copyhistory=yes';
   sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
   sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();
   sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

   window.open( aURL, "mynewwindow", sOptions );
}

function hbxStrip(a)
{
     a = a.split("|").join("");
     a = a.split("&").join("");
     a = a.split("'").join("");
     a = a.split("#").join("");
     a = a.split("$").join("");
     a = a.split("%").join("");
     a = a.split("^").join("");
     a = a.split("*").join("");
     a = a.split(":").join("");
     a = a.split("!").join("");
     a = a.split("<").join("");
     a = a.split(">").join("");
     a = a.split("~").join("");
     a = a.split(";").join("");
     a = a.split(" ").join("+");

     return a;
}
// toggle visibility
function toggle(targetId, imageId) {
    if (document.getElementById) {
        target = document.getElementById(targetId);
        if (target.style.display == "none") {
            target.style.display = "block";
        } else {
            target.style.display = "none";
        }
        closeAd = document.getElementById(imageId);
        st = closeAd.src;
        if (st.indexOf("CloseAd") == -1) {
            closeAd.src = "http://images.myfoxny.com/img/CloseAd.gif";
        } else {
            closeAd.src = "http://images.myfoxny.com/img/OpenAd.gif";
        }
	  	//End Added
    }
}

function openWindow4Max(popurl) {
	var iTop=0;
	var iLeft=0;
	var iWidth = screen.availWidth;
	var iHeight = screen.availHeight;
 	window.open(popurl, '', "resizable=yes, top=" + iTop + ", left=" + iLeft + ", width=" + iWidth + ", height=" + iHeight + "status=yes, directories=yes,location=yes, menubar=yes, toolbar=yes, scrollbars=yes, resizable=yes, top=0, left=0");
}

function openpopup(popurl) {
	var winpops=window.open(popurl,"","width=760px,height=750px, status=no, scrollbars=no, resizable=yes, top=0, left=0")
}

function openBlank() {
    var openBlank = window.open("", "", "");
}
function openNormalWin(url) {
    var openNormalWin = window.open(url, "", "width=740px,height=700px, status=yes, directories=yes,location=yes, menubar=yes, toolbar=yes, scrollbars=yes, resizable=yes");
}
function openWindowLink(url, params, width, height) {
	var iWidth = width;
	var iHeight = height;
	if(iWidth <= 0)
		iWidth = screen.availWidth;
	if(iHeight <= 0)
		iHeight = screen.availHeight;
	var iTop = 20;//(screen.availHeight - iHeight)/2;
	var iLeft=(screen.availWidth - iWidth)/2 ;	
	var mystyle = "top=" + iTop + "px, left=" + iLeft + "px,width=" + iWidth +"px,height=" +iHeight+"px";
	if(params != null ){
		mystyle = mystyle + "," + params;
		//",status=yes, directories=yes,location=yes, menubar=yes, toolbar=yes, scrollbars=yes, resizable=yes";
	}
    var openWindow = window.open(url, "", mystyle);
}
function emailWindow(popurl) {
    var winpops = window.open(popurl, "", "width=530px,height=370px,status,scrollbars=no");
}
function openWindow(popurl, width, height) {
    var st = "width=" + width + "px, height=" + height + "px, status,scrollbars=no, top=0, left=0";
    var winpops = window.open(popurl, "", st);
}
function openPrintFriendly(popurl, width, height) {
    var st = "width=" + width + "px, height=" + height + "px, status,scrollbars=yes";
    var winpops = window.open(popurl, "", st);
}
function setImgUrl() {
	var sLink = path + "/MyFox/pages/radar_popup.jsp?src=" + document.getElementById("largeImg").src;
	sLink = sLink + "&title=Doppler Radar and Satellite Imagery&siteId=" + siteId;
	sLink = sLink + "&l1_type_code=" + document.getElementById("current_l1_type_code").value;
	sLink = sLink + "&l2_type_code=" + document.getElementById("current_l2_type_code").value;
	sLink = sLink + "&l2_order=" + document.getElementById("current_l2_order").value;
	sLink = sLink + "&portletType=" + document.getElementById("portletType").value;
	sLink = sLink + "&runLoop=" + document.getElementById("runLoop").value;

	if(document.getElementById("logoImg"))
	{
		sLink = sLink + "&logoImageParam=" + document.getElementById("logoImg").src;
	}
    document.getElementById("hrefImage").href = "javascript:openpopup('" + sLink + "')";
    document.getElementById("hrefLargeImage").href = "javascript:openpopup('" + sLink + "')";
}

function setImgUrlP33(siteId, contextPath) {
	var sLink = contextPath + "/MyFox/pages/radar_popup.jsp?src=" + document.getElementById("largeImg").src;
	sLink = sLink + "&title=Doppler Radar and Satellite Imagery&siteId=" + siteId;
	sLink = sLink + "&l1_type_code=" + document.getElementById("current_l1_type_code").value;
	sLink = sLink + "&l2_type_code=" + document.getElementById("current_l2_type_code").value;
	sLink = sLink + "&l2_order=" + document.getElementById("current_l2_order").value;
	sLink = sLink + "&portletType=" + document.getElementById("portletType").value;
	sLink = sLink + "&runLoop=" + document.getElementById("runLoop").value;

	if(document.getElementById("logoImg"))
	{
		sLink = sLink + "&logoImageParam=" + document.getElementById("logoImg").src;
	}
    document.getElementById("hrefImage").href = "javascript:openpopup('" + sLink + "')";
    document.getElementById("hrefLargeImage").href = "javascript:openpopup('" + sLink + "')";
}
function showLargeImg_p33(src, typeCode) {
    document.getElementById("runLoop").value = "0";
    document.getElementById("largeImg").src = src;
    document.getElementById("current_l2_type_code").value = typeCode;
    document.getElementById("current_l2_order").value = "1";
    extractList();
}
function showLargeImg(image) {
    document.getElementById("runLoop").value = "0";
    if (image != null) {
        var id = image.id;
        var l2TypeCode = image.name;
        if (id.indexOf("RDR") != -1) {
            document.getElementById("current_l1_type_code").value = "RDR";
        }
        if (id.indexOf("SAT") != -1) {
            document.getElementById("current_l1_type_code").value = "SAT";
        }
        document.getElementById("largeImg").src = image.src;
        document.getElementById("current_l2_type_code").value = l2TypeCode;
        document.getElementById("current_l2_order").value = image.value;
        extractList();
    }
}
function putToMainList(Key, Value) {
    aMainListKey[nIndex] = Key;
    aMainListValue[nIndex] = Value;
    nIndex++;
}
function loopImg() {
    if (document.getElementById("runLoop").value == "0") {
        j = 0;
        document.getElementById("runLoop").value = "1";
        runSlideShow();
    } else {
        document.getElementById("runLoop").value = "0";
        document.getElementById("largeImg").src = preLoad[0].src;
    }
}
function runSlideShow() {
    if (document.getElementById("runLoop").value == "1") {
        var p = Pic.length;
        j = j + 1;
        if (j > (p - 1)) {
            j = 0;
        }
        document.getElementById("largeImg").src = preLoad[j].src;
        t = setTimeout("runSlideShow()", slideShowSpeed);
    }
}
function extractList() {
    var Key = document.getElementById("current_l1_type_code").value + "_" + document.getElementById("current_l2_type_code").value;
    Pic = new Array();
    nPicCount = 0;
    for (i = 0; i < nIndex; i++) {
        if (aMainListKey[i] == Key) {
            Pic[nPicCount++] = aMainListValue[i];
        }
    }
    preLoad = new Array();
    var p = Pic.length;
    for (i = 0; i < p; i++) {
        preLoad[i] = new Image();
        preLoad[i].src = Pic[i];
    }
}
function openPhotosSideBar(popurl) {
    var winpops = window.open(popurl, "", "width=750px,height=520px,margin-left:auto,margin-right:auto,status,scrollbars=yes");
}

function changeBigImgSideBar(source, index) {
    if (source != null) {
        if (document.getElementById("imageCaption") != null)
            document.getElementById("imageCaption").innerHTML = pictureCaptions[index];
        
        if (document.getElementById("showedImage") != null){
            document.getElementById("showedImage").src = source;
        }
        else{
        	if (document.getElementById("showedImageDiv") != null){
	        	var innerImage = '<img src="' + source + '" id="showedImage">';
    	    	document.getElementById("showedImageDiv").innerHTML = innerImage;
    	    }
        }
    }
}

/**
	*Check contact us form error
	**/
function checkError() {
    var emailID = document.contact_us.email;
    if (document.contact_us.userName.value == "") {
        alert("Please provide your first and last name within the field provided.");
        document.contact_us.userName.focus();
        return false;
    }

		//check zip code
    var st = document.contact_us.zipcode.value;
    if ((st.length != 5) || (/[^0-9]/.test(st))) {
        alert("Please provide a valid 5-digit zip code within the field provided.");
        document.contact_us.zipcode.focus();
        return false;
    }
    if ((emailID.value == null) || (emailID.value == "")) {
        alert("Please provide your email address within the field provided.");
        emailID.focus();
        return false;
    }
    if (echeck(emailID.value) == false) {
        alert("Please provide a valid email address within the field provided.");
        emailID.focus();
        return false;
    }
    if (document.contact_us.topic.value == "0") {
        alert("Please select a comment topic from the dropdown list provided.");
        document.contact_us.topic.focus();
        return false;
    }
	
	// Added 21-04-06 for Comments Text Area - JMSM
	if(document.contact_us.comments.value == '')
		{
			alert('Please provide your comments within the field provided.');			
			document.contact_us.comments.focus();
			return false;
		}
		
    if (document.contact_us.age.checked == false) {
        alert("In order to submit a comment, you must be 13 years of age or older.");
        document.contact_us.age.focus();
        return false;
    }
		//check over 13 of age
    if (!document.contact_us.age.value) {
        alert("In order to submit a comment, you must be 13 years of age or older.");
        return false;
    }
		//alert('All data is OK, submit to server. Thanks!');
    document.contact_us.submit();
		//TODO: must return true to submit data to server, this is only for validating data 
    return false;
}
/*
	* Check email validation
	*/
function echeck(str) {
    var at = "@";
    var dot = ".";
    var lat = str.indexOf(at);
    var lstr = str.length;
    var ldot = str.indexOf(dot);
    if (str.indexOf(at) == -1) {
        return false;
    }
    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
        return false;
    }
    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
        return false;
    }
    if (str.indexOf(at, (lat + 1)) != -1) {
        return false;
    }
    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        return false;
    }
    if (str.indexOf(dot, (lat + 2)) == -1) {
        return false;
    }
    if (str.indexOf(" ") != -1) {
        return false;
    }
    return true;
}
function replaceLayerContent(name, content) {
    var theObj = document.getElementById(name);
    if (theObj != null) {
        theObj.innerHTML = content;
        return true;
    }
    return false;
}
function showLayer(name) {
    var layer = getLayer(name);
    layer.visibility = "visible";
}
function changeLargeImg(source) {
    if (source != null) {
        document.getElementById("mainImage").src = source;
    }
}
function getMainImageSrc(siteId, path) {
    var linkImg = "javascript:openpopup('" + path + "/MyFox/pages/radar_popup.jsp?src=" + document.getElementById("mainImage").src + "&siteId=" + siteId + "&portletType=p31" + "&title=Watches and Warnings')";
    document.getElementById("hrefImage").href = linkImg;
    document.getElementById("lookUpImg").href = linkImg;
}
function createLayer(name, inleft, intop, width, height, visible, content) {
    document.writeln("<div id=\"" + name + "\" style=\"position:absolute; overflow:hidden; left:" + inleft + "px; top:" + intop + "px; width:" + width + "px; height:" + height + "px;" + "; z-index:1; visibility:" + (visible ? "visible;" : "hidden;") + "\">");
    document.writeln(content);
    document.writeln("</div>");
}

function checkZipCode() {
    var st = document.searchZip.searchtoken.value;
    if ((st.length != 5) || (/[^0-9]/.test(st))) {
        alert("Please provide a valid 5-digit zip code within the field provided.");
        document.searchZip.searchtoken.value = "";        
        document.searchZip.searchtoken.focus();
        return false;
    }
    return true;
}

function checkCityName() {
    var st = document.searchCity.loc.value;
    if ((st != "") && (/[^A-Z,a-z, ]/.test(st))) {
        alert("Please provide a valid city name or fragment.");
        document.searchCity.loc.value = "";        
        document.searchCity.loc.focus();
        return false;
    }
    return true;
}

function checkWeatherForm() {
    var st = document.weatherSearch.searchtext.value;
    if ((st.length != 5) || (/[^0-9]/.test(st))) {
	    if ((st != "") && (/[^A-Z,a-z, ]/.test(st))) {
	        var obj = document.getElementById("formError");
	        obj.innerHTML = "Please enter a valid Zip Code or City.";
	        document.weatherSearch.searchtext.value = "";        
	        document.weatherSearch.searchtext.focus();
	        return false;
	    }
	    else {
	    	document.weatherSearch.searchtoken.value = "";	    
	    	document.weatherSearch.loc.value = st;
	    	document.weatherSearch.context.value = "city";	    	
	    }
	}
	else {
    	document.weatherSearch.loc.value = "";
    	document.weatherSearch.context.value = "";	    	
    	document.weatherSearch.searchtoken.value = st;
	}
    return true;
}

function formSubmit() {
	document.conditions.submit();
}

function putToLeftLinkList(Key, Name) {
    for (i = 0; i < iLeftLinks_index; i++) {
        if (aLeftLinks_key[i] == Key) {
			return;
        }
    }
    aLeftLinks_key[iLeftLinks_index] = Key;
    aLeftLinks_name[iLeftLinks_index] = Name;
    iLeftLinks_index++;
}

function putToSubLinkList(MainKey, Key, Name, Pic) {		
	aSubLinks_main_key[iSubLinks_index] = MainKey;
    aSubLinks_key[iSubLinks_index] = Key;
    aSubLinks_name[iSubLinks_index] = Name;
    aSubLinks_pic[iSubLinks_index] = Pic;		    
    iSubLinks_index++;
}

function createHtmlLinks() {			
    for (i = 0; i < iLeftLinks_index; i++) {		    	
    	var mainKey = aLeftLinks_key[i];
    	var text = '<p style="width:300px;float:right;color:white;"> <br>';
    	var count = 0;
    	
    	for (j = 0; j < iSubLinks_index; j++){		    		
	    	if(aSubLinks_main_key[j] == mainKey){
	    		var pic = aSubLinks_pic[j];
	    		var name = aSubLinks_name[j];
	    		
	    		if(count > 0)
	    			text = text + ' |';
	    		text = text + ' <a href="javascript:changeLargeImg_p32(\'' + mainKey +
	    				'\',\'' + pic + '\');">' + name + '</a>';			    		
	    		count++;
	    	}			    	
    	}
    	
    	text = text + ' </p>';
    	
    	aHtmlLinks[i] = text;		    	
    }		    
}

function showMenu(sMenu){		
	replaceLayerContent("subMenu", aHtmlLinks[sMenu]);			
}				
function displayLeftLinks(){		
    for (i = 0; i < iLeftLinks_index; i++) {
    	var key = aLeftLinks_key[i];
    	var name = aLeftLinks_name[i];
    	var pic;
    	
    	for (j = 0; j < iSubLinks_index; j++){		    		
	    	if(aSubLinks_main_key[j] == key){
	    		pic = aSubLinks_pic[j];
	    		break;
	    	}			    	
    	}			    	
		var text = '<p style="width:63px;padding:5px 0 0 0;"><a href="javascript:changeLargeImg_p32(\'' +
						key + '\', \'' +
						pic + '\');showMenu(' + i + ');" style="color:white;">' + name + '</a></p>';

		document.write(text);
	}
}

function getFlashPluginVersion() 
{ 
  var version = { 
        major: -1, 
        minor: -1, 
        installed: false,
        scriptable: false
      };

  var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; 
  if (!plugin) 
  {
    return version;
  }

  version.installed = true;

  var description = plugin.description; 
  
  // use RegExp to obtain the relevant version strings 
  // obtain an array of size 2 with version information
  
  var versionArray = description.match(/[\d.]+/g); 
  
  if (!versionArray)
  {
    return version;
  }

  if (versionArray.length >= 1 && !isNaN(versionArray[0]))
  {
    version.major = parseFloat(versionArray[0]);
  }

  if (versionArray.length >= 2 && !isNaN(versionArray[1]))
  {
    version.minor = parseFloat(versionArray[1]);
  }
    
  if (version.major < 6 || navigator.product != 'Gecko')
  {
    return version;
  }

  if (version.major > 6 || version.minor >= 47)
  {
    version.scriptable = true;
  }

  return version;
}

function identifyFlash() 
{ 

  if ((window.ActiveXObject) && 
      (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
  {  
     return;
  }

  var flashversion = getFlashPluginVersion();
  var major = getFlashPluginVersion().major;
  var minor = getFlashPluginVersion().minor;
 
  if (!getFlashPluginVersion().installed)
  {
    document.write("<p><strong>Flash is not installed as a plugin. " +
                   "You need to install the latest version available from " +
                   "<a href='http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&P5_Language=English'>here.<\/a>" +
                   "<\/strong><\/p>");
    return;
  }

  if (major == -1 || minor == -1 || major < 8)
  {
     document.write("<p><strong>Compatible flash player is not installed. " +
                   "Because you are running Firefox and do not have the latest version of Flash installed, you need to uninstall your current version of Flash and install the latest version available from " +
                   "<a href='http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&P5_Language=English'>here.<\/a>" +
                   "<\/strong><\/p>");
    return;
  }
  return;
 }

 
 function showLargeImg_thumbnail(image, imgSrc, looping, redirectUrl) {
    document.getElementById("runLoop").value = "0";
    if (image != null) {
        var id = image.id;
        var l2TypeCode = image.name;
        if (id.indexOf("MANRDR") != -1) {
            document.getElementById("current_l1_type_code").value = "MANRDR";
        }
        if (id.indexOf("SAT") != -1) {
            document.getElementById("current_l1_type_code").value = "SAT";
        }
        document.getElementById("largeImg").src = imgSrc;
        document.getElementById("current_l2_type_code").value = l2TypeCode;
        document.getElementById("current_l2_order").value = image.value;
        if (redirectUrl != '') {
		    document.getElementById("hrefImage").href = "javascript:f_open_window_max('" + redirectUrl + "');";
		    document.getElementById("hrefLargeImage").href = "javascript:f_open_window_max('" + redirectUrl + "');";			
		    document.getElementById("hrefLargeImage").onmousemove = "javascript:f_open_window_max('" + redirectUrl + "');";
		    document.getElementById("hrefImage").onclick="javascript:f_open_window_max('" + redirectUrl + "');";		    
	    } else {
			setImgUrl();
		    document.getElementById("hrefLargeImage").onmousemove = "javascript:setImgUrl();";	    
		    document.getElementById("hrefImage").onclick="javascript:setImgUrl();";
	    }   
	    if (looping == 'Y') {
			document.getElementById("largeImageTd").style.display="block";
	    } else {
			document.getElementById("largeImageTd").style.display="none";	    
	    }
        extractList();
    }
}

//Helper functions for trimming title and abstract with a given line
function trimTitle(sProcessLayerName, nLineNum){
	var pProcessLayer = document.getElementById(sProcessLayerName);	
	if (pProcessLayer == undefined)
		return;			
	var sTitle = document.getElementById(sProcessLayerName).innerHTML;
	var i =0;
	var sText = "";
	pProcessLayer.innerHTML = "&nbsp;"; 		
	var nReqHeight = pProcessLayer.offsetHeight*(nLineNum + 0.5);
	sText = sTitle;
	if(sText.length > 10){
		var pWords = sText.split(" "); 
		var sTmp ="";
		sText = "";		
		for (i=0; i < pWords.length; i++){
			sTmp += " " + pWords[i];
			pProcessLayer.innerHTML = sTmp + "...";
			if (pProcessLayer.offsetHeight >= nReqHeight){
				sTitle = sText  + "...";
				bFound = true;				
				break;
			}
			sText = sTmp;						
		}
	}
	pProcessLayer.innerHTML = sTitle; 
	pProcessLayer.visibility = "visible"; 
}	
//
function trimAbstract(sProcessLayerName, nLineNum, hrefId){
	var pProcessLayer = document.getElementById(sProcessLayerName);
	if (pProcessLayer == undefined)
		return;		
	var sAbstract = document.getElementById(sProcessLayerName).innerHTML;
	var i =0;
	var sText = "";
	var pHref =  document.getElementById(hrefId);
	var sHref = "#";
	if (pHref != undefined)
	 	sHref = pHref.href;	
	var bFound = false;
	pProcessLayer.innerHTML = "&nbsp;"; 		
	var nReqHeight = pProcessLayer.offsetHeight*(nLineNum + 0.5); 
	var nPreditChars = 1* (pProcessLayer.offsetWidth*nLineNum)/pProcessLayer.offsetHeight;		
	
	var nPos = sAbstract.indexOf("<");
	if (nPos >=0){
		sAbstract = sAbstract.substr(0,nPos);
	}	
	sText = sAbstract;
	
	//alert("Before\n" + sAbstract);
	var sTmp ="";
	var sLastWord = "";
	if(sText.length > 10){
		var pWords = sText.split(" "); 		
		sText = "";		
		sTmp ="";
		//Skip to predit words count
		for (i=0; i < pWords.length; i++){
			sTmp += pWords[i]+" ";
			if ( sTmp.length >= nPreditChars){
				sTmp = sText;				
				break;
			}
			sLastWord = pWords[i];
			sText = sTmp;
		}		
		//Continue put word and measure the layer height
		for ( ; i < pWords.length; i++){
			sTmp += pWords[i] + " ";
			pProcessLayer.innerHTML = sTmp + "...<a href='"+ sHref +"' >&gt;&gt;More</a>";
			sLastWord = pWords[i];
			if (pProcessLayer.offsetHeight >= nReqHeight){
				sAbstract = sText;				
				bFound = true;				
				break;
			}			
			sText = sTmp;						
		}		
		if (i < pWords.length){
			var bAdded = false; 
			for (i=0; i < sLastWord.length; i++){
				pProcessLayer.innerHTML = sAbstract + " " + sLastWord.substr(0,i+1) + "...<a href='"+ sHref +"' >&gt;&gt;More</a>";				
				if (pProcessLayer.offsetHeight >= nReqHeight){
					sAbstract = sAbstract + sLastWord.substr(0,i);				
					bAdded = true;
					break;
				}
			} 
			if ((!bAdded) && (i>1)){				
				sAbstract = sAbstract + sLastWord.substr(0,i-1);
			}
		}						
	}	
	//Update More link and prevent duplicate More link
	sHref = sHref.replace(/'/g,"\"");
	if (!bFound){
		if (sAbstract.indexOf("<a href") < 0){
			sAbstract = sAbstract + "<a href='"+ sHref +"' >&gt;&gt;More</a>";
		}
	}
	else{
		if (sAbstract.indexOf("<a href") < 0){
			while(sAbstract.length > 0){
				if (sAbstract.substr(sAbstract.length-1,1)=="."){
					sAbstract = sAbstract.substr(0,sAbstract.length-1);
				}
				else{
					break;
				}
			}
			sAbstract = sAbstract + "...<a href='"+ sHref +"' >&gt;&gt;More</a>";
		}
	}
	
	pProcessLayer.innerHTML = sAbstract;
	//pProcessLayer.visibility = "visible"; 
}
//
//var arUpdatedPortlets = new Array();
function updateAllPortlet(){	
	for(var i =1; i <16; i++){
		eval(" if (this.updateP3Story"+i+" !=undefined){updateP3Story"+i+"();}");
		eval(" if (this.updateP3Home"+i+" !=undefined){updateP3Home"+i+"();}");
		eval(" if (this.updateP11Portlet"+i+" !=undefined){updateP11Portlet"+i+"();}");				
		eval(" if (this.updateP20Portlet"+i+" !=undefined){updateP20Portlet"+i+"();}");
		eval(" if (this.updateP21Story"+i+" !=undefined){updateP21Story"+i+"();}");
	}	
	eval(" if (this.updateP11Portlet !=undefined){updateP11Portlet();}");
}

function LoadingTimeOver(){
	//alert("Loading time is over...");
	//updateAllPortlet();
}
//setTimeout("LoadingTimeOver()", 25000); //Loading timeover is milisecs

//End of Trimming Helper Functions------------------
// Alert smoothly
var copyspeed = 1;
function initScroll(){	
	var cross_marquee = document.getElementById("iemarquee");
	var marqueewidth = document.getElementById("scrolling_text_boudary").offsetWidth;
	
	cross_marquee.style.left=parseInt(marqueewidth)+8+"px";	
	var pTemp = document.getElementById("temp");
	pTemp.innerHTML = cross_marquee.innerHTML;
	
	if (navigator.userAgent.indexOf("Firefox")!=-1||navigator.userAgent.indexOf("Netscape")!=-1
	||navigator.userAgent.indexOf("Opera")!=-1) 
	lefttime=setInterval("scrollmarquee()",1);
	
	if (navigator.userAgent.indexOf("MSIE")!=-1) 
	lefttime=setInterval("scrollmarquee()",5);	
}
function scrollmarquee(){		
	var actualwidth= document.getElementById("temp").offsetWidth;
	var marqueewidth = document.getElementById("scrolling_text_boudary").offsetWidth;
	var cross_marquee = document.getElementById("iemarquee");
	if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+ 8)){
		cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px";
	}	
	else{
		cross_marquee.style.left=parseInt(marqueewidth)+8+"px";		
	}
}
// End Alert smoothly

function addToPictureCaptions(text)
{
	text = text.replace(/\n/g, " ");
	pictureCaptions[i1] = text;
	i1++;
}			

function goAirportMap(airprt) {
	var thePath = "http://www.fly.faa.gov/flyfaa/flyfaaindex.jsp?ARPT=" + airprt + "&p=0";
	var openResults = window.open(thePath,'results','toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500');
    openResults.focus();
}
/*Alerts & Breaking News, updated on Aug 01, 2006 (It is moved from P13_breaking_news_alerts_portlet.jsp) */
var newsLinks = Array();		
	newsLinks[0]="";
var alertsLinks = "" ;	
function addToNewsLink(text, n)
{
	text = text.replace(/\n/g, " ");
	text = text.replace(/'/g,"\"");
	newsLinks[n] = text;

}
function addToAlertLink(text)
{		
	text = text.replace(/'/g,"\"");
	text = text.replace(/\n/g, " ");		
	alertsLinks += text;
}	
var iBreaking = 0;	
function FoxClock(){
	if (++iBreaking >= newsLinks.length) 
		iBreaking = 0;
	if (newsLinks.length>0){			
		document.write('<div id="text_scroll_breaking"></div>');
		replaceLayerContent("text_scroll_breaking", newsLinks[iBreaking]);			
	}
}
/*End of Alerts & Breaking News */

/* Return the Popup script for poll link */
function pollPopLink(url) { 
  var name = 'story'; 
  wdt = screen.width; 
  ht = screen.height; 
  var params = 'width='+wdt+',height='+ht+',scrollbars=yes,menubar=1,resizable=1, location=1, directories=1'; 
  win = window.open(url, name, params); 
  return false; 
} 

function pollSubmitForm(label, pollKey){ 
  if (!pollCheckAnswer() && (pollCheckCookies(pollKey))){ 
  	alert('Please make a selection before clicking the "'+label+'" button'); 
  }else{ 
	document.pollForm.submit(); 
  } 
} 
function pollCheckAnswer(){ 
  var answer = false; 
  for(var i=0; i<document.pollForm.pollAnswer.length; i++) { 
	  if(document.pollForm.pollAnswer[i].checked) { 
		  answer = true;
		  break;
	  } 
	} 
  return answer;
} 
function pollCheckCookies(pollKey){
 var cookies = document.cookie.split(';'); 
 for(var i=0; i<cookies.length; i++){
 if((pollKey).equals(cookies[i].getName())){
   return true;
   break;
 }
}
}


