
function insertFlash(fileName, pictureName) {
	var fileName = fileName;
	var pictureName = pictureName;
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
	if (!agentID) {
		
		$('#flashcontainer').flash(
			{
				swf: 'http://kundeweb.aggressive.no/users/naturalab.no/'+fileName,
				width: 540,
				height: 195
			});
	}else{
		$('#flashcontainer').css('display','none');
		$('#picturecontainer').html('<img src="' + pictureName + '" alt="" />');
	}
}

function readCookie(name) 
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) 
			{
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
		return ca['navn'];
	}

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=/";
	}

function jatakk()
	{
		createCookie('vilkar', 1, 1);
	}


function show_description(arg) {
	$('#' + arg).css('display','block');
}

function hide_description(arg) {
	$('#' + arg).css('display','none');
}

function popup(arg) {
						   
// Here we will write a function when link click under class popup				   
								
						
// Here we will describe a variable popupid which gets the
// rel attribute from the clicked link							
var popupid = $('#'+arg).attr('rel');


// Now we need to popup the marked which belongs to the rel attribute
// Suppose the rel attribute of click link is popuprel then here in below code
// #popuprel will fadein
$('#'+arg).fadeIn();


// append div with id fade into the bottom of body tag
// and we allready styled it in our step 2 : CSS
//$('body').append('<div id="fade"></div>');
$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();


// Now here we need to have our popup box in center of 
// webpage when its fadein. so we add 10px to height and width 
var popuptopmargin = ($('#' + popupid).height() + 10) / 2;
var popupleftmargin = ($('#' + popupid).width() + 10) / 2;


// Then using .css function style our popup box for center allignment
$('#' + popupid).css({
'margin-top' : -popuptopmargin,
'margin-left' : -popupleftmargin
});



// Now define one more function which is used to fadeout the 
// fade layer and popup window as soon as we click on fade layer
$('#fade').click(function() {


// Add markup ids of all custom popup box here 						  
$('#fade , #popuprel, #tips').fadeOut()
return false;
});
};

function ajaxcall(arg){
  		$.ajax({
			url: 'ajax.asp?ID=' + arg ,
			success: function(data) {
				$('#produkt').html(data);		
			}
		});
	}
	
function ajaxcall2(arg){
  		$.ajax({
			url: 'ajax2.asp?ID=' + arg ,
			success: function(data) {
				$('#produkt').html(data);		
			}
		});
	}
	
function popup2(url2)
	{
		$('#popuprel').remove();
		var div = '';
		var div2 = '';
		div += '<div class="popupbox2" id="popuprel">';	
		
		$.ajax({
			url: url2,
			success: function(data) {
				div += $('#popuprel').html(data);		
			}
		});
		
		div += '</div>';
		var div2 = '<div id="fade"></div>';
		
		$("body").append(div);
		$("body").append(div2);
		
		$('#popuprel').fadeIn();
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
		
		
		$('#fade').click(function() {
			// Add markup ids of all custom popup box here 						  
			$('#fade,#popuprel').fadeOut()
			return false;
			});
	}
	
	function validate() {
		$('input[type=submit]').attr('disabled','disabled');
		var valid = true;
		var flereepost = false;
		var vilkar = readCookie('vilkar');
		var language = $('#language').val();
		var msg = "";
		if(language == 'FIN') {msg = "Täytä seuraavat kentät:" + "\n";}
		if(language == 'NOR') {msg = "Følgende felter er feil fylt ut:" + "\n";}
		if(language == 'SWE') {msg = "Var god fyll i följande felt:" + "\n";}
						
		$('#validate_form input').each(function(index) {
			
			if($(this).attr('type') != "hidden") {
				var navn = $(this).attr('navn');
				
				if($(this).attr('rel') == "text") {
					
					if(navn == "Adresse") {
						var adresse1 = $(this).val();
						var words = ["pb","postboks","postbox","pbox","pboks","boks","box","post"];	
							
						for(i=0;i<words.length;i++)
							{
								if(adresse1.indexOf(words[i]) != -1){
									msg += "-Vi godtar ikke postbokser" + "\n";
									valid = false;
									$(this).css('background','#ff8484');
									break;
								}else{
									$(this).css('background','#fff');
								}
							}	
							
						if(adresse1.length < 4) {
							msg += "-Adresse" + "\n";
							valid = false;
							$(this).css('background','#ff8484');
						}
					}else{
						if($(this).val().length < 2) {
							$(this).css('background','#ff8484');
							valid = false;
							msg += "-" + navn + "\n";
						}else{
							$(this).css('background','#fff');
						}
					}
				}
				if($(this).attr('rel') == "number") {
					if(isNaN(parseInt($(this).val())) || $(this).val().length < 4) {
						$(this).css('background','#ff8484');
						valid = false;
						msg += "-" + navn + "\n";
					}else{
						$(this).css('background','#fff');
					}
					
				}
				if($(this).attr('rel') == "e-post") {
					if($(this).val().indexOf('@') == -1) {
						$(this).css('background','#ff8484');
						valid = false;
						msg += "-" + navn + "\n";
					}else{
						$(this).css('background','#fff');
					}
					
				}
				
				
			}
		});
		
		if(vilkar != 1)  {
			if(language == 'NOR') {msg += "NB! Du må huke av for at du har lest vilkårene.";}
			if(language == 'SWE') {msg += "Obs! Du måste markera rutan för att bekräfta att du har läst villkoren.";}
			if(language == 'FIN') {msg += "HUOM! Sinun täytyy ruksata laatikko jossa toteat lukeneesi ehdot.";}
			valid = false;
		}
		
		if(valid == false) {
			$('input[type=submit]').attr('disabled','');
			alert(msg);
			return false;
		}
	}
	
	function validate2() {
		var valid = true;
		var language = $('#language').val();
		var msg = "";
		if(language == 'FIN') {msg = "Täytä seuraavat kentät:" + "\n";}
		if(language == 'NOR') {msg = "Følgende felter er feil fylt ut:" + "\n";}
		if(language == 'SWE') {msg = "Var god fyll i följande felt:" + "\n";}

						
		$('#validate_form2 input').each(function() {
			
			if($(this).attr('type') != "hidden") {
				var navn = $(this).attr('navn');
				
				if($(this).attr('rel') == "text") {
					if($(this).val().length < 2) {
						$(this).css('background','#ff8484');
						valid = false;
						msg += "-" + navn + "\n";
					}else{
						$(this).css('background','#fff');
					}
				}
				if($(this).attr('rel') == "number") {
					if(isNaN(parseInt($(this).val())) || $(this).val().length < 4) {
						$(this).css('background','#ff8484');
						valid = false;
						msg += "-" + navn + "\n";
					}else{
						$(this).css('background','#fff');
					}
					
				}
				if($(this).attr('rel') == "e-post") {
					if($(this).val().indexOf('@') == -1) {
						$(this).css('background','#ff8484');
						valid = false;
						msg += "-" + navn + "\n";
					}else{
						$(this).css('background','#fff');
					}
					
				}
				
				
			}
		});
		
				
		if(valid == false) {
			alert(msg);
			return false;
		}
	}

	




