 


function app_Header(){
//	document.write("<h5> Application Highlights </h5><p/>");
}

//today's date will be used to compare the start and end dates of feateured products

var todaysDateApph=new Date();
  var sCont=0;
  var sCont1=0;
  	var ProdLine_available_appH=0;
  	var ProdFamily_available_appH=0;
  	var ProdGroup_available_appH=0;
  	var Application_available_appH=0;
  	var IndSubset_available_appH=0;
  	var Industry_available_appH=0;
    var Capability_available_appH=0;	
  	var Any_available_appH=0;
    var Home_available_appH=0;	
  	var counter_display_appH=0;
	
	var Found_appH=false;
	var Count_appH=0;
	var Current_appH = new Array(-1,-1,-1,-1,-1);
	var sTemp_appH= new Array();


	var appH_title;
	var appH_tag_prodline;
	var appH_tag_prodfamily;
  var appH_tag_prodgroup;
  var appH_tag_application;
  var appH_tag_indsubset;
	var appH_tag_industry;
	var appH_tag_capability;
	var appH_imgURL;
	var appH_text;
	var appH_linkURL;
	var appH_startDate;
	var appH_endDate;
	var appH_homePool;	
	
	var sTemp1_appH= new Array();
	var sTemp2_appH= new Array();

	appH_title =new Array();
  appH_tag_prodline =new Array();
	appH_tag_prodfamily =new Array();
	appH_tag_application = new Array();
	appH_tag_prodgroup = new Array();
	appH_tag_indsubset = new Array();
	appH_tag_industry =new Array();
	appH_tag_capability = new Array();
	appH_imgURL =new Array();
	appH_text =new Array();
	appH_linkURL =new Array();
	appH_startDate =new Array();
	appH_endDate =new Array();	
	appH_homePool=new Array();	

appH_linkURL[0] = "../../../en/Industry/AppHighlights/stormprotection.html";
appH_title[0] = "Storm Protection" ; 
appH_startDate[0] = "09-17-2008" ; 
appH_endDate[0] = "12-31-2009" ; 
appH_homePool[0] = 1; 
appH_tag_capability[0] = "##Fabrication##" ; 
appH_tag_prodgroup[0] = "##Storm Protection##" ; 
appH_tag_prodfamily[0] = "" ; 
appH_tag_prodline[0] = "" ; 
appH_tag_industry[0] = "" ; 
appH_tag_indsubset[0] = "" ; 
appH_tag_application[0] = "" ; 
appH_imgURL[0] = "http://imageserver.geampod.kcbam.net/KBAMImagingServer/Scripts/resize.kix?FileName=http://kbam.geampod.com/KBAM/reflection/Assets/15435.jpg&Width1=60&Height1=60&Unit1=Pixels" ; 
appH_text[0] = "SABIC Polymershapes storm protection products are made to endure the toughest storm-prone areas along the gulf, Florida and Atlantic..." ; 
  
 
//small piece of code to bubble sort the featured products according to their titles. this is necessary as the same
//arrays will be used for left hand nav

