//jQuery homepage script for the show-hide framework- START  -written by Kenneth Sipe (07/2011)  //



function portalSearch(){

 $(".pS").bind("click",function(){

				if($(".pSearch").is(":visible")){

					$(this).removeClass("portal-select-click");

					setTimeout(function(){
						$(".pSearch").fadeOut(1000,function(){

							$(".pS").removeClass("portal-select-click");

							});
				
						},200);


					}


				if($(".pSearch").is(":hidden")){
					
					$(".pSearch").fadeIn(500,function(){

					$(".pS").addClass("portal-select-click");

						});

					}
				

				});
		
	$(".pSearch").hover(
	
				function(){
		
					$(this).fadeIn();
		
					},
	
				function(){
		
					setTimeout(function(){
						$(".pSearch").fadeOut(1000,function(){


							$(".pS").removeClass("portal-select-click");

							});
				
						},1000);
		
			});	
	

	}

//

function homequickSearch(){

    $(".qS").click(
	
	function(){
				
		$(".qSearch").toggle( 1000,function(){
			
					$(".qS").toggleClass("qS-click", "qS-return")
					
					});
		
		
	});
	
	
	$(".qSearch").hover(function(){
		
						$(this).fadeIn();
		
			},
	
				function(){
		
					setTimeout(function(){
							$(".qSearch").fadeOut(1000)
							$(".qS").toggleClass("qS-click", "qS-return");
				
						},6000);
		
				});	
	
}
	
	
//	
	
		
function twitterLoad() {
				$("#twitter").getTwitter({
					userName: "rohmsemi",
					numTweets: 20,
					loaderText: "Loading tweets...",
					slideIn: true,
					slideDuration: 750,
					showHeading: true,
					headingText: "Latest Tweets",
					showProfileLink: true,
					showTimestamp: true
				});
				
}




//jQuery script for the banner scroll framework- START  -written by Kenneth Sipe (07/2011)  //




	
	function imgScroll(){
	 
	  var arrS = new Object;
        arrS[0] = "iScroll-1";
        arrS[1] = "iScroll-2";
        arrS[2] = "iScroll-3";
        arrS[3] = "iScroll-4";
		
		
		
		
		$.each(arrS, function(i){
			
			$(this).hover(function(){
				
			 $(this).stop();
			 
			},
			
			function(){
				
				imgScroll();
				
			});
			
			
		});

   
        $("#" + arrS[0]).css("z-index","0");

        $("#" + arrS[1]).css("z-index","100");

        $("#" + arrS[2]).css("z-index","200");

        $("#" + arrS[3]).css("z-index","300");

  
           $("#" + arrS[3]).fadeOut(3000);
           $("#" + arrS[2]).hide();
           $("#" + arrS[1]).hide();
           $("#" + arrS[0]).fadeIn(10000 , function(){
           $("#" + arrS[1]).delay(5000).fadeIn(3000,function(){
           $("#" + arrS[2]).delay(5000).fadeIn(3000, function(){
           $("#" + arrS[3]).delay(6000).fadeIn(2000,  function(){

                setTimeout(imgScroll, 5000);
          
                              });
            
                         });
            
                    });
            
              });
         

        };

        


/* Start jquery toggle option 1    */

function toggleOption1(){


$(".toggle-content").hide();
	
	$(".toggle-button").click(
	
		function(){
			
			$(this).parent().parent().find(".toggle-content").toggle(1000);
			
			$(this).find(".showStatus").toggle();
			
			
			});
			
};



/* Start jquery toggle option 2    */


function toggleOption2(){


$(".toggle-content-home").hide();
	
	$(".toggle-button-home").click(
	
		function(){
			
			$(this).parent().parent().find(".toggle-content-home").toggle(1000);
			
			$(this).find(".showStatus").toggle();
			
			
			});
			
};


/* Start jquery toggle option 3    */


function toggleOption3(){//button


$(".toggle-content-expand").hide();
	
	$(".toggle-button-expand").click(
	
		function(){
			
			$(this).parent().parent().find(".toggle-content-expand").toggle(1000);
			
			$(this).find(".showStatus").toggle();
			
			
			});
			
};


/* Start jquery toggle option 4    */


function toggleOption4(){//link


$(".toggle-content-expand").hide();
	
	$(".toggle-button-expand-URL").click(
	
		function(){
			
			$(this).parent().find(".toggle-content-expand").toggle(1000);
			
			$(this).parent().find(".showStatus").toggle();
			
			
			});
			
};





/* remote file jQuery injection script */


