﻿function mailTo(email){
	var reg,email;
	reg = /#/g;
	email = email.replace(reg, "@");
	location.href="mai" + "lto:" + email;
}

	function setStyleSheet(title,type)
	{
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
		{
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && isStyleSheetType(a.getAttribute("title"),type))
			{
				a.disabled = true;
				if(a.getAttribute("title") == title)
				{
					a.disabled = false;

				}

				else if(getCookie( 'as' ) != null && a.getAttribute("title") == getCookie( 'as' ))
				{
					a.disabled = false;
				}

				setCookie('ss',title, '/');
				setCookie('st',type, '/');
			}
		}
	}

	function setSecondStyleSheet(title,type)
	{

		var i, a, main;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
		{
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && isStyleSheetType(a.getAttribute("title"),type))
			{
				a.disabled = true;
				if(a.getAttribute("title") == title)
				{
					a.disabled = false;

				}

				else if(getCookie( 'ss' ) != null && a.getAttribute("title") == getCookie( 'ss' ))
				{
					a.disabled = false;
				}

				setCookie('as',title, '/');
				setCookie('at',type, '/');
			}
		}

	}

	function isStyleSheetType(str,type) 
	{
		if( str == "" )
		{ 
			return true; 
		}
		else if( type == "width" && str.match(/\d/) )
		{ 
			return true; 
		}
		else if( type != "width" && str.match(/^\D*$/) ) 
		{ 
			return true; 
		}
		
		return false;
	}
	
	function loadSelectedStyleSheet()
	{
		if (getCookie( 'ss' ) != null)
		{
			setStyleSheet( getCookie( 'ss' ) , getCookie( 'st' ) );
		}
		if(getCookie( 'as' ) != null)
		{
			setSecondStyleSheet( getCookie( 'as' ) , getCookie( 'at' ) );
		}

	}


	function getCookie( _cookie_name )
	{
		var results = document.cookie.match( _cookie_name + '=(.*?)(;|$)' );

		if ( results )
			return ( unescape ( results[1] ) );
		else
			return null;
	}


	function setCookie( _name, _value, _path )
	{


	  var cookie_string = _name + "=" + escape ( _value );


	  if ( _path )
		cookie_string += "; path=" + escape ( _path );

	  document.cookie = cookie_string;


	}

function checkAtvinna()
{
	if(document.getElementById('browse').value == "")
	{
		alert("Þú verður að láta mynd fylgja með!");				
		return false;
	}
	else if(document.getElementById('Nafn').value == "")	
	{
		alert("Þú verður að skrifa nafn!");				
		return false;
	}
	else if(document.getElementById('Kennitala').value == "")	
	{
		alert("Þú verður að skrifa kennitölu!");				
		return false;
	}
	else
	{
		return true;
	}
}