var tempExchange;
for (var sort_appH=0;sort_appH < appH_title.length;sort_appH++)
{
	for (var sortIn_appH =sort_appH+1;sortIn_appH< appH_title.length; sortIn_appH++)
	{
		if(appH_title[sort_appH] > appH_title[sortIn_appH])
		{
			tempExchange=appH_title[sort_appH];
			appH_title[sort_appH]= appH_title[sortIn_appH];
			appH_title[sortIn_appH]=tempExchange;


			tempExchange=appH_linkURL[sort_appH];
			appH_linkURL[sort_appH]= appH_linkURL[sortIn_appH];
			appH_linkURL[sortIn_appH]=tempExchange;

			tempExchange=appH_imgURL[sort_appH];
			appH_imgURL[sort_appH]= appH_imgURL[sortIn_appH];
			appH_imgURL[sortIn_appH]=tempExchange;

			tempExchange=appH_text[sort_appH];
			appH_text[sort_appH]= appH_text[sortIn_appH];
			appH_text[sortIn_appH]=tempExchange;
			
			
			tempExchange=appH_tag_prodgroup[sort_appH];
			appH_tag_prodgroup[sort_appH]= appH_tag_prodgroup[sortIn_appH];
			appH_tag_prodgroup[sortIn_appH]=tempExchange;


			tempExchange=appH_tag_prodfamily[sort_appH];
			appH_tag_prodfamily[sort_appH]= appH_tag_prodfamily[sortIn_appH];
			appH_tag_prodfamily[sortIn_appH]=tempExchange;

			tempExchange=appH_tag_prodline[sort_appH];
			appH_tag_prodline[sort_appH]= appH_tag_prodline[sortIn_appH];
			appH_tag_prodline[sortIn_appH]=tempExchange;


			tempExchange=appH_tag_industry[sort_appH];
			appH_tag_industry[sort_appH]= appH_tag_industry[sortIn_appH];
			appH_tag_industry[sortIn_appH]=tempExchange;

			tempExchange=appH_tag_indsubset[sort_appH];
			appH_tag_indsubset[sort_appH]= appH_tag_indsubset[sortIn_appH];
			appH_tag_indsubset[sortIn_appH]=tempExchange;

			tempExchange=appH_tag_application[sort_appH];
			appH_tag_application[sort_appH]= appH_tag_application[sortIn_appH];
			appH_tag_application[sortIn_appH]=tempExchange;
			
			tempExchange=appH_startDate[sort_appH];
			appH_startDate[sort_appH]= appH_startDate[sortIn_appH];
			appH_startDate[sortIn_appH]=tempExchange;

			tempExchange=appH_endDate[sort_appH];
			appH_endDate[sort_appH]= appH_endDate[sortIn_appH];
			appH_endDate[sortIn_appH]=tempExchange;

			tempExchange=appH_homePool[sort_appH];
			appH_homePool[sort_appH]= appH_homePool[sortIn_appH];
			appH_homePool[sortIn_appH]=tempExchange;

			tempExchange=appH_tag_capability[sort_appH];
			appH_tag_capability[sort_appH]= appH_tag_capability[sortIn_appH];
			appH_tag_capability[sortIn_appH]=tempExchange;		
		
		}

	}
//convert to dates

      dateArray=appH_startDate[sort_appH].split("-");
      appH_startDate[sort_appH]=new Date(dateArray[2],dateArray[0]-1,dateArray[1]);
      dateArray=appH_endDate[sort_appH].split("-");
      appH_endDate[sort_appH]=new Date(dateArray[2],dateArray[0]-1,dateArray[1]); 	
}



function appHighBody(indexToDisplay){
   	document.write("<div class=\"imageBlock\"><p class=\"image\">");
  	document.write("<img src=\"" + appH_imgURL[indexToDisplay] + "\"/></p><h5><a href=\""+appH_linkURL[indexToDisplay]+"\">" + appH_title[indexToDisplay] + "</a></h5><p>"+appH_text[indexToDisplay]+"</p></div><br/>");
}

function appAllLink(){
	document.writeln("<p align=\"right\">&gt;<a href=\"../../../en/Industry/AppHighlightsLanding/apphighlightslanding.html\">View All Highlights</a></p>");  
}



function displayAppHighlights_ProductLine(product){
	//alert("-"+product+"-");

	forProductLineAppH(product,2);
	//alert(ProdLine_available_appH);
  
	if (ProdLine_available_appH>0)
  {
  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (ProdLine_available_appH > 2 ? 2:ProdLine_available_appH);
		  app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }		 
		  appAllLink();
	}
	

}

function displayAppHighlights_ProductFamily(productFamily){
	forProductFamilyAppH(productFamily,2);
	if (ProdFamily_available_appH>0)
  {
  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (ProdFamily_available_appH > 2 ? 2:ProdFamily_available_appH);
		  app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }		 
		  appAllLink();
	}

}

function displayAppHighlights_ProductGroup(productGroup){
	forProductGroupAppH(productGroup,2);
	if (ProdGroup_available_appH>0)
  {
	  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (ProdGroup_available_appH > 2 ? 2:ProdGroup_available_appH);
  	  app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }		 
		  appAllLink();
	}

}

function displayAppHighlights_IndustryDetail(industry){
    forIndustryAppH(industry,2);
		if (Industry_available_appH>0)
    {
	  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (Industry_available_appH > 2 ? 2:Industry_available_appH);
		  app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }		 
		  appAllLink();
			}
	
}

