function pop_eyebeep(theURL,winName,features) { window.open(theURL,winName,features); } function ClearText(obj, DefaultText) { if (DefaultText == obj.value) { obj.value = ""; } } $(document).ready(function() { /* $("a#inpage").fancybox({ 'transitionIn' : 'fade', 'transitionOut' : 'fade', 'speedIn' : 800, 'speedOut' : 800, 'overlayShow' : true, 'overlayOpacity' : 0.9 }); */ $('.fancybox').fancybox(); $(".various").fancybox({ maxWidth : 980, maxHeight : 600, fitToView : true, width : '80%', height : '80%', autoSize : true, closeClick : false, openEffect : 'elastic', closeEffect : 'elastic' }); }); // Resizes YouTube iframes // Resize when window resizes window.onresize=function(){ }; // Resize onload $(document).ready(function() { /* * Grab all iframes on the page or return */ var iframes = document.getElementsByTagName( 'iframe' ); /* * Loop through the iframes array */ for ( var i = 0; i < iframes.length; i++ ) { var iframe = iframes[i], /* * RegExp, extend this if you need more players */ players = /www.youtube.com|www.youtube-nocookie.com|player.vimeo.com|www.svt.se|www.thinglink.com|nojesguidenplay.solidtango.com|player.vimeo.com/; /* * If the RegExp pattern exists within the current iframe */ if ( iframe.src.search( players ) > 0 ) { /* * Calculate the video ratio based on the iframe's w/h dimensions */ var videoRatio = ( iframe.height / iframe.width ) * 100; /* * Replace the iframe's dimensions and position * the iframe absolute, this is the trick to emulate * the video ratio */ iframe.style.position = 'absolute'; iframe.style.top = '0'; iframe.style.left = '0'; iframe.width = '100%'; iframe.height = '100%'; /* * Wrap the iframe in a new
which uses a * dynamically fetched padding-top property based * on the video's w/h dimensions */ var wrap = document.createElement( 'div' ); wrap.className = 'fluid-vids'; wrap.style.width = '100%'; wrap.style.position = 'relative'; wrap.style.paddingTop = videoRatio + '%'; /* * Add the iframe inside our newly created
*/ var iframeParent = iframe.parentNode; iframeParent.insertBefore( wrap, iframe ); wrap.appendChild( iframe ); } } $('#contactformbox').on('shown', function () { $('#collapsebutton').removeClass($('#collapsebutton').attr( "iconcollapse" )).addClass($('#collapsebutton').attr( "iconincollapse" )); }) $('#contactformbox').on('hidden', function () { $('#collapsebutton').removeClass($('#collapsebutton').attr( "iconincollapse" )).addClass($('#collapsebutton').attr( "iconcollapse" )); }); }); function submitContactForm(){ /* Stop form from submitting normally */ event.preventDefault(); var submit = $('#contactsubmit').attr("name") + "=" + $('#contactsubmit').val(); /* Get some values from elements on the page: */ var values = $('#contactform').serialize() + "&" + submit; var postData = { "contactname" : $('#contactname').val(), "contactemail" : $('#contactemail').val(), "contactmessage" : $('#contactmessage').val(), "contactsubmit" : $('#contactsubmit').val(), "webspace" : $('#webspace').val(), "webspacemail" : $('#webspacemail').val() }; ajaxContactForm(postData); } function ajaxContactForm(postData){ $.ajax({ type: 'POST', url: 'http://46.22.123.170/Kontakt/kontaktformPOST.php', crossDomain: true, data: postData, cache: false, success: function(){ $("#successmess").show(); setTimeout(function() { $("#successmess").hide(); $("#contactsubmit").removeAttr('disabled').css('opacity',1.0); }, 3000); $("#contactform").trigger('reset'); //jquery document.getElementById("contactform").reset(); //native JS setTimeout(function() { $('#contactformbox').collapse('hide') }, 2000); }, error:function(){ $("#failmess").show(); setTimeout(function() { $("#failmess").hide(); $("#contactsubmit").prop('disabled', false).css('opacity',1.0); }, 3000); } }); } function checkContactForm() { var strEText = "Du måste åtgärda följande: \n"; if($('input[name="contactname"]').length){ if($('input[name="contactname"]').attr("placeholder").indexOf("*") > 0) { if (document.contactform.contactname.value == "" || document.contactform.contactname.value == "Namn *") { strEText += "Fyll i namn \n"; } else if (!validateFORNAMN(document.contactform.contactname.value)) { strEText += "Fyll i en korrekt namn \n"; } }else if (!(document.contactform.contactname.value == "" || document.contactform.contactname.value == "Namn") && !validateFORNAMN(document.contactform.contactname.value)) { strEText += "Namnet är felaktigt \n"; } } if($('input[name="contactemail"]').length){ if($('input[name="contactemail"]').attr("placeholder").indexOf("*") > 0) { if (document.contactform.contactemail.value == "" || document.contactform.contactemail.value == "E-post *") { strEText += "Fyll i e-post \n"; } else if (!validateMAIL(document.contactform.contactemail.value)) { strEText += "Fyll i en korrekt e-postadress \n"; } }else if (!(document.contactform.contactemail.value == "" || document.contactform.contactemail.value == "E-post") && !validateMAIL(document.contactform.contactemail.value)) { strEText += "Din e-postadress är felaktigt \n"; } } if($('textarea[name="contactmessage"]').length){ if($('textarea[name="contactmessage"]').attr("placeholder").indexOf("*") > 0) { if (document.contactform.contactmessage.value == "" || document.contactform.contactmessage.value == "Meddelande *") { strEText += "Fyll i ett meddelande \n"; } else if (!validateTEXT(document.contactform.contactmessage.value)) { strEText += "Meddelandet är felaktigt \n"; } }else if (!(document.contactform.contactmessage.value == "" || document.contactform.contactmessage.value == "Meddelande") && !validateTEXT(document.contactform.contactmessage.value)) { strEText += "Meddelandet är felaktigt \n"; } } if (strEText != "Du måste åtgärda följande: \n") { alert(strEText); return false; } else { //måste finnas med för att skippa dubletter! $("#contactsubmit").attr('disabled','true').css('opacity',0.5); //document.forms[0].submit(); submitContactForm(); } } function validateFORNAMN(fornamn){ var contain = /^[A-öüÜ -]*$/; return contain.test(fornamn); } function validateMAIL(mail){ var contain = /^[_A-z0-9-]+(\.[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,3})$/; return contain.test(mail); } function validateTEXT(text){ var contain = /^[a-öüA-ÖÜ0-9\s:(),\-!?#%&.]*$/; return contain.test(text); } function submitGallup(webspace) { //alert('gallup'); if (!isSelected(document.gallup.gallupanswer)) { alert("Välj ett av svarsalternativen"); } else { //måste finnas med för att skippa dubletter! jQuery("#gallupbutton").attr('disabled','disabled').css('opacity',0.5); document.getElementById('gallupLoaderHolder').innerHTML = ''; $.ajax({ type: 'POST', url: 'http://' + webspace + '/includes/gallupExecute.php', data: $('#gallupForm').serialize(), cache: false, success: function(result) { setTimeout(function(){ jQuery("#gallupbutton").prop('disabled', false).css('opacity',1.0); createCookie('EYE_GALLUP', result, 365); $.ajaxSetup({ 'beforeSend' : function(xhr) { xhr.overrideMimeType('text/html; charset=ISO-8859-1'); }, }); $("#gallupHolder").load("http://" + webspace + "/includes/gallup.php?gallupID=" + result); }, 2000); } }); } } function isSelected(btns) { for (var i=0; el=btns[i]; i++) { if (el.checked) return true; } return false; } function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else { var expires = ""; } document.cookie = name + "=" + value + expires + "; path=/"; }