var blank = new Image();
 blank.src = 'admin/design/images/blank.gif';
 
 $(document).ready(function(){
	$("#Photo #greybox h2").textShadow();
	$("a.faa-tilbud").textShadow();
	$("a.smallbutton").textShadow();
	$("h5").textShadow();
	$("#OtherPages .TilbudPages .TilbudHeader").textShadow();
	
   $("#page h1").textShadow();
   
	$('#faa-tilbud').click(function(){
		document.getElementById('Message').value = '';
		document.getElementById('PhoneTop').value = '';
		document.getElementById('EmailTop').value = '';
     $('#tilbudform').toggle(400);
   });
   $('#Closetilbudform').click(function(){
		document.getElementById('Message').value = '';
		document.getElementById('PhoneTop').value = '';
		document.getElementById('EmailTop').value = '';
		document.getElementById('PhoneErrorTop').style.display = 'none';
		document.getElementById('EmailErrorTop').style.display = 'none';
     $('#tilbudform').toggle(400);
   });
    $('#Canceltilbudform').click(function(){
		document.getElementById('Message').value = '';
		document.getElementById('PhoneTop').value = '';
		document.getElementById('EmailTop').value = '';
		document.getElementById('PhoneErrorTop').style.display = 'none';
		document.getElementById('EmailErrorTop').style.display = 'none';
     $('#tilbudform').toggle(400);
   });
	$('#whois').click(function(){
     $('#whois-dropdown').toggle(400);
   });
   $('#whoisimg').click(function(){
     $('#whois-dropdown').toggle(400);
   });
   $('#whois-cancel').click(function(){
     $('#whois-dropdown').toggle(400);
   });
   $('#whois-close').click(function(){
     $('#whois-dropdown').toggle(400);
   });
	
   $('#tilbudformajax').ajaxForm({ 
        beforeSubmit: validateTop, 
		success: function() { 
			document.getElementById('tilbudformajax').style.display = 'none';
			document.getElementById('ThankYou').style.display = 'block';
			document.getElementById('Message').value = '';
			setTimeout("$('#tilbudform').toggle(400)",2500);
			setTimeout("document.getElementById('tilbudformajax').style.display = 'block'",3000);
			setTimeout("document.getElementById('ThankYou').style.display = 'none'",3000);
			setTimeout("document.getElementById('PhoneErrorTop').style.display = 'none'",3000);
			setTimeout("document.getElementById('EmailErrorTop').style.display = 'none'",3000);
        } 
    });
	
	
	$('#tilbudpagebottom').ajaxForm({ 
		beforeSubmit: validateBottom, 
        success: function() { 
			document.getElementById('pagebottomform').style.display = 'none';
			document.getElementById('pagebottomThankYou').style.display = 'block';
			document.getElementById('pagebottomMessage').value = '';
        } 
    });
	
	
var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
   if (badBrowser) {
     // get all pngs on page
     $('img[src$=.png]').each(function() {
       if (!this.complete) {
         this.onload = function() { fixPng(this) };
       } else {
         fixPng(this);
       }
     });
   }
   
})

 function fixPng(png) {
   // get src
   var src = png.src;
   // set width and height
   if (!png.style.width) { png.style.width = $(png).width(); }
   if (!png.style.height) { png.style.height = $(png).height(); }
   // replace by blank image
   png.onload = function() { };
   png.src = blank.src;
   // set filter (display original image)
   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 }

function OpenLogin() {
	win_width = 450;
	win_height = 300;
	pos_horizon = ((screen.width/2)-(win_width/2));
	pos_vertical = ((screen.height/2)-(win_height/2));
	win = window.open("LoginPopup.asp", "Login", "Width="+win_width+",Height="+win_height+",Top="+pos_vertical+",Left="+pos_horizon+"");
	win.focus();
}

var winSepius = null;


function CloseSepius(){
		winSepius = window.open("sepius/default.asp", "Sepius","Width=2,Height=2,Top=0,Left=0,Scrollbars=yes,status=no,resizable");
		winSepius.close();
}


function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57))
}


function validateTop(formData, jqForm, options) { 
    // jqForm is a jQuery object which wraps the form DOM element 
    // 
    // To validate, we can access the DOM elements directly and return true 
    // only if the values of both the username and password fields evaluate 
    // to true 
 
    var form = jqForm[0]; 
	var regexp = /^[\w\.\-_]+@[\w\-_]+\.[\w\.\-_]{2,}$/i;
	var Phone=form.Phone.value;
	var Email=form.Email.value;
	
	if ((Phone=='') && (Email=='')) {
		document.getElementById("PhoneErrorTop").style.display = "block";
		document.getElementById("EmailErrorTop").style.display = "none";
		return false;
	} 
	else {
		document.getElementById("PhoneErrorTop").style.display = "none";
		document.getElementById("EmailErrorTop").style.display = "none";
 
		if (((Email!='')) && (!regexp.test(Email))) {
		document.getElementById("EmailErrorTop").style.display = "block";
		return false;
		} 
	}

}

function validateBottom(formData, jqForm, options) { 
    // jqForm is a jQuery object which wraps the form DOM element 
    // 
    // To validate, we can access the DOM elements directly and return true 
    // only if the values of both the username and password fields evaluate 
    // to true 
 
    var form = jqForm[0]; 
	var regexp = /^[\w\.\-_]+@[\w\-_]+\.[\w\.\-_]{2,}$/i;
	var Phone=form.Phone.value;
	var Email=form.Email.value;
	
	if ((Phone=='') && (Email=='')) {
		document.getElementById("PhoneErrorBottom").style.display = "block";
		document.getElementById("EmailErrorBottom").style.display = "none";
		return false;
	} 
	else {
		document.getElementById("PhoneErrorBottom").style.display = "none";
		document.getElementById("EmailErrorBottom").style.display = "none";
 
		if (((Email!='')) && (!regexp.test(Email))) {
		document.getElementById("EmailErrorBottom").style.display = "block";
		return false;
		} 
	}

}



function ConsoleOver(obj){
	obj.className='AdminConsole_cell_over'
}

function ConsoleOut(obj){
	obj.className='AdminConsole_cell_out'
}


function submitFormToPopup(formref,height,width) {
	win_width = ""+width+"";
	win_height = ""+height+"";
	pos_horizon = ((screen.width/2)-(win_width/2));
	pos_vertical = ((screen.height/2)-(win_height/2));
    newwin = window.open("about:blank","formvindue","width="+win_width+",height="+win_height+",Top="+pos_vertical+",Left="+pos_horizon+",Scrollbars=yes,status=no,resizable");
}

function PopUpWindow(url,height,width) {
	win_width = ""+width+"";
	win_height = ""+height+"";
	pos_horizon = ((screen.width/2)-(win_width/2));
	pos_vertical = ((screen.height/2)-(win_height/2));
	win = window.open(""+url+"", "WindowName", "Width="+win_width+",Height="+win_height+",Top="+pos_vertical+",Left="+pos_horizon+",Scrollbars=yes,status=no,resizable");
	win.focus();
}

function ConfirmLogOut()
	{ 	
		var agree=confirm(" Ønsker du at logge ud fra administrationssystemet?");
		if (agree)
		setTimeout("window.location = 'login.asp?Action=Logout'", 10);
		else
		return false; 
	}
	 
<!-- sletning skal bekræftes - bruges evt. ved gæstebog og lign.

function Confirm()
	{ 	
		var agree=confirm("Er du sikker på, at sletning skal foretages?");
		if (agree)
		return true;
		else
		return false; 
	}
 //-->

function mrfixit()
{
var fc = document.getElementById('fixedcell'); fc_top = fc.offsetParent.offsetTop; fc.style.top = document.documentElement.scrollTop + 
fc_top;
}
onscroll = mrfixit; 

var focusElem = null;
function dropdown( obj )
{
	if( focusElem != null )
	{
		focusElem.className = focusElem.className.replace(" over", "");
	}
	focusElem = obj.parentElement;
	focusElem.className += ' over';
}

function SyncDiv() //sørger for, at venstremenuen går helt til bund 
	{
	var iHeight;

	iHeight = document.getElementById('content').offsetHeight;
	bSync = false;

	if(document.getElementById('leftcolumn')) {
		if (document.getElementById('leftcolumn').offsetHeight>iHeight) {
				iHeight = document.getElementById('leftcolumn').offsetHeight;
				bSync = true;
				}
	}
	if(document.getElementById('rightcolumn')) {
		if (document.getElementById('rightcolumn').offsetHeight>iHeight) {
				iHeight = document.getElementById('rightcolumn').offsetHeight;
				bSync = true;
				}
	}

	if(bSync = true) {
		document.getElementById('content').style.height = iHeight + 'px';

		if(document.getElementById('leftcolumn')) {
			document.getElementById('leftcolumn').style.height = iHeight + 'px';
		}
		if(document.getElementById('rightcolumn')) {
			document.getElementById('rightcolumn').style.height = iHeight + 'px';
		}
	}
}