function displayAppHighlights_IndustrySubset(industrySubset){
    forIndustrySubsetAppH(industrySubset,2);
		if (IndSubset_available_appH>0)
    {
	  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (IndSubset_available_appH > 2 ? 2:IndSubset_available_appH);
      app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }		 
		  appAllLink();
			}
	
}

function displayAppHighlights_Application(app){
	forApplicationAppH(app,2);
	
	if(Application_available_appH>0)
	{
	  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (Application_available_appH > 2 ? 2:Application_available_appH);
	    app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }
     	appAllLink();
  }
}

function displayAppHighlights_Capability(cap){
	forCapabilityAppH(cap,2);
	
	if(Capability_available_appH>0)
	{
	  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (Capability_available_appH > 2 ? 2:Capability_available_appH);
	    app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }
     	appAllLink();
  }
}

function displayAppHighlights_HomePage(){
	forHomePageAppH(2);
	
	if(Home_available_appH>0)
	{
	  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (Home_available_appH > 2 ? 2:Home_available_appH);
	    app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }
     	appAllLink();
  }
}

function displayAppHighlights_Generic(){
  Any_available_appH=0;
  forAllAppH(2);
	
	if(Any_available_appH>0)
	{
	  //since we have to display only two max, if available to display is greater than 2, then set counter to 2
      counterDisplay = (Any_available_appH > 2 ? 2:Any_available_appH);
	    app_Header();
    	for (var countFeat=0;countFeat<counterDisplay;countFeat++)
    	{
    	   appHighBody(sTemp_appH[Current_appH[countFeat]]);
      }
     	appAllLink();
  }
}


//modified sammy
 //added sammy

 function forProductLineAppH(sProdL,howMany){
 	sProdL="#"+sProdL+"#";
		for (i=0;i < appH_title.length;i++){
		//alert(tag_prodline[i]+"--"+sProdL);
		//The sProdL product line has to match the tag_prodLine arrays for that paritular featured product and that
		//new product must have valid start and end date i.e, today's date must be b/w start date and end date
			if ((appH_tag_prodline[i].indexOf(sProdL)!=-1)&&(appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))
      {		
				sTemp_appH[sCont]=i;
				sTemp1_appH[sCont]=i;
				sCont++;
				ProdLine_available_appH++;
			}
		}
		if (sCont!=0){
		GetUniqueAppH(sCont-1,howMany);
		}
 }
 
 function forProductFamilyAppH(sProdF,howMany){
 	sProdF="#"+sProdF+"#";
					for (i=0;i < appH_title.length;i++){
		//The sProdF product family has to match the tag_prodFam array for that paritular featured product and that
		//new product must have valid start and end date i.e, today's date must be b/w start date and end date
						if ((appH_tag_prodfamily[i].indexOf(sProdF)!=-1)&&(appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))
            {
							sTemp_appH[sCont]=i;
							sTemp1_appH[sCont]=i;
							sCont++;
							ProdFamily_available_appH++;
						}
					}
					if (sCont!=0){
					GetUniqueAppH(sCont-1,howMany);
			}
 }
 
 function forProductGroupAppH(sProdG,howMany){
 	sProdG="#"+sProdG+"#";
		for (i=0;i < appH_title.length;i++){
		//The sProdG product group has to match the tag_prodgroup arrays for that paritular featured product and that
		//new product must have valid start and end date i.e, today's date must be b/w start date and end date
			if ((appH_tag_prodgroup[i].indexOf(sProdG)!= -1)&&(appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))
      {
			//	alert("found a match");
				sTemp_appH[sCont]=i;
				sTemp1_appH[sCont]=i;
				sCont++;
				ProdGroup_available_appH++;
			}
		}
		if (sCont!=0){
		GetUniqueAppH(sCont-1,howMany);
		}
 } 
 
 
 function forIndustryAppH(sIndus,howMany){
 	sIndus="#"+sIndus+"#";
				for (i=0;i < appH_title.length;i++){
			//The sIndus industry has to match the tag_idnustry  array for that paritular featured product and that
		//new product must have valid start and end date i.e, today's date must be b/w start date and end date
  				if ((appH_tag_industry[i].indexOf(sIndus)!=-1)&&(appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))
  				{
						sTemp_appH[sCont]=i;
						sTemp1_appH[sCont]=i;
						sCont++;
						Industry_available_appH++;
					}
				}
				if (sCont!=0){
				GetUniqueAppH(sCont-1,howMany);
		}
 }
 
 function forIndustrySubsetAppH(sIndusSubset,howMany){
 	sIndusSubset="#"+sIndusSubset+"#";
				for (i=0;i < appH_title.length;i++){
		//The sIndussubset industry subset has to match the tag_indussubset array for that paritular featured product and that
		//new product must have valid start and end date i.e, today's date must be b/w start date and end date
					if ((appH_tag_indsubset[i].indexOf(sIndusSubset)!=-1)&&(appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))				
				  {	
						sTemp_appH[sCont]=i;
						sTemp1_appH[sCont]=i;
						sCont++;
						IndSubset_available_appH++;
					}
				}
				if (sCont!=0){
				GetUniqueAppH(sCont-1,howMany);
		}
 } 
 
 function forApplicationAppH(sApp,howMany){
 	sApp="#"+sApp+"#";
				for (i=0;i < appH_title.length;i++){
					//The sApp application has to match the tag_application array for that paritular featured product and that
		//new product must have valid start and end date i.e, today's date must be b/w start date and end date
					if ((appH_tag_application[i].indexOf(sApp)!=-1)&&(appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))
          {	
						sTemp_appH[sCont]=i;
						sTemp1_appH[sCont]=i;
						sCont++;
						Application_available_appH++;
					}
				}
				if (sCont!=0){
				GetUniqueAppH(sCont-1,howMany);
		}
 }
 

