String.prototype.trim = new Function("return this.replace(/\\s+$|^\\s*/gi,'');");

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function GetDocObj(elementID){
	element = window.document.getElementById(elementID);
	return element;
}

function ValidateLogin(usernameID, passwordID, usernameMsg, passwordMsg){
	var IsOK = true;

	try{
		if (GetDocObj(usernameID).value.trim().length == 0){
			alert(usernameMsg);
			GetDocObj(usernameID).focus();
			IsOK = false;
		}
		if (IsOK && GetDocObj(passwordID).value.trim().length == 0){
			alert(passwordMsg);
			GetDocObj(passwordID).focus();
			IsOK = false;
		}
	}catch(e){
		IsOK = false;
		//alert(e);
	}

	return IsOK;
}
/*by tselios print page 05/02/2008*/
function LaunchPrintPagePopUp() 
{
  var win = null;
  win = window.open ("ECPrintPopup.html","_blank","resizable=no,scrollbars=no,toolbar=no,location=no,status=no,menubar=no,width=40,Height=40");
}

function PrintPageContent () {
	var targetWindow = null;
	var prHolder     = null;
	var plHolder     = null;
	var i = 0;
	
	try {
		if (self.opener!=null) {
			targetWindow = self.opener;
			this.document.title = targetWindow.document.title;
			prHolder = targetWindow.GetDocObj ("ContentHolder");
			plHolder = GetDocObj ("PrintContentHolder");
			if ((prHolder!=null) && (plHolder!=null)) {
				// Add Content
				plHolder.innerHTML = prHolder.innerHTML;
				// Clear any link
				for (i=0; i<this.document.links.length; i++) 
				{
				  this.document.links[i].href="#";
				}
				// focus and print
				self.focus();
				self.print();
			}   
		}  
	}
	
	catch (ex) {
		this.close();
	}
}
function getAbsoluteLeft(objectId) {
    // Get an object left position from the upper left viewport corner
    o = document.getElementById(objectId)
    oLeft = o.offsetLeft            // Get left position from the parent object
    while (o.offsetParent != null) {   // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent    // Get parent object reference
        oLeft += oParent.offsetLeft // Add parent left position
        o = oParent
    }
    return oLeft
}
function css_browser_selector(u) { var ua = u.toLowerCase(), is = function(t) { return ua.indexOf(t) > -1 }, g = 'gecko', w = 'webkit', s = 'safari', o = 'opera', m = 'mobile', h = document.documentElement, b = [(!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + RegExp.$1) : is('firefox/2') ? g + ' ff2' : is('firefox/3.5') ? g + ' ff3 ff3_5' : is('firefox/3.6') ? g + ' ff3 ff3_6' : is('firefox/3') ? g + ' ff3' : is('gecko/') ? g : is('opera') ? o + (/version\/(\d+)/.test(ua) ? ' ' + o + RegExp.$1 : (/opera(\s|\/)(\d+)/.test(ua) ? ' ' + o + RegExp.$2 : '')) : is('konqueror') ? 'konqueror' : is('blackberry') ? m + ' blackberry' : is('android') ? m + ' android' : is('chrome') ? w + ' chrome' : is('iron') ? w + ' iron' : is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.$1 : '') : is('mozilla/') ? g : '', is('j2me') ? m + ' j2me' : is('iphone') ? m + ' iphone' : is('ipod') ? m + ' ipod' : is('ipad') ? m + ' ipad' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' + (is('windows nt 6.0') ? ' vista' : '') : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', 'js']; c = b.join(' '); h.className += ' ' + c; return c; }; css_browser_selector(navigator.userAgent);


var MM_contentVersion = 7;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if (plugin) {
    var words = navigator.plugins["Shockwave Flash"].description.split(" ");
    for (var i = 0; i < words.length; ++i) {
        if (isNaN(parseInt(words[i])))
            continue;
        var MM_PluginVersion = words[i];
    }
    var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0
			&& (navigator.appVersion.indexOf("Win") != -1)) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
    document.write('on error resume next \n');
    document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
    document.write('</SCR' + 'IPT\> \n');
}

$(document).ready(function() {

    $("#srch-b")
             .click(function() {
                 $("#srch").css({ "display": "block" });
                 var left = getAbsoluteLeft('srch-b') - 340 + 'px';
                 $("#srch").css({ "left": left });
             })
    $("#srch-close")
     .click(function() {
         $("#srch").css({ "display": "none" });
     })
     try {
       if (parent != null && parent.document!=null && parent.document.getElementById("fancybox-frame") != null) {

        var iFrameContentHeight = parent.document.getElementById("fancybox-frame").contentWindow.document.body.scrollHeight;
        var iFrameContentWidth = parent.document.getElementById("fancybox-frame").contentWindow.document.body.scrollWidth; // id of iframe
        var outer = parent.$('#fancybox-outer');
        var inner = parent.$('#fancybox-content');
        var paddingTotal = 10;
        var extra = 10; // some extra space to avoid Scrollbars 

        if (iFrameContentHeight > 0 && iFrameContentWidth > 0) {
            outer.css({
                height: iFrameContentHeight + paddingTotal + extra,
                width: iFrameContentWidth + paddingTotal + extra
            });
            inner.css({
                height: iFrameContentHeight + extra,
                width: iFrameContentWidth + extra
            });
            //parent.$.fancybox.center();
        }
    }
    }
    catch (err){}
    if (document.getElementById("primary-navigation") != null) {
        $("#primary-navigation > li").each(function(i) {
            var width1 = $(this).outerWidth();
            $(this).find('ul:first-child').width(width1);
            $(this).find('a', 'ul:first-child').each(function(j) {
                $(this).width(width1 - 12);
            });
        });
    }

    if (document.getElementById("accordion") != null)
        $("#accordion").accordion({ active: false, collapsible: true, autoHeight: false, navigation: true, icons: { 'header': 'ui-icon-plus', 'headerSelected': 'ui-icon-minus'} });

});

   