function currentNews(){
	
	$(".current-story").load("html/news/current/news-low-power-micro.html #news-summary", function(){/*the #news-summary block and only this block*/

			/*with in the #news-summary block hide the following elements*/
		
			$(this).contents().find("img").hide();/*hide inset(s)*/
			
			$(this).contents().find("h2").css("margin-top","0");/*move heading to top*/
			
			$(this).contents().find("h3").hide();/*hide any other headings*/
						  
			$(this).contents().find("span").hide();/*hide the rest of the paragragh*/
		
			/*add a read more link*/
									
			$(this).contents().find("p:eq(2)").after("<a href='html/news/current/news-low-power-micro.html' tilte='Read more'><span style='color:#2E00FF; font-weight:bold; display:block;'> Read more >></span></a>");


								});
	
	
	};
	
	
	
/*  jQuery IC Cross Reference script */	

function icRef(){

$("#icTool").hide();

$("#home-news").ready(function(){
	$("#icTool").fadeTo(500, 0.3, function(){
		
					$(this).fadeTo(500, 1.0, function(){
			
							$("#cR span").css("color","#03F");
			
							$(this).fadeTo(500, 0.3, function(){
				
									$(this).fadeTo(500, 1.0)
				
									$("#cR span").css("color","#d8203c");

				
														});
						
										});
		
						});
	
  			 });
   
};


/* PR more info button animation  */

function buttonAniOption1(){
	
	$(".more-info-top").hide();
	
	$(".more-info-top").css("top","-60px").fadeIn(1000,  function(){
		
													$(this).slideDown(2000, function(){
			
																	$(this).animate({top:0}, 1000)
			
		    													  });
		
							  });

};

/* toggle container/ fadeIn links see PicoLed IMC  */

function toggleContainerOption1(){
	
	var $subH =   $("#toggleContainer").find("div h3");
	 
	 var $fadeInLink = $("#toggleContainer").find("div dl dd a");
	 
	 $subH.hide();
	 
	 $fadeInLink.hide();
	 
	$subH.toggle(2000, function(){
		 
		 						$fadeInLink.fadeIn(3000);
		 
					 });
	
};




