
// CSS init (c) Agents.se - v4.0
/*
CSS Browser Selector v0.4.0 (Nov 02, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
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);

// No spam e-mail address v2
function noSpam(a,b,c,d) {
	if (d==null) {
		d = c+'@'+b+'.'+a;
	}
	document.write('<a href="mai'+'lto:'+c+'@'+b+'.'+a+'" class="sticky">'+d+'</a>');
}

// Go to url
function go(a) {
	document.location.href = a;
}
function formgo() {
	document.forms[0].submit();
	return false;
}

// jQuery setup on page load
$(document).ready(function() {
	autoblur();
});
function autoblur() {
	$("a").mouseup(function(){
		$(this).blur();
	});
	$("select").change(function() {
		$(this).blur();
	});
}

// Validate form v2
var regEml = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
var regDrp = /[^0]/i;

function validate(a, b, c, e, d) {
    var keyCode = (window.event) ? e.which : e.keyCode;
	if (e.keyCode != 9 || e.keyCode == null) { // Don't run on tab key
		switch (b) {
			case "txt": a.value.length >= c ? g=1 : g=0; break;
			case "eml": a.value.match(regEml) ? g=1 : g=0; break;
			case "drp":	a.value.match(regDrp) ? g=1 : g=0; break;
			case "rad":	a.checked ? g=1 : g=0; break;
}
		if (a.id.indexOf("_") != -1) {
		    h = "s" + a.id.substring(a.id.lastIndexOf("_")+1);
			//b = a.id.substring(0,a.id.indexOf("_"));
			//c = a.id.substring(a.id.indexOf("_")+1);
			//h = b+"_s"+c;
		} else {
			h = "s"+a.id;
        }

		f = document.getElementById(h);
		g ? f.className = "fsignok" : f.className = "fsignalert";
		g ? $("#"+h).attr("title", "Valid input") : $("#"+h).attr("title", "Invalid input");
		return true;
	}
}

function showcontact(a,b) {
    if ($("#"+a).is(":hidden")) {
    		$("#"+a).slideDown(400);
    		scrollPage(a,b);
    	}
	return false;
}
// Tree toggle
function tree(a,b,c,d) {
	if ($("#"+a+" .container").is(":hidden")) {
		$("#"+b+" .icoarrdown").removeClass();
		$("#"+a+" a:first").addClass("icoarrdown");
		$("#"+b+" .container").slideUp(400);
		$("#"+a+" .container").slideDown(400);
		scrollPage(a,c);
		if (!d)
		_gaq.push(['_trackPageview', '/'+a]); // Analytics push
	} else {
		$("#"+a+" a:first").removeClass();
		$("#"+a+" .container").slideUp(400);
	}
	return false;
}

// Toggle div
function toggle(a,b) {
	if ($("#"+a).is(":hidden")) {
		$("#"+a).slideDown(400);
		scrollPage(a,b);
		_gaq.push(['_trackPageview', '/'+a]); // Analytics push
	} else {
		$("#"+a).slideUp(400);
	}
	return false;
}
function scrollPage(a,b) {
	if($.browser.safari){bodyelem=$("body")}else{bodyelem=$("html")}
	d = ($("#"+a).offset().top+b)-($(window).height()+bodyelem.scrollTop());
	if (d>30)
	$("html, body").animate({scrollTop:"+="+d+"px"}, 1000);
}

//start added by BnearIT /NK
// Tree toggle
function tree2(e, a, b, c, d) {
//    if (d == 'true') {
//        alert("This file is protected. Please send a message using the form bellow to get the information e-mailed to you.");
//    }
//    if ($("#" + a + " .container").is(":hidden")) {
//        $("#" + b + " .icoarrdown").removeClass();
//        $("#" + a + " a:first").addClass("icoarrdown");
//        $("#" + b + " .container").slideUp(400);
//        $("#" + a + " .container").slideDown(400);
//        scrollPage(a, c);
//    }
//    else {
//        scrollPage(a, c);
//    }
//    return false;

    //if (d == 'true') {
    //    alert("This file is protected. Please send a message using the form bellow to get the information e-mailed to you.");
    //}

    f = document.getElementById(e);
    if (f.className == "showC") {
        f.className = "container";
        $("#" + a + " a:first").removeClass();
        $("#" + a + " .showC").slideUp(400);
        return false;
    }

    if ($("#" + a + " .container").is(":hidden")) {
        $("#" + b + " .icoarrdown").removeClass();
        $("#" + a + " a:first").addClass("icoarrdown");
        $("#" + b + " .container").slideUp(400);
        $("#" + a + " .container").slideDown(400);
        scrollPage(a, c);
				_gaq.push(['_trackPageview', '/'+a]); // Analytics push
    } else {
        scrollPage(a, c);
    }
    return false;
}

//start added by BnearIT /ML

var regDrp2 = /[^0]/i;

function validateDDL(a, e) {
    var keyCode = (window.event) ? e.which : e.keyCode;
    if (e.keyCode != 9 || e.keyCode == null) { // Don't run on tab key

        a.value.match(regDrp2) ? g = 1 : g = 0;
        h = a.id + "S";

        f = document.getElementById(h);
        g ? f.className = "fsignok" : f.className = "fsignalert";
       // g ? $("#" + h).attr("title", "Valid input") : $("#" + h).attr("title", "Invalid input");
        return false;
    }
}

function validateText(a, c, e) {
    var keyCode = (window.event) ? e.which : e.keyCode;
    if (e.keyCode != 9 || e.keyCode == null) { // Don't run on tab key

        a.value.length >= c ? g = 1 : g = 0;
        h = a.id + "S";

        f = document.getElementById(h);
        g ? f.className = "fsignok" : f.className = "fsignalert";
       // g ? $("#" + h).attr("title", "Valid input") : $("#" + h).attr("title", "Invalid input");
        return false;
    }
}
var regEml2 = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;

function validateEmail(a, e) {
    var keyCode = (window.event) ? e.which : e.keyCode;
    if (e.keyCode != 9 || e.keyCode == null) { // Don't run on tab key
        a.value.match(regEml2) ? g = 1 : g = 0;
        h = a.id + "S";
        f = document.getElementById(h);
        g ? f.className = "fsignok" : f.className = "fsignalert";
       // g ? $("#" + h).attr("title", "Valid input") : $("#" + h).attr("title", "Invalid input");
        return true;
    }
}
function treeC(e, a, b, c, d) {
    f = document.getElementById(e);
    if (f.className == "showC") {
        f.className = "container";
        $("#" + a + " a:first").removeClass();
        $("#" + a + " .showC").slideUp(400);
        return false;
    }
    if ($("#" + a + " .container").is(":hidden")) {
        $("#" + b + " .icoarrdown").removeClass();
        $("#" + a + " a:first").addClass("icoarrdown");
        $("#" + b + " .container").slideUp(400);
        $("#" + a + " .container").slideDown(400);
        scrollPage(a, c);
				_gaq.push(['_trackPageview', '/'+a]); // Analytics push
    } else {
        $("#" + a + " a:first").removeClass();
        $("#" + a + " .container").slideUp(400);
    }
    return false;
}
function treeClear(h, m, ph, n, e, a, b, c, d) {
    name = document.getElementById(h);
    name.value = "";
    nameS = name.id + "S";
    nameP = document.getElementById(nameS);
    nameP.className = "fsign";

    email = document.getElementById(m);
    email.value = "";
    emailS = email.id + "S";
    emailP = document.getElementById(emailS);
    emailP.className = "fsign";

    phone = document.getElementById(ph);
    phone.value = "";

    medd = document.getElementById(n);
    medd.value = "";
    meddS = medd.id + "S";
    meddP = document.getElementById(meddS);
    meddP.className = "fsign";

    f = document.getElementById(e);
    if (f.className == "showC") {
        f.className = "container";
        $("#" + a + " a:first").removeClass();
        $("#" + a + " .showC").slideUp(400);
        return false;
    }

    if ($("#" + a + " .container").is(":hidden")) {
        $("#" + b + " .icoarrdown").removeClass();
        $("#" + a + " a:first").addClass("icoarrdown");
        $("#" + b + " .container").slideUp(400);
        $("#" + a + " .container").slideDown(400);
        scrollPage(a, c);
				_gaq.push(['_trackPageview', '/'+a]); // Analytics push
    } else {
        $("#" + a + " a:first").removeClass();
        $("#" + a + " .container").slideUp(400);
    }
    return false;
}

function GetClientUTC(from, to) {
    var now = new Date();
    var offset = now.getTimezoneOffset(); //Ger offset till UTC i minuter!
    var hours = offset / 60;  //-120 // alert(hours); //2

    stringOut = "(UTC";
    if (hours > 0)
        stringOut += "-";
    else {
        stringOut += "+";
        hours = -hours;
    }
    if ((hours < 10) )
        stringOut += "0";

    stringOut += hours.valueOf().toString();
        f = document.getElementById("UTCdiff");
        f.value = stringOut + ".00):";  //fast fel font mm
		//$("#UTCdiff").append(stringOut+".00):");

    b = document.getElementById(from);
    if (b.value.length < 1) {
        h = document.getElementById("contactUTC");
        h.value = " ";
		//$("#contactUTC").html(" ");
        return;
    }
    fromH = b.value;
    hours = offset / 60;

    fromH = fromH - hours;
    if (fromH < 0) {
        fromH = fromH + 24;
    }
    if (fromH > 24) {
        fromH = fromH - 24;
    }

    if (fromH == 0) {
        fromH = 24;
    }
    var suffix = "AM";
    if (fromH > 12) {
        suffix = "PM";
        fromH = fromH - 12;
    }



    c = document.getElementById(to);
    toH = c.value;
    hours = offset / 60;

    toH = toH - hours;
    if (toH < 0) {
        toH = toH + 24;
    }
    if (toH > 24) {
        toH = toH - 24;
    }

    suffix2 = "AM";
    if (toH == 0) {
        toH = 24;
    }
    if (toH > 12) {
        suffix2 = "PM";
        toH = toH - 12;
    }
//    h.value += " - "+toH + " " + suffix;

        h = document.getElementById("contactUTC");
        h.value = fromH + " " + suffix + " - " + toH + " " + suffix2;
		//$("#contactUTC").html(fromH + " " + suffix+" - "+toH + " " + suffix2);
}

//stop added by BnearIT /ML
function togglediv(a) {
	if ($("#"+a).is(":hidden")) {
		$("#"+a).show();
	} else {
		$("#"+a).hide();
	}
	return false;
}
function blanket_size(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
        viewportheight = window.innerHeight;
    } else {
        viewportheight = document.documentElement.clientHeight;
    }
    if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
        blanket_height = viewportheight;
    } else {
        if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
            blanket_height = document.body.parentNode.clientHeight;
        } else {
            blanket_height = document.body.parentNode.scrollHeight;
        }
    }
    var blanket = document.getElementById('blanket');
    blanket.style.height = blanket_height + 'px';
    var popUpDiv = document.getElementById(popUpDivVar);
    popUpDiv.style.top = (viewportheight/2)-($("#"+popUpDivVar).height()/2)+$(window).scrollTop()+"px";
}
function window_pos(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
        viewportwidth = window.innerHeight;
    } else {
        viewportwidth = document.documentElement.clientHeight;
    }
    if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
        window_width = viewportwidth;
    } else {
        if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
            window_width = document.body.parentNode.clientWidth;
        } else {
            window_width = document.body.parentNode.scrollWidth;
        }
    }
    var popUpDiv = document.getElementById(popUpDivVar);
    window_width = window_width/2 - 175; //175 is half popup's width
    popUpDiv.style.left = window_width + 'px';
}


function popupOpen(a,n) {

	blanket_size(a);
	window_pos(a);
	togglediv("blanket");
	togglediv(a);
	//alert(n); //ok
	$('#requestedDocument').val(n);
	
//	b=$('#requestedDocument').val();
//	alert(b);//ok
//	if (openClose == 'close') {
//		_gaq.push(['_trackPageview', '/'+a]); // Analytics push
//		$("#contactsend .container").hide();
//		tree("contactsales","salescontact",400,true);		
//	}	
	return false;
}
function popupClose(a,openClose,g,m) {

	blanket_size(a);
	window_pos(a);
	togglediv("blanket");
	togglediv(a);
	if (openClose == 'close') {
		_gaq.push(['_trackPageview', '/'+a]); // Analytics push
		$("#contactsend .container").hide();
		tree("contactsales","salescontact",400,true);		
	}
	$("#contactsales #"+m).val("Hi, can you please contact me regarding the protected content of this page.");
	b=$('#requestedDocument').val();
	// alert(b);
    $('#'+g).val(b);
   
	//alert('close');
	return false;
}


function noProtectedFiles(g, m, n) {  
	$("#contactsales #"+m).val("Hi, can you please contact me regarding "+n+".");		
	$('#'+g).val("");   
	//alert(n); 
}


