﻿$(document).ready(function(e)
{
	$(function(){
	    $("div#menu > a:first-child").css("display", "none");
	    $("div#menu > table.GlobalNav > tbody > tr > td:last-child").addClass("last-child");

	    $("div.RelatedModuleWrap > div.Content > div > div.HeaderStyle:first-child").css("border-top","none");
	    $("div.RelatedModuleWrap > div.Content > ul > li:last-child").css("border","none");

	    $("div#CurrentNavWrap > a:first-child").css("display", "none");
	    $("div#CurrentNavWrap > a:last-child").addClass("NavLast");
	});
	
	$(function(){
		$("table.homeEventCal table.TitleStyle > tbody > tr > td:first-child").each(function()
	    {
	        $(this).addClass("first");	        
			$(this).children("a").text("");
	    });
	
	    $("table.homeEventCal table.TitleStyle > tbody > tr > td:last-child").each(function()
	    {
	        $(this).addClass("last");
			$(this).children("a").text("");
	    });

		$("table.homeEventCal th:last-child").css("border-right","none");
		$("table.homeEventCal td:last-child").css("border-right","none");
		$("table.homeEventCal tr:last-child td").css("border-bottom","none");
		$("table.EventsListCal th:last-child").css("border-right","none");
		$("table.EventsListCal td:last-child").css("border-right","none");
		$("table.EventsListCal tr:last-child td").css("border-bottom","none");
		$("table.EventsListCal table.TitleStyle > tbody > tr > td:first-child").each(function()
	    {
	        $(this).addClass("first");	        
			$(this).children("a").text("");
	    });
	
	    $("table.EventsListCal table.TitleStyle > tbody > tr > td:last-child").each(function()
	    {
	        $(this).addClass("last");
			$(this).children("a").text("");
	    });
	});
	if($(".VideoListDropDown").length <1)
		$(".VideoListLabel").addClass("clearbg");
	/**/
	var VariationClass = $("div.VariationWrap").find("span.VariationLabel").attr("class").replace("VariationLabel ","");
	$("a."+VariationClass).css("background-color","#F4F4F4");

	/*
	//Releated Menu First Item Background Changer
	var relatedFirstItems = $("div.RelatedModuleWrap table.fileListTable").find("tr");
	$(relatedFirstItems[0]).css("background-color","#FFFFFF");
	$(relatedFirstItems[1]).css("background-color","#FFFFFF");
	*/	
	//Ten Reasons Click Effect Script
	var detailItem = $("div.Ten_ReasonDetail");
		
	$("td.ReasonsItemBottom").toggle(
		function()
		{
			var ItemIndex = $("td.ReasonsItemBottom").index(this);
			$(detailItem).hide();
			
			$(detailItem[ItemIndex]).slideDown("slow");
		},
		function()
		{
			var ItemIndex = $("td.ReasonsItemBottom").index(this);
			$(detailItem[ItemIndex]).slideUp("slow");
		}
	);
	
	$("div.Clickforall").toggle(
		function()
		{
			$(detailItem).slideDown();
		},
		function()
		{
			$(detailItem).slideUp();
		}
	);	
	// Ten Reasons End Script
   	$(function(){
	    $('.LiteButton').each(function()
	    {
	        var _tempB = document.createElement('b');
	        var _tempSPAN = document.createElement('SPAN');
			$(_tempSPAN).append($(this).text());
			$(_tempB).append(_tempSPAN);
			
			$(this).html(_tempB);
	    });
	    
		$("a.ClickAllButton}").each(function(){
	        var _domElem = $.create("span",{},[$(this).text()]);
	        $(this).html(_domElem);
		});

   	});
   	
 	//Search Box Clear Script
	$(function(){
		var searchText = $(".SearchBox input:text");
		var searchValue = $(searchText).val();
		
		$(searchText).focus(function(){
			if($(searchText).val() == searchValue)
				$(this).val("");
		});
		
		$(searchText).blur(function(){
			if($(searchText).val() == "")	
				$(this).val(searchValue);
		});
	});

   	/*
   	$(".ms-dtinput").find("input").keydown(function(){
   		return false;
   	});
   	*/
   	//Top Menu Current Select
   	$(function(){
   		var globalNav = $("table.GlobalNav");
		var pageURI = $.url();
		var path = pageURI.attr("path").split("/");
		var searchSiteText = path[2].toLowerCase();
		$(globalNav).find("a").each(function(){
			if($(this).attr("href").toLowerCase().indexOf(searchSiteText)>0&&searchSiteText.indexOf("pages")<0)
			{
				$(this).addClass("StaticSelectedStyle");
				$(this).parents("table.StaticMenuItemStyle").addClass("StaticSelectedStyle");
			}
		});
   	});
	//pageFontChange: Selector page font changer
	$(function(){
		//var fontIndex = parseInt($(".GeneralPageContent > div").css("font-size"));
		var fontIndex = parseInt(12);
		$("#fontBig").click(function(){
			if(fontIndex < 18)
				fontIndex++;
				$("#pageFontChange *").css("font-size", fontIndex + "px");
		});
		$("#fontSmall").click(function(){
			if(fontIndex > 10)
				fontIndex--;
				$("#pageFontChange *").css("font-size", fontIndex + "px");
		});
		$("#fontNormal").click(function(){
			$("#pageFontChange *").css("font-size","");
			fontIndex = parseInt(12);
		});
	});
	
	//Contact Us Add & Position Pins
	$(function(){
		$("div.ContactMap").find("a").each(function(){
			var pos = $(this).attr("rel").split("|");
			var toolTipWrap = $.create("div",{"class":"toolTip"},[]);
			
			var titleText = " " + $(this).attr("title");
			var title = $.create("span",{"class":"title"},[titleText]);
			$(toolTipWrap).append(title);
			var CountryName = $.create("span",{},[$(this).attr("name")]);
			$(toolTipWrap).append(CountryName);
			$(this).append(toolTipWrap);
			$(toolTipWrap).hide();
			
			$(this).css({
				"top": pos[0] + "px",
				"left": pos[1] + "px"
			});
			$(this).qtip({
				content: $(this).find("div").html(),
				position: {
			      corner: {
			         target: 'topMiddle',
			         tooltip: 'bottomMiddle'
			      }
			   },
			   style: { 
			      width: 200,
			      padding: 5,
			      background: '#f8f8f8',
			      border: {
			         width: 0,
			         radius: 5,
			         color: '#eeeeee'
			      }
			   }
			});
		});
	});

    //Publishing Editor Toggle Select Style Script
    $(function(){
		var pageURI = document.location.href;
		var pageStatus = true;

		if(pageURI.toLowerCase().indexOf("editform.aspx")>0)
			pageStatus = false;
				
        if($("#MSOLayout_InDesignMode").val() == "" && pageStatus)
        {
	    	$("span.ms-rteCustom-ToggleContent").hide();
	    	
	    	$(".ms-rteCustom-ToggleTitle").click(function(){
	    		var titleIndex = $(".GeneralPageContent .ms-rteCustom-ToggleTitle").index(this);
	    		var contentItems = $(".ms-rteCustom-ToggleContent");
	    		if(titleIndex <= contentItems.length)
	    		{
		    		var toggleItem = $(contentItems[titleIndex]);
			    	$(this).toggleClass("msrteCustomToggleTitleHide")
		    		$(toggleItem).toggle("fast");
		    	}
	    	});
        }
    });

    $(function(){
		var pageURI = document.location.href;
		var pageStatus = true;

		if(pageURI.toLowerCase().indexOf("editform.aspx")>0)
			pageStatus = false;
				
        if($("#MSOLayout_InDesignMode").val() == "" && pageStatus)
        {
	    	$("table.ms-rteTable-7").each(function(){
		    	$(this).hide();
		    	var parent = $(this).parent("td");
	    		$(parent).css("padding","0")
	    	});
	    	$(".ms-rteCustom-ToggleTableTitle").each(function(){
	    		var _tempText = $(this).text().trim();
	    		if(_tempText.indexOf("+") == -1)
	    		{
	    			$(this).text("+ " + _tempText);
	    		}
	    	});
	    	
	    	$(".ms-rteCustom-ToggleTableTitle").click(function(){
	    		var titleIndex = $(".ms-rteCustom-ToggleTableTitle").index(this);
	    		var contentItems = $(".ms-rteTable-7");
	    		if(titleIndex <= contentItems.length)
	    		{
		    		var toggleItem = $(contentItems[titleIndex]);
		    		$(toggleItem).toggle();
		    	}
	    		var _tempThisText = $(this).text().trim();
		    	if(_tempThisText.substring(0,1) != "+")
	    		{
	    			var _t = "+";
	    		}
	    		else
	    		{
	    			var _t = "-";
	    		}
	    		$(this).text(_t + _tempThisText.substring(1,_tempThisText.length));	    		
	    	});
        }
    });
    //Publishing Image find control Script
    $(function(){
    	if($("div.PublishingImageWrap").find("img").is(":first-child")){
    		$("div.PublishingImageWrap").show();
    	}
    });
    
    //Page Print Button
    $(function(){
    	$("span.PrintPage").click(function(){    		
			$("div.PrintPreview").show();
    		$(".noPrint").hide();
    		$("body").css("background","transparent");
			var header = $("#inv-logo").outerHTML();
    		$("#contentLayout").prepend(header);
    		$("#contentLayout").find("#inv-logo").css("position","static");
    	});
	 	$(".GoBackPrint" ).click(function(){
			$(".noPrint").show();
			$("div.PrintPreview").hide();
			$("body").attr("style","");

    		$("#contentLayout").find("#inv-logo").remove();

		});
	 	$(".PrintPreviewButton" ).click(function(){
			window.print();
		});
    });
	//Page Top Link
	$(function(){
		var contentLayout = $("div#contentLayout").height();
		var GeneralContent = $("div.GeneralPageContent").height();
		if(contentLayout<750 || GeneralContent<750)
			$("div.PageTop").hide();
		
		$("div.PageTop > a").click(function(){
			$('html').animate({scrollTop:0}, 'slow');
		});
	});
	
	//
	$(".NewsImage").find("img").length==0?$(".NewsImage").hide():false;
});