//Quick search page injection
$.fn.frameStretch = function() {

var theFrame = $("iframe", parent.document.body);
theFrame.height($(document.body).height() + 30);

}

	
		
	$.fn.hideStuff = function() {
									 $(this).contents().find("#selectsite").hide();
									 $(this).contents().find("#selectsiteTitle").hide();
									 $(this).contents().find("#topic-path").hide();
									 $(this).contents().find("#sw_fontsize").hide();
								     $(this).contents().find("#search").hide();
								     $(this).contents().find("#myRohmLogin").hide();
								     $(this).contents().find("#header-logo").hide();
									 $(this).contents().find("#menu").hide();
									 $(this).contents().find("#sitemap").hide();
                                     $(this).contents().find("#left-cell").hide();
                                     $(this).contents().find("#right-cell").hide();
									 $(this).contents().find(".r-col-h").css("display","none");
									 $(this).contents().find("#r-col-h-link").css("display","none");
									 $(this).contents().find(".topic-col-end").css("display","none");
									 $(this).contents().find(".topic-col").css("display","none");
									 $(this).contents().find("#center-cell").width(665); //change the #center-cell to this (initial state: width:100%)
									 $(this).contents().find("#main-table").width(790); //change #main-table in center to this (initial state: width:100%)
									
									
									 //$(this).contents().find("table.products-table td").css("padding","2px");//shrink product table
									 $(this).width(900); 
									 $(this).contents().find("#product-title-h2").css("border", "none");
									 $(this).contents().find(".product-d-h4").css("display", "none");
									 $(this).contents().find(".product-d-h4:contains('Features')").css("display", "block");
									 $(this).contents().find(".product-d-h4:contains('Features')").css("background", "url('none') no-repeat scroll 0 0 ");
									 $(this).contents().find(".product-d-h4 strong").css("background", "url('none') no-repeat scroll 0 0 ");
									 $(this).contents().find(".product-d-h4:contains('Status Product')").css("display", "block");
									 $(this).contents().find(".product-d-h4:contains('Status Product')").css("background", "url('none') no-repeat scroll 0 0 ");
									// $(this).contents().find(".product-d-h4:contains('Status Product')").text("Product Status");//Change text of 'Status Product' link to 'Product Status'									
									 $(this).contents().find(".product-d-h4:contains('Others')").css("display", "block");
									 $(this).contents().find(".product-d-h4:contains('Others')").css("background", "url('none') no-repeat scroll 0 0 ");
									 $(this).contents().find("#topic-path").css("color", "#fff");
									 $(this).contents().find(".barrow:contains('Package')").css("display", "none");
									 $(this).contents().find(".barrow:contains('RoHS')").css("display", "none");
									 $(this).contents().find(".barrow:contains('Quality and reliability information')").css("display", "none");
									 $(this).contents().find(".barrow:contains('*Put the mouse on the icon to see further details')").css("display", "none");
									 $(this).contents().find(".barrow:contains('Application notes')").css("display", "none");
									 $(this).contents().find(".barrow:contains('Design Model')").css("display", "none");
									 $(this).contents().find(".barrow:contains('Please check the details on')").css("display", "none");
									 $(this).contents().find("#footer").hide();
									 $(this).contents().find("body").css("background-image", "none");
									 $(this).contents().find(".cnt2-h2").css("background-image","none");
									 $(this).contents().find(".cnt2-h2").css("color","#fff");
									 $(this).contents().find("#product-title").css("background-image", "none");
									 $(this).contents().find("#product-title").css("border", "none");
									 $(this).contents().find("#product-title-h2").css("border-top", "none");
									 $(this).contents().find("#p-inquiry-button").css("display", "none");
									 $(this).contents().find("#product-header-list").css("border", "none");
									 $(this).contents().find("#product-header-list").css("background", "url('none') no-repeat scroll 0 0 ");
									 $(this).contents().find("#product-header-list td").css("border", "none");
									 $(this).contents().find(".cnt3-h2").css("display", "none");
									 $(this).contents().find(".cnt3-h2-sub").css("display", "none");
									 $(this).contents().find(".tab_line").css("display", "none");
									 $(this).contents().find("p span:contains('*')").css("display", "none");
									 $(this).contents().find("img[src*='_off']").css("display", "none");
									 $(this).contents().find("img[src*='_on']").css("display", "none");
									 $(this).contents().find("p span a:contains('Registration is required to access the design models and application notes')").css("display", "none");
									// $(this).contents().find("#rcm td:contains('Costomers who viewed this product also viewed')").replaceWith("<td class='title' valign='middle' colspan='4' >Customers who viewed this product also viewed</td>");			                                      //correct spelling
									 $(this).contents().find("#rcm").hide();//Costomers who viewed this product also viewed table- Not accurate for western market
									 $(this).contents().find(".products-info-photo-set").css("display", "none");
									 $(this).contents().find("td  p[class='itemPhoto'] a img").css("display", "block");
									//!important- opens link in same window
									 $(this).contents().find("td a").attr("target", "_self");
									 $(this).contents().find("td span a:contains('Package')").attr("target", "_self");
									 $(this).contents().find("td span a:contains('RoHS')").attr("target", "_self");
									 $(this).contents().find("td a:contains('Inquiry')").attr("href","http://www.rohm.com/us/contact_us/contact_us.html").attr("target", "_parent");//Change path of 'Inquiry' link to ROHM USA Web form
									 $(this).contents().find("td a:contains('Inquiry')").text("contact us");//Change text of 'Inquiry' link to 'contact us'
									 //$(this).contents().find("td a:contains('Product Inquiries')").attr("href","http://www.rohm.com/us/contact_us/contact_us.html").attr("target", "_parent");//Change path of 'Inquiry' link to ROHM USA Web form
									// $(this).contents().find("td a:contains('Product Inquiries')").text("contact us");//Change text of 'Inquiry' link to 'contact us'	
									
									$(this).contents().find("td a:contains('Product Inquiries')").text("contact us");//Change text of 'Inquiry' link to 'contact us'
 
									$(this).contents().find("td a:contains('contact us')").attr("href","http://www.rohm.com/us/contact_us/contact_us.html").attr("target", "_blank");//Change path of 'Inquiry' link to ROHM USA Web form
								
									 //!important- opens link in _new window
									 $(this).contents().find("td span a:contains('Data Sheet')").attr("target", "_blank");
						  			 $(this).contents().find("a[href*='.pdf']").attr("target", "_blank");//.pdfs opened _blank
									 $(this).contents().find(".products-table td  a[href*='databook']").attr("target", "_blank");//a[href*='databook'] href contains 'databook'
									 $(this).contents().find(" td  a[href*='rohs']").attr("href", "");//a[href*='rohs'] href contains 'rohs'
									 $(this).contents().find(".products-table td a:contains('Yes')").replaceWith("Yes");//replace RoHS link with text 'YES'
									
}


