var starttimestamp = Math.round( new Date().getTime() / 1000 ); $(document).ready( function(){ // Aleay scroll to top $("html, body").scrollTop(0); // Tiptool $('[class="tooltip"]').mousemove( function( e ) { var title = $(this).attr('data-title'); var message = $(this).attr('data-message'); var x = e.pageX + 24; var y = e.pageY; if ( x > ( menupositionx - ( $("#tooltipbox").width() + 10 ) ) ) { x = x - ( $("#tooltipbox").width() + 45 ); } $("#tooltipbox").css( { left: x, top: y } ); $("#tooltipboxtitle").html( title ); $("#tooltipboxmessage").html( message ); $("#tooltipbox").show(); }); $('[class="tooltip"]').mouseout( function(e) { $("#tooltipbox").hide(); }); if ( $('body').width() <= 500 ){ $('[id="topimage"]').css( { 'background-size': '226%', 'background-position': '-100px 0px' } ); } if ( $('body').width() <= 440 ){ $('[id="customersupportemail"]').hide(); } var offset_top = 0; $(window).scroll(function () { offset_top = $('#responseinfo').offset().top; if ( $('body').width() > 500 && offset_top > 45 ){ $('[id=header-anchor]').css( { 'border-bottom' : '1px solid #c8c8cf' } ).fadeIn('slow'); $('[id=header-logo]').animate( { padding: '0px 0px 0px 0px', width: '113px', height: '30px' }, 400 ); $('[id=header-anchor]').animate( { height: '60px', opacity: '0.95', filter: 'alpha(opacity=95)' }, 400 ); $('[id=header-links]').animate( { padding: '5px 0px 0px 0px' }, 400 ); } // console.log( offset_top ); }); // Resize mapdiv if alone on line (small displays) $(window).on( "load resize", function() { if ( $('[id="aus_address_map"]').height() > 300 ){ $('[id=mapdisplay]').width( $('[id="aus_companyinfo"]').outerWidth() - 2 ); $('[id="aus_address_tbl"]').width( '100%' ); } }); }); /// FUNCTIONS /// function setCookie( c_name, value, exdays ){ var exdate=new Date(); exdate.setDate( exdate.getDate() + exdays ); var c_value = escape( value ) + ( ( exdays==null ) ? "" : "; expires=" + exdate.toUTCString() ); document.cookie = c_name + "=" + c_value; } function getCookie( c_name ){ var i,x,y,ARRcookies = document.cookie.split( ";" ); for( i=0; i 3 && document.e.parkzipcode.value.length == 4 ) { var s = document.e.parkaddress.value +", "+ document.e.parkzipcode.value +" "+ document.e.parkplace.value +" , Norway"; geocoder = new google.maps.Geocoder(); geocoder.geocode ( {'address':s}, function(results, status) { if(status == google.maps.GeocoderStatus.OK) { var p=results[0].geometry.location; document.e.lat.value=p.lat(); document.e.lng.value=p.lng(); map.setCenter(p); mapClick(p); } else { } } ); } } function lookupcoordsfromplace( place ) { if ( place.length >= 2 ) { var s = place +" , Norway"; geocoder = new google.maps.Geocoder(); geocoder.geocode ( {'address':s}, function(results, status) { if(status == google.maps.GeocoderStatus.OK) { var p=results[0].geometry.location; document.e.lat.value=p.lat(); document.e.lng.value=p.lng(); map.setCenter(p); mapClick(p); } else { } } ); } } function responseinfo( message, type ){ if ( type === undefined) { $('[id="responseinfo"]').css( 'background-color', '#3598DB' ); } else if ( type == 'warning' ) { $('[id="responseinfo"]').css( 'background-color', '#FF3333' ); } $('[id="responseinfo"]').html( message ); $('[id="responseinfo"]').slideDown( 300 ); setTimeout(function(){ $('[id="responseinfo"]').slideUp( 300 ); }, 2000 + ( message.length * 45 ) ); } function utf8_encode( string ) { for (var n=0, u=""; n < string.length; n++) { var c=string.charCodeAt(n); if (c < 128) { u += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { u += String.fromCharCode((c >> 6) | 192); u += String.fromCharCode((c & 63) | 128); } else { u += String.fromCharCode((c >> 12) | 224); u += String.fromCharCode(((c >> 6) & 63) | 128); u += String.fromCharCode((c & 63) | 128); } } return u; } function hex2rgb( hexStr, type ){ // note: hexStr should be #rrggbb var hex = parseInt(hexStr.substring(1), 16); var r = (hex & 0xff0000) >> 16; var g = (hex & 0x00ff00) >> 8; var b = hex & 0x0000ff; // return as array or string if ( type === undefined ) { return [r, g, b]; } else { return r +', '+ g +', '+ b; } } function initMap( address ) { var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var latlng = results[0].geometry.location; var mapOptions = { center: latlng, zoom: 15, streetViewControl: false }; map = new google.maps.Map( document.getElementById( 'mapdisplay' ), mapOptions ); marker = new google.maps.Marker({ map: map, position: latlng }); } else { // alert( 'Geocode was not successful for the following reason: ' + status ); } }); } function addMarker(location) { var marker = new google.maps.Marker({ position: location, map: map }); }