var curObj;
var preObj;

var iframeObj = '<iframe frameborder="0"></iframe>';
$(document).ready(function() {
                // Premium Content pulldowns
                $("#premiumContentNav>ul").children("li").hoverIntent(function() {
                                $("#premiumContentNav ul ul").hide();
                                $(this).children("iframe").slideDown(200);
                                $(this).children("ul").slideDown(200);
                },function(){
                                $(this).children("ul").hide();
                                $(this).children("iframe").hide();
                });

				//Header Nav Pull Down Menus

				$("#gnav2>ul").children("li").hoverIntent(function() {
								//if ($(this).classname =="subNav"){ $(this).prepend(iframeObj); }
								if($(this).is(".subNav")){ $(".subNav ul").before(iframeObj); }
                                $("#gnav2 ul ul").hide();								
								$(this).children("iframe").slideDown(200);
                                $(this).children("ul").slideDown(200);
                },function(){
                                $(this).children("ul").hide();
								$(this).children("iframe").hide();
								$(this).children("iframe").remove();
                });

				
                $("#techChannels").children("li").hoverIntent(function() {
                                $("#techChannels li").removeClass("highlighted");
                                $(this).addClass("highlighted");
                },function(){
                });
                /* Scripts for premiumContentBlocks Starts*/
                $("#homePremiumContent .contentBoxBody").children("div").not(":first").css('display','none');
                //making the first li option selected
                $("#premiumContentNav ul ul li:first a").addClass('selected');
                curObj = $("#premiumContentNav ul ul li:first a");
                $("#premiumContentNav ul ul").children("li").click(function() {
                                preObj = curObj;
                                $(preObj).removeClass('selected');
                                curObj = $(this).children("a");
                                $(curObj).addClass('selected');
                });
                /* Scripts for premiumContentBlocks Ends */
				$("#premiumContent").children("li").hoverIntent(function() {
		$("#premiumContent li").removeClass("highlighted");
		$(this).addClass("highlighted");
	},function(){
	});
});

/* Scripts for getContentBlock Starts*/
function getContentBlock(objName)
{
                $(".contentBoxBody").children("div").css('display','none');
                dispObj=document.getElementById(objName);
                $(dispObj).css('display','block');
}
/* Scripts for getContentBlock Ends */

/*Script for printing starts*/

function Clickheretoprint(){
   var disp_setting="toolbar=no,location=no,directories=no,menubar=no,"; 
   disp_setting+="scrollbars=yes,width=550, height=400, left=100, top=25"; 
   var content_vlue = document.getElementById("print_content").innerHTML;
   var content_hdr = document.getElementById("print_header").outerHTML; 
   var content_hdrVal = document.getElementById("print_header").innerHTML;
   var docprint=window.open("","",disp_setting);     
   docprint.document.open(); 
   docprint.document.write('<html><head><title>');
   docprint.document.write(content_hdrVal);
   docprint.document.write('</title>'); 
   docprint.document.write('</head><body><a href="javascript://" style="float: right; color: #000; text-decoration: none;" onclick="self.print()"><img border="0" src="/community/images/content_area/iconPrint.gif"/> Print</a><img src="/community/images/header/risiLogo.gif"/><br/><h1>');         
   docprint.document.write(content_hdrVal);
   docprint.document.write('</h1><p>');
   docprint.document.write(content_vlue);          
   docprint.document.write('</p></body></html>');
   docprint.document.close(); 
   docprint.focus();	
}

/*Script for printing ends*/

// Article Details - Email article
function utf8Encode(string) {
	string = string.replace(/\r\n/g,"\n");
	var utftext = "";

	for (var n = 0; n < string.length; n++) {

		var c = string.charCodeAt(n);

		if (c < 128) {
			utftext += String.fromCharCode(c);
		}
		else if((c > 127) && (c < 2048)) {
			utftext += String.fromCharCode((c >> 6) | 192);
			utftext += String.fromCharCode((c & 63) | 128);
		}
		else {
			utftext += String.fromCharCode((c >> 12) | 224);
			utftext += String.fromCharCode(((c >> 6) & 63) | 128);
			utftext += String.fromCharCode((c & 63) | 128);
		}

	}

	return utftext;
}
function getArticleTitle(){

	
	document.article.emailstoryid.value=document.article.emailstoryid.value;
	document.article.blogtitle.value=replaceAll(document.article.blogtitle.value,'#@@#','"');
	document.article.firstpara.value=replaceAll(document.article.firstpara.value,'#@@#','"');
	document.article.comurl.value=document.article.comurl.value;
	document.article.blogauthor.value=replaceAll(document.article.blogauthor.value,'#@@#','"');
	document.article.pageid.value="articleDetails";
	document.article.action="/email.html";
	document.article.submit();

}

// Blog Details - Email article
function getBlogTitle()
{	
	document.blogarticle.emailstoryid.value=document.blogarticle.emailstoryid.value;
	document.blogarticle.blogtitle.value=replaceAll(document.blogarticle.blogtitle.value,'#@@#','"');
	document.blogarticle.firstpara.value=replaceAll(document.blogarticle.firstpara.value,'#@@#','"');
	document.blogarticle.comurl.value=document.blogarticle.comurl.value;
	document.blogarticle.blogauthor.value=replaceAll(document.blogarticle.blogauthor.value,'#@@#','"');
	document.blogarticle.pageid.value="articleDetails";
	document.blogarticle.action="/email.html";
	document.blogarticle.submit();
}
function gettitle(){
	
	document.comer.emailstoryid.value=document.comer.emailstoryid.value;
	document.comer.blogtitle.value=replaceAll(document.comer.blogtitle.value,'#@@#','"');
	document.comer.firstpara.value=replaceAll(document.comer.firstpara.value,'#@@#','"');
	document.comer.comurl.value=document.comer.comurl.value;
	document.comer.blogauthor.value=replaceAll(document.comer.blogauthor.valu,'#@@#','"');
	document.comer.pageid.value="articleDetails";
	document.comer.action="/email.html";
	document.comer.submit();

}


function replaceAll(Source,stringToFind,stringToReplace){
	  var temp = Source;
	    var index = temp.indexOf(stringToFind);
	        while(index != -1){
	            temp = temp.replace(stringToFind,stringToReplace);
	            index = temp.indexOf(stringToFind);
	        }
	        return temp;
	}

/*Script for Email Ends*/

/*Script for Graph Price Index Starts*/

function priceIndexpublic(){
            var comboValue;
            var rad_val;
            var priceindex = document.getElementById("priceindex");
            var selIndex = document.homeGraph.category.selectedIndex;
            var contxtPath=document.home.contextPath.value;
            comboValue = document.homeGraph.category.options[selIndex].value;
            for (var i=0; i < document.homeGraph.price.length; i++){
               if (document.homeGraph.price[i].checked){
                    rad_val = document.homeGraph.price[i].value;
              }
            }
            document.homeGraph.price[1].disabled=false;
          	document.homeGraph.price[2].disabled=false;            
            if (comboValue=="Pulp & Paper - Graphic Paper" && rad_val=="NORTH AMERICA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-North-America-Graphic-Paper-Price-Index.jpg");
                        
            } 
            else if(comboValue=="Pulp & Paper - Graphic Paper" && rad_val=="ASIA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-Asia-Graphic-Paper-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Graphic Paper" && rad_val=="EUROPE"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-Europe-Graphic-Paper-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Recovered Paper" && rad_val=="NORTH AMERICA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-North-America-Recovered-Paper-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Recovered Paper" && rad_val=="ASIA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-Asia-Recovered-Paper-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Recovered Paper" && rad_val=="EUROPE"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-Europe-Recovered-Paper-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Paper Packaging" && rad_val=="NORTH AMERICA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-North-America-Packaging-Paper-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Paper Packaging" && rad_val=="ASIA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-Asia-Packaging-Paper-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Paper Packaging" && rad_val=="EUROPE"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-Europe-Packaging-Paper-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Pulp" && rad_val=="NORTH AMERICA"){
                     
                     priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-North-America-Pulp-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Pulp" && rad_val=="ASIA"){
                        priceindex.setAttribute("src","http://www.risiinfo.com/images/news_commentary/priceindex/Risi-Asia-Pulp-Price-Index.jpg");
            }
            else if(comboValue=="Pulp & Paper - Pulp" && rad_val=="EUROPE"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/Risi-Europe-Pulp-Price-Index.jpg");
            }else if(comboValue=="Crow's Lumber and Structural Panel Composite" && rad_val=="NORTH AMERICA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/home_lumber.jpg");
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }
            else if(comboValue=="Crow's Lumber and Structural Panel Composite" && rad_val=="ASIA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/home_lumber.jpg");
                        document.homeGraph.price[0].checked=true;
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }
            else if(comboValue=="Crow's Lumber and Structural Panel Composite" && rad_val=="EUROPE"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/home_lumber.jpg");
                      document.homeGraph.price[0].checked=true;
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }else if(comboValue=="Southern Pine Stumpage" && rad_val=="NORTH AMERICA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/home_pine.jpg");
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }
            else if(comboValue=="Southern Pine Stumpage" && rad_val=="ASIA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/home_pine.jpg");
                      document.homeGraph.price[0].checked=true;
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }
            else if(comboValue=="Southern Pine Stumpage" && rad_val=="EUROPE"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/home_pine.jpg");
                      document.homeGraph.price[0].checked=true;
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }
            else if(comboValue=="Wood Biomass Price Index" && rad_val=="NORTH AMERICA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/RISI-Wood-Biomass-Price-Index.jpg");
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }
            else if(comboValue=="Wood Biomass Price Index" && rad_val=="ASIA"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/RISI-Wood-Biomass-Price-Index.jpg");
                      document.homeGraph.price[0].checked=true;
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }
            else if(comboValue=="Wood Biomass Price Index" && rad_val=="EUROPE"){
                        priceindex.setAttribute("src", "http://www.risiinfo.com/images/news_commentary/priceindex/RISI-Wood-Biomass-Price-Index.jpg");
                      document.homeGraph.price[0].checked=true;
                        document.homeGraph.price[1].disabled=true;
                        document.homeGraph.price[2].disabled=true;
            }
      }
      
/*Script for Graph Price Index Ends*/


sfHover = function() { // Start of Nav Javascript
	var nav=document.getElementById("MS_nav");
	if(typeof(nav) !== 'undefined' && nav != null) {
			var sfEls = document.getElementById("MS_nav").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); // End of Nav Javascript