function loadSearch(){ 

		var wait = "Loading" + "...";
	
		$("#lMessage").html("<p><img src='http://www.rohm.com/us/images/common/70.gif' width='38' height='44' alt='Loading' style='float:left; margin-top:-20px; margin-right:20px;' /><span style='color:#999; float:left;'>"+wait+"<span></p>");

		$("iframe").load(function (){
			
			
			$("body").contents().find("iframe").hideStuff();
			

			$("#lMessage").css("display","block");
								    
			$("#load-overlay").show();
					
			$("#iF-Wrapper").animate({opacity:1}, 1000);
			
			$("iframe").animate({opacity:1}, 1000,function(){
							
                 //hide loading message
			$("#lMessage").hide(4000, function(){
					
			//show iframe
			setTimeout(function(){
				
			

				
						$("iframe").css("display","block");

										},1000);

				  			 });
								   
				
				
					
			    });

				
	            
				
		//Event handlers
		 //initiate reload
	
			  
		 
	$("iframe").contents().find("a[href*='.pdf']").click(function(){
		
			 $("iframe").show();
			 
		 });
				
				
	$("iframe").contents().find("a:not([href*='.pdf'])").click(function(){
			
			 $("iframe").hide();
						
			loadSearch();
							
			$("#lMessage").show();
						
									
		
				});
				
				
				
	$("iframe").contents().find("#select").click(function(){
			 
			$("iframe").hide();
						
			loadSearch();
						
			$("#lMessage").show();
									
		
				});
				
	$("iframe").contents().find("a:contains('contact us')").click(function(){
  
    $("iframe").show();
	
	$("#lMessage").hide();
    
  			    });


	
	
		});
							
									
							
} loadSearch();



//Data Sheets page injection
	
function loadDatasheets(){
	var wait = "Loading" + "...";
	
	$("#lMessage").html("<p><img src='http://www.rohm.com/us/images/common/70.gif' width='38' height='44' alt='Loading' style='float:left; margin-top:-20px; margin-right:20px;' /><span style='color:#999; float:left;'>"+wait+"<span></p>");
	$("#datasheet-search").load(function (){
		                 //hide external page elements
						 $(this).contents().find(".r-col-h").css("display","none");
						 $(this).contents().find("#r-col-h-link").css("display","none");
						 $(this).contents().find(".topic-col-end").css("display","none");
						 $(this).contents().find(".topic-col").css("display","none");
						  $(this).contents().find("#footer").hide();
						  $(this).contents().find(".product-d-h3").css("display","none");
						  $(this).contents().find(".product-d-h3").css("color","#000");	  
						  $(this).contents().find(".cnt2-h2").css("background-image","none");
						  $(this).contents().find(".product-d-h3").css("background-image","none");
						  $(this).contents().find(".cnt2-h2").css("position","relative");
						  $(this).contents().find(".product-d-h3").delay(3000).fadeIn(3000);
						  $(this).contents().find(".product-d-h3").css("border","none");
						  $(this).contents().find("#main-table tbody tr td table['width','550'] tbody tr td  ul li a[href*='.pdf']").attr("target", "_blank");//.pdfs opened _blank
							//open links in new window
						  $(this).contents().find(".table_data tbody tr td a").attr("target","_blank");
						//fade in external page	
						  $("#iF-Wrapper").animate({"height": 2800}, 1000);  
						  $("#datasheet-search").animate({"height": 2800}, 1000);  
						  $(this).fadeIn(2000);
						//hide loading message
						  $("#lMessage").fadeOut();
			
			 });
	
	
	} 

//calls

//$(document).ready(function(){  // HTML (head tag)

//		imgScroll();  
//			
//		toggleOption2(); 
//		
//		homequickSearch();	
//		
//		icRef();
//		
//		twitterLoad();
//		
//		currentNews();


//});


//START embedded scripts   -------------------------------------------------------------------------------------------------------------------------------//

//change relative URL to absolute


//$(document).ready(function(){
//	
//$("#loadW").load("http://www.rohm.com/products/lsi/sensor/ #center-cell", function(){
//
//var $links = $("#center-cell div ul li a");
//
//var partialUrl = "http://www.rohm.com/products/lsi/sensor/"
//
//$links.each(function(i){
//	
//$(this).attr("href",partialUrl+$(this).attr('href'));
//		
//	});
//	
//});
//
//});

//inject see more products

//$(document).ready(function(){
//		
//		
//	toggleOption2(); 
//	
//	$("#loadW").load("http://www.rohm.com/products/lsi/eeprom/ #center-cell/ ", function(){
//	
//	//$("#center-cell h2").addClass("injectedJq");//h2.injectedJq
//			
//	$("#loadW").contents().find(".products-info-photo-set").hide();
//			
//	$("#loadW").contents().find("img").hide();
//		
//	$("#loadW").contents().find("p:contains('ROHM's serial EEPROMs are top shelf products featuring high reliability.')").hide();
//		
//			$("#loadW").contents().find(".eepromSearch-text").hide();
//
//			var $links = $("#center-cell div ul li a");
//			
//			var partialUrl = "http://www.rohm.com/products/lsi/eeprom/";
//
//				$links.each(function(i){
//					
//							$(this).attr("href",partialUrl+$(this).attr('href'));
//		
//									});
//	
//					});
//	
//	
//	loadSearch();
//	 
//	
//		 
//});
                 
//END embedded scripts   -------------------------------------------------------------------------------------------------------------------------------//
