var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Opera, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}
function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
var myUrl=location.href;
var patt1=/\.html/g;
if (myUrl.match(patt1))
{
var x = document.language.lanOpt.selectedIndex;
if (x==0)
{
var selLanguage = "en"
var url=location.pathname;
//document.write(url);
//document.write("<br/>");
SplitName = url.split("/");
for (i=0; i<SplitName.length;i++)
{
if (SplitName[i].length==2 && SplitName[i]!="iw")
{
//document.write(SplitName[i]);
//document.write("<br/>");
SplitName[i]=selLanguage;
//document.write(SplitName[i]);
//document.write("<br/>");
}
}
var pageUrl = SplitName.join("/") ;
window.open(pageUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
if (x==1)
{
var myopt=document.language.lanOpt;
    var my_url = myopt.options[myopt.selectedIndex].value;
window.open(my_url,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
if (x==2)
{
var selLanguage = "jp"
var url=location.pathname;
//document.write(url);
//document.write("<br/>");
SplitName = url.split("/");
for (i=0; i<SplitName.length;i++)
{
if (SplitName[i].length==2 && SplitName[i]!="iw")
{
//document.write(SplitName[i]);
//document.write("<br/>");
SplitName[i]=selLanguage;
//document.write(SplitName[i]);
//document.write("<br/>");
}
}
var pageUrl = SplitName.join("/") ;
window.open(pageUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
if (x==3)
{
var selLanguage = "ko"
var url=location.pathname;
//document.write(url);
//document.write("<br/>");
SplitName = url.split("/");
for (i=0; i<SplitName.length;i++)
{
if (SplitName[i].length==2 && SplitName[i]!="iw")
{
//document.write(SplitName[i]);
//document.write("<br/>");
SplitName[i]=selLanguage;
//document.write(SplitName[i]);
//document.write("<br/>");
}
}
var pageUrl = SplitName.join("/") ;
window.open(pageUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
if (x==4)
{
var selLanguage = "pt"
var url=location.pathname;
//document.write(url);
//document.write("<br/>");
SplitName = url.split("/");
for (i=0; i<SplitName.length;i++)
{
if (SplitName[i].length==2 && SplitName[i]!="iw")
{
//document.write(SplitName[i]);
//document.write("<br/>");
SplitName[i]=selLanguage;
//document.write(SplitName[i]);
//document.write("<br/>");
}
}
var pageUrl = SplitName.join("/") ;
window.open(pageUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
if (x==5)
{
var selLanguage = "es"
var url=location.pathname;
//document.write(url);
//document.write("<br/>");
SplitName = url.split("/");
for (i=0; i<SplitName.length;i++)
{
if (SplitName[i].length==2 && SplitName[i]!="iw")
{
//document.write(SplitName[i]);
//document.write("<br/>");
SplitName[i]=selLanguage;
//document.write(SplitName[i]);
//document.write("<br/>");
}
}
var pageUrl = SplitName.join("/") ;
window.open(pageUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
//document.write(selLanguage);
    }
  }
  else
    {
    var x = document.language.lanOpt.selectedIndex;
if (x==0)
{
var myLanguage = "en";
var fullLan ="english";
 var homeUrl="http://www.sabic-ip.com/gep/"+myLanguage+"/Home/Home/home.html"
   var r=confirm("Page is not available in "+fullLan+". Do you want to redirect to the home page of "+fullLan+" website?");
    if (r==true)
  {
  window.open(homeUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
  }
}
if (x==1)
{
var myopt=document.language.lanOpt;
    var my_url = myopt.options[myopt.selectedIndex].value;
window.open(my_url,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
if (x==2)
{
var myLanguage = "jp";
var fullLan ="japanese";
 var homeUrl="http://www.sabic-ip.com/gep/"+myLanguage+"/Home/Home/home.html"
   var r=confirm("Page is not available in "+fullLan+". Do you want to redirect to the home page of "+fullLan+" website?");
    if (r==true)
  {
  window.open(homeUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
  }
}
if (x==3)
{
var myLanguage = "ko";
var fullLan ="korean";
 var homeUrl="http://www.sabic-ip.com/gep/"+myLanguage+"/Home/Home/home.html"
   var r=confirm("Page is not available in "+fullLan+". Do you want to redirect to the home page of "+fullLan+" website?");
    if (r==true)
  {
  window.open(homeUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
  }
}
if (x==4)
{
var myLanguage = "pt";
var fullLan ="portuguese";
 var homeUrl="http://www.sabic-ip.com/gep/"+myLanguage+"/Home/Home/home.html"
   var r=confirm("Page is not available in "+fullLan+". Do you want to redirect to the home page of "+fullLan+" website?");
    if (r==true)
  {
  window.open(homeUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
  }
}
if (x==5)
{
var myLanguage = "es";
var fullLan ="spanish";
 var homeUrl="http://www.sabic-ip.com/gep/"+myLanguage+"/Home/Home/home.html"
   var r=confirm("Page is not available in "+fullLan+". Do you want to redirect to the home page of "+fullLan+" website?");
    if (r==true)
  {
  window.open(homeUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
  }
}
    }
}
}
function my_selectLanguage(){
var myUrl=location.href;
var patt1=/\.html/g;
if (myUrl.match(patt1))
{
var x = document.language.lanOpt.selectedIndex;
if (x==0)
{
var selLanguage = "en";
open_window(selLanguage);
}
if (x==1)
{
var myopt=document.language.lanOpt;
    var my_url = myopt.options[myopt.selectedIndex].value;
window.open(my_url,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
if (x==2)
{
var selLanguage = "jp";
open_window(selLanguage);
}
if (x==3)
{
var selLanguage = "ko";
open_window(selLanguage);
}
if (x==4)
{
var selLanguage = "pt";
open_window(selLanguage);
}
if (x==5)
{
var selLanguage = "es";
open_window(selLanguage);
}
   }
   else {
   var x = document.language.lanOpt.selectedIndex;
   if (x==0)
{
deleteCookie("GEPLanguage");
setCookie("GEPLanguage","en",365);
my_jsp_window();
}
if (x==1)
{
var myopt=document.language.lanOpt;
    var my_url = myopt.options[myopt.selectedIndex].value;
window.open(my_url,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}
if (x==2)
{
deleteCookie("GEPLanguage");
setCookie("GEPLanguage","jp",365);
my_jsp_window();
}
//Changed by sheetal to fix language dropdowm inconsistency, Nov 11, 2010

/*if (x==3)
{
var myopt=document.language.lanOpt;
    var my_url = myopt.options[myopt.selectedIndex].value;
window.open(my_url,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
}*/
if (x==3)
{
deleteCookie("GEPLanguage");
setCookie("GEPLanguage","ko",365);
my_jsp_window();
}
if (x==4)
{
deleteCookie("GEPLanguage");
setCookie("GEPLanguage","pt",365);
my_jsp_window();
}
if (x==5)
{
deleteCookie("GEPLanguage");
setCookie("GEPLanguage","es",365);
my_jsp_window();
}
   }
}
function setCookie(name, value, days) {
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}
function deleteCookie(name){
setCookie(name, "moot")
}
function open_window(selLanguage){
var url=location.pathname;
//document.write(url);
//document.write("<br/>");
SplitName = url.split("/");
for (i=0; i<SplitName.length;i++)
{
if (SplitName[i].length==2 && SplitName[i]!="iw")
{
//document.write(SplitName[i]);
//document.write("<br/>");
SplitName[i]=selLanguage;
//document.write(SplitName[i]);
//document.write("<br/>");
}
}
var pageUrl = SplitName.join("/") ;
//document.write(pageUrl);
loadXMLDoc(pageUrl);
    var opt=document.language.lanOpt;
   // var url = opt.options[opt.selectedIndex].value;
   // if(opt.selectedIndex == 1){
     //window.location.href=pageUrl;
   	//}
   //else{
  // window.open(pageUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
   //  }
}

function my_jsp_window(){
jspUrl=location.href;
   window.open(jspUrl,null, "height=800,width=600,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,titlebar=yes,location=yes,menubar=yes");
   
   //Changed by sheetal to fix the Datasheet issue, 11 nov, 2010
 //deleteCookie("GEPLanguage");  
}


function header(){

document.write("<DIV id=document>");
document.write("<TABLE id=fullwidth border=0 bordercolor=green>");
document.write("<TBODY>");
document.write("<TR>");
document.write("<TD colSpan=3>");
document.write("<br><TABLE width=1141px border=0 bordercolor=pink>");
document.write("<TR>");
document.write("<td width=25px>");
document.write("</td>");
document.write("<TD align=left valign=top>");
document.write(" <A href=\"/gep/"+lang+"/Home/Home/home.html\">");
document.write("<IMG alt=\"sabic-ip.com home\" src=\"../../../css/images/logo_payoff.jpg\">");
document.write("</A>");
document.write("</TD>");
document.write("<TD align=right>");
document.write("<A href=\"/gep/"+lang+"/Home/Home/home.html\">");
document.write("<IMG alt=\"sabic-ip.com home\" src=\"../../../css/images/SABIC_LOGO.gif\">");
document.write("</A> ");
document.write("</TD></TR><tr style=height:10px><td colspan=3></td></tr></TBODY></TABLE>");

document.write("<TABLE id=fullwidth border=0 >");
document.write("<TBODY>");
document.write("<TR>");
document.write("<TD width=960px>");
document.write("</TD>");
document.write("<TD width=735px>");
document.write("<DIV>");
document.write("<FORM name=searchDatasheetsForm action=/gepapp/Plastics/global/jsp/IdesTools/quicksearch.jsp method=post>");
document.write(SearchResinsCompound);
document.write("<INPUT onblur=\"if (this.value=='') this.value='"+searchkeywords+"';\" style=\"WIDTH: 80px; HEIGHT: 16px\" onfocus=\"if (this.value=='"+searchkeywords+"') this.value='';\" size=15 value="+searchkeywords+" name=query> ");
document.write("&nbsp; ");
document.write("<INPUT class=dsimage type=image alt="+Conductsearch+" src=\"../../../css/images/button_search-arrow.gif\" name=SearchSubmit>");
document.write("</FORM>");
document.write("</DIV>");
document.write("</TD>");
document.write("</TR>");
document.write("</Table>");
document.write("<table id=fullwidth border=0 bordercolor=green style=height:10px>");
document.write("<tr>");
document.write("<TD width=264px>");
document.write("");
document.write("</TD>");


document.write("<TD width=100px>");


document.write("<TABLE id=menuCell border=0 bordercolor=blue >");
document.write("<TBODY>");
document.write("<TR>");

document.write("<TD class=utilitynav >");
document.write("<P id=stockTicker> ");
document.write("<A href=\"http://www.sabic.com\">"+Sabic+"</A>");
document.write(" | <A href=\"/gep/"+lang+"/NewsRoom/NewsRoom/news_room.html\">"+News+"</A>");
document.write(" | <A href=\"/gep/Plastics/"+lang+"/BuyPages/BuyLandingPage/buy_landing_page.html\">"+Buy+"</A>");
document.write(" | <A href=\"/gep/"+lang+"/UtilityAndLegal/SiteMap/site_map.html\">"+Sitemap+"</A>");
//document.write(" | <img class=liveHelp src=\"../../../css/images/LiveHelp.gif\">");
document.write(" | <A href=\"/gep/Plastics/"+lang+"/UtilityPages/LiveChat/livechat.html\"> "+Livehelp+" </A>");
document.write("</P></TD>");
            
document.write("<TD class=utilitynav >");
register();
document.write("</TD>");

document.write("<TD class=utilitynav id=search>");

document.write("<FORM name=searchResultsForm action=JavaScript:refinedSearch(); method=get>");
document.write("<INPUT onblur=\"if (this.value=='') this.value='"+searchkeywords+"';\" style=\"WIDTH: 80px; HEIGHT: 16px\" onfocus=\"if (this.value=='"+searchkeywords+"') this.value='';\" size=15 value="+searchkeywords+" name=withinQuery_2>");
document.write("<INPUT type=hidden value=wholeSite name=srhOpt>");
document.write("<INPUT type=hidden value=search name=search>");
document.write("<INPUT type=image alt="+Conductsearch+" src=\"../../../css/images/search_bg_btn.jpg\" name=SearchSubmit>");
document.write("</FORM>");
document.write("</TD>");

document.write("<TD id=language-nav class=utilitynav>");
document.write("<DIV>");
document.write("<FORM name=language  method=post>");
document.write("<select name=\"lanOpt\" onchange='JavaScript:my_selectLanguage();'>");
document.write("<option value="+SabicipHomeLink+" selected>"+English+"</option>");
document.write("<option value="+HomeZHLink+">"+Chinese+"</option>");
document.write("<option value="+HomeJPLink+">"+Japanese+"</option>");
document.write("<option value="+HomeKRLink+">"+Korean+"</option>");
document.write("<option value="+HomeBRLink+">"+PortugueseBrazil+"</option>");
document.write("<option value="+HomeESLink+">"+SpanishSpain+"</option>");
document.write("</select>");

document.write("</FORM>");
document.write("</DIV>");
document.write("</TD>");

document.write("</TR></TBODY></TABLE>");
document.write("</TD>");
document.write("</tr>");

document.write("</table>");

document.write("<table id=fullwidth border=0 bordercolor=yellow>");
document.write("<tr>");
document.write("<td>");
document.write("<table style='margin-left: 180px;' border=0 bordercolor=black>");
document.write("<TBODY>");
document.write("<tr>");
document.write("<td id=menu >");
document.write("<DIV onmouseover=iframehide()>");

myTest.writeMenuBar();

document.write("</div");
document.write("</td>");
document.write("</tr>");
document.write("</tbody>");
document.write("</table>");
document.write("</td>");
document.write("</tr>");
document.write("<tr style=height:10px>");
document.write("<td>");
document.write("</td>");
document.write("</tr>");



}
var patt3=new RegExp("\/gep\/");
var patt4=new RegExp("\/gepapp\/");
var myurl=location.href;
if (patt3.test(myurl)|patt4.test(myurl))
{
var store_title = document.title;
document.title=document.title+" - "+"PORTUGUESE";
}

//Start of Asynchronous tracking code
var _gaq = _gaq || []; 
_gaq.push(['_setAccount', 'UA-11846224-1']);  
_gaq.push(['_trackPageview']);
(function() {    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);  })();

//End of Asynchronous tracking code