function forCapabilityAppH(sCap,howMany){
 	sCap="#"+sCap+"#";
				for (i=0;i < appH_title.length;i++){
		//The sCap capability has to match the tag_capabilty array for that paritular featured product and that
		//new product must have valid start and end date i.e, today's date must be b/w start date and end date
					if ((appH_tag_capability[i].indexOf(sCap)!=-1)&&(appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))
          {
						sTemp_appH[sCont]=i;
						sTemp_appH[sCont]=i;
						sCont++;
						Capability_available_appH++;
					}
				}
				if (sCont!=0){
				GetUniqueAppH(sCont-1,howMany);
		}
 } 

function forHomePageAppH(howMany){
 	
				for (i=0;i < appH_title.length;i++){
	     // the flag for having the product on the home page must be equal to 1 and the
		//new product must have valid start and end date i.e, today's date must be b/w start date and end date
					if ((appH_homePool[i]==1)&&(appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))
          {
						sTemp_appH[sCont]=i;
						sTemp1_appH[sCont]=i;
						sCont++;
						Home_available_appH++;
					}
				}
				if (sCont!=0){
				GetUniqueAppH(sCont-1,howMany);
		}
 }
 function forAllAppH(howMany){
 		for (i=0;i < appH_title.length;i++){
 	    if((appH_startDate[i]<todaysDateApph)&& (appH_endDate[i] > todaysDateApph))
        {	
					sTemp_appH[sCont]=i;
					sTemp1_appH[sCont]=i;
					sCont++;
					Any_available_appH++;
				}
		}
		if (sCont!=0){	
  	GetUniqueAppH(sCont-1,howMany);
  	}
 }

 function GetUniqueAppH(MaxValue,howMany)
   {
   	if (howMany>MaxValue){
   		howMany=MaxValue;
   	}
     for (i=0;Count_appH<=howMany;Count_appH++)
     {
       Found_appH=false;
       var rndValue = get_randomAppH(MaxValue);
       var j=0;
       for (j=0;j<Current_appH.length;j++)
       {
         if (Current_appH[j] == rndValue)
         {
           Found_appH=true;
           break;
         }
       }
       if (Found_appH)
       {
         Count_appH--;
       } else {
         Current_appH[Count_appH]=rndValue;
       }
     }
   }
   
   function get_randomAppH(MaxValue)
   {
     var ranNum= Math.round(Math.random()*(MaxValue));
     return ranNum;
   }
 //added sammy

