/// <reference path="jquery-1.3.2.js" />
/*IE 6 hover plagin*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 u=k(){9 g=/^([^#.>`]*)(#|\\.|\\>|\\`)(.+)$/;k u(a,b){9 c=a.J(/\\s*\\,\\s*/);9 d=[];n(9 i=0;i<c.l;i++){d=d.v(o(c[i],b))};6 d};k o(a,b,c){a=a.z(" ","`");9 d=a.r(g);9 e,5,m,7,i,h;9 f=[];4(d==8){d=[a,a]};4(d[1]==""){d[1]="*"};4(c==8){c="`"};4(b==8){b=E};K(d[2]){w"#":7=d[3].r(g);4(7==8){7=[8,d[3]]};e=E.L(7[1]);4(e==8||(d[1]!="*"&&!x(e,d[1]))){6 f};4(7.l==2){f.A(e);6 f};6 o(7[3],e,7[2]);w".":4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};7=d[3].r(g);4(7!=8){4(e.j==8||e.j.r("(\\\\s|^)"+7[1]+"(\\\\s|$)")==8){q};m=o(7[3],e,7[2]);f=f.v(m)}y 4(e.j!=8&&e.j.r("(\\\\s|^)"+d[3]+"(\\\\s|$)")!=8){f.A(e)}};6 f;w">":4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};4(!x(e,d[1])){q};m=o(d[3],e,">");f=f.v(m)};6 f;w"`":5=p(b,d[1]);n(i=0,h=5.l;i<h;i++){e=5[i];m=o(d[3],e,"`");f=f.v(m)};6 f;M:4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};4(!x(e,d[1])){q};f.A(e)};6 f}};k p(a,b){4(b=="*"&&a.F!=8){6 a.F};6 a.p(b)};k x(a,b){4(b=="*"){6 N};6 a.O.G().z("P:","")==b.G()};6 u}();k Q(a,b){9 c=u(a);n(9 i=0;i<c.l;i++){c[i].R=k(){4(t.j.H(b)==-1){t.j+=" "+b}};c[i].S=k(){4(t.j.H(b)!=-1){t.j=t.j.z(b,"")}}}}4(D.I&&!D.T){D.I("U",V)}',58,58,'||||if|listNodes|return|subselector|null|var||||||||limit||className|function|length|listSubNodes|for|doParse|getElementsByTagName|continue|match||this|parseSelector|concat|case|matchNodeNames|else|replace|push|childNodes|nodeType|window|document|all|toLowerCase|indexOf|attachEvent|split|switch|getElementById|default|true|nodeName|html|hoverForIE6|onmouseover|onmouseout|opera|onload|ieHover'.split('|'),0,{}))
/*parametrs [selector, hover_class]*/
function ieHover() {
	hoverForIE6("div.sector-box .slide-holder .popup .box ul li, .search-drop ul li", "hover");
}

//external urls
$(function() { $('a[href][rel*=external]').each(function(i) { this.target = "_blank"; }); });

function initTabs()
{
	var sets = document.getElementsByTagName("ul");
	for (var i = 0; i < sets.length; i++)
	{
		if (sets[i].className.indexOf("tabset") != -1)
		{
			var tabs = [];
			var links = sets[i].getElementsByTagName("a");
			for (var j = 0; j < links.length; j++)
			{
				if (links[j].className.indexOf("tab") != -1)
				{
					tabs.push(links[j]);
					links[j].tabs = tabs;
					var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));

					//reset all tabs on start
					if (c) if (links[j].className.indexOf("active") != -1) c.style.display = "block";
					else c.style.display = "none";

					links[j].onclick = function ()
					{
						var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
						if (c)
						{
							//reset all tabs before change
							for (var i = 0; i < this.tabs.length; i++)
							{
								document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1)).style.display = "none";
								this.tabs[i].className = this.tabs[i].className.replace("active", "");
							}
							this.className += " active";
							c.style.display = "block";
							return false;
						}
					}
				}
			}
		}
	}
}

if (window.addEventListener) window.addEventListener("load", initTabs, false);
else if (window.attachEvent) window.attachEvent("onload", initTabs);


$(document).ready(function() {
    // Slide effect
    var _parentSlide = 'div.slide-block';
    var _linkSlide = 'a.open-close, div.heading-hold';
    var _slideBlock = 'div.popup';
    var _openClassS = 'open-slide';
    var _durationSlide = 300;

    $(_parentSlide).each(function() {
        if (!$(this).is('.' + _openClassS)) {
            $(this).find(_slideBlock).css('display', 'none');
        }
    });
    $(_linkSlide, _parentSlide).click(function() {
        if ($(this).parents(_parentSlide).is('.' + _openClassS)) {
            $(this).parents(_parentSlide).removeClass(_openClassS);
            $(this).parents(_parentSlide).find(_slideBlock).slideUp(_durationSlide, function() { $(this).parents("#header").css({ "z-index": "1" }); });

        } else {
            $(this).parents(_parentSlide).addClass(_openClassS);
            $(this).parents(_parentSlide).find(_slideBlock).slideDown(_durationSlide);
            $(this).parents("#header").css({ "z-index": "120" });
        }
        return false;
    });

    //top slide
    $('#top-fdi-box a.open-close').hover(function() {
        $(this).parents(_parentSlide).addClass(_openClassS);
        $(this).parents(_parentSlide).find(_slideBlock).slideDown(_durationSlide);
        $(this).parents("#header").css({ "z-index": "120" });

        var fdipopup = $('#top-fdi-box .popup');
        if (fdipopup.attr('hasBeenSet') == null) {
            fdipopup.attr('hasBeenSet', true);
            var top = fdipopup.offset().top;
            fdipopup.css('top', top - 16);
        }

        return false;
    });

    $('#top-fdi-box').mouseleave(function() {
        if ($(this).is('.' + _openClassS)) {
            $(this).removeClass(_openClassS);
            $(this).find(_slideBlock).slideUp(_durationSlide, function() {
                $(this).parents("#header").css({ "z-index": "1" });
            });
        }

        return false;
    });

    // search input ************************************************************
    var _searchText = $('#search-text');
    _searchText.attr("autocomplete", "off");
    _searchText.v = _searchText.val();
    var _serchPopup = $('div.search-drop');
    _searchText.focus(function() {
        if ($(this).val() == _searchText.v) {
            $(this).val('');
        }
    });
    _searchText.blur(function() {
        if ($(this).val() == '') {
            $(this).val(_searchText.v);
        }
        if (_serchPopup.is(':visible'))
            _serchPopup.fadeOut(300);
    });
    _searchText.keypress(function(e) {
        if (_serchPopup.is(':hidden'))
            _serchPopup.fadeIn(300);
    });
    _searchText.keyup(function(e) {
        $("#quickSearchActionlink").attr("href", "/search/country-starts-with/" + $(this).val());
        //document.getElementById("quickSearchActionlink").href =
        //            "/search/country-starts-with/" + $(this).val();
        $("#quickSearchActionlink").trigger("click");
    });
});
