$(document).ready(function(){

	$('.ajaximagecheck').each(function(index){
		var imageobject = $(this);
		$.ajax({
		  url: imageobject.attr('src'),
		  statusCode: {
		    500: function() {
		     imageobject.remove();
		    }
		  }
		});
	})

});

var chosenCalendar= 0;

function showCalendar(PId,SId){
	if(document.getElementById(PId).style.display == 'block'){
		document.getElementById(PId).style.display = 'none';
	}
	else{ 
		document.getElementById(SId).style.display = 'none';
		document.getElementById(PId).style.display = 'block';
		}
}

function selectthisTop(id){
	if(id=='mit_tereba'){
		document.getElementById('mit_tereba').src = 'AjrGfx/gfx/btn_mit_tereba_on.gif';
	}
	if(id=='profil'){
		document.getElementById('profil').src = 'AjrGfx/gfx/btn_profil_on.gif';
	}
	if(id=='produktioner'){
		document.getElementById('produktioner').src = 'AjrGfx/gfx/btn_produktioner_on.gif';
	}
	if(id=='arrangementer'){
		document.getElementById('arrangementer').src = 'AjrGfx/gfx/btn_arrangementer_on.gif';
	}
	if(id=='data'){
		document.getElementById('data').src = 'AjrGfx/gfx/btn_data_on.gif';
	}
}

function selectthisTop2(id){
	if(id=='mit_tereba'){
		document.getElementById('mit_tereba').src = 'AjrGfx/gfx/btn_mit_tereba_off.gif';
	}
	if(id=='profil'){
		document.getElementById('profil').src = 'AjrGfx/gfx/btn_profil_off.gif';
	}
	if(id=='produktioner'){
		document.getElementById('produktioner').src = 'AjrGfx/gfx/btn_produktioner_off.gif';
	}
	if(id=='arrangementer'){
		document.getElementById('arrangementer').src = 'AjrGfx/gfx/btn_arrangementer_off.gif';
	}
	if(id=='data'){
		document.getElementById('data').src = 'AjrGfx/gfx/btn_data_off.gif';
	}
}



function selectthisGuide(id){

	if(id=='rightGuideTab_3pc01'){
		document.getElementById('rightGuideTab01pc03').src = 'AjrGfx/gfx/btn_assistent2_small_on.gif';
		document.getElementById('rightGuideTab02pc03').src = 'AjrGfx/gfx/btn_hjaelp2_small_off.gif';
		document.getElementById('rightGuideTab03pc03').src = 'AjrGfx/gfx/btn_vejledning2_small_off.gif';
		
		
		document.getElementById('rightGuide01').style.display = 'block';
		document.getElementById('rightGuide02').style.display = 'none';
		document.getElementById('rightGuide03').style.display = 'none';
	}
	
	if(id=='rightGuideTab_3pc02'){
		document.getElementById('rightGuideTab01pc03').src = 'AjrGfx/gfx/btn_assistent2_small_off.gif';
		document.getElementById('rightGuideTab02pc03').src = 'AjrGfx/gfx/btn_hjaelp2_small_on.gif';
		document.getElementById('rightGuideTab03pc03').src = 'AjrGfx/gfx/btn_vejledning2_small_off.gif';

		document.getElementById('rightGuide01').style.display = 'none';
		document.getElementById('rightGuide02').style.display = 'block';
		document.getElementById('rightGuide03').style.display = 'none';
	}
	
	if(id=='rightGuideTab_3pc03'){
		document.getElementById('rightGuideTab01pc03').src = 'AjrGfx/gfx/btn_assistent2_small_off.gif';
		document.getElementById('rightGuideTab02pc03').src = 'AjrGfx/gfx/btn_hjaelp2_small_off.gif';
		document.getElementById('rightGuideTab03pc03').src = 'AjrGfx/gfx/btn_vejledning2_small_on.gif';


		document.getElementById('rightGuide01').style.display = 'none';
		document.getElementById('rightGuide02').style.display = 'none';
		document.getElementById('rightGuide03').style.display = 'block';
	}
	
	
}

function selectthistab(id){

	if(id=='tab01'){
	
		document.getElementById('tab01').style.display = 'block';
		document.getElementById('tab02').style.display = 'none';
		document.getElementById('linktab01').className = 'textDarkBrown12';
		document.getElementById('linktab02').className = 'textGreen12';

	}
	
	if(id=='tab02'){
	
		document.getElementById('tab01').style.display = 'none';
		document.getElementById('tab02').style.display = 'block';
		document.getElementById('linktab01').className = 'textGreen12';
		document.getElementById('linktab02').className = 'textDarkBrown12';

	}
	
	if(id=='rightGuideTab01'){
		document.getElementById('rightGuide01').style.display = 'block';
		document.getElementById('rightGuide02').style.display = 'none';
		document.getElementById('rightGuideTab01').src = 'AjrGfx/gfx/btn_hjaelp2_left_on.gif';
		document.getElementById('rightGuideTab02').src = 'AjrGfx/gfx/btn_vejledning2_right_off.gif';
	}
	
	if(id=='rightGuideTab02'){
		document.getElementById('rightGuide01').style.display = 'none';
		document.getElementById('rightGuide02').style.display = 'block';
		document.getElementById('rightGuideTab01').src = 'AjrGfx/gfx/btn_hjaelp2_left_off.gif';
		document.getElementById('rightGuideTab02').src = 'AjrGfx/gfx/btn_vejledning2_right_on.gif';
	}
	


}


function rendermail(user, domain, classname, style){
  var1=user;
  var2=domain;
  var3=var1+'@'+var2;
  emailE=(var3);
  document.write ('<a class="'+ classname +'" style="'+style+'" href="mailto:' + emailE + '">' + emailE + '<\/a>');
}

function StartClientMail(user, domain){
  var1=user;
  var2=domain;
  var3=var1+'@'+var2;
  emailE=(var3);
  document.location.href='mailto:' + emailE;
}

function onEnter( evt, frm ) {
	var keyCode = null;

	if( evt.which ) {
		keyCode = evt.which;
	} else if( evt.keyCode ) {
		keyCode = evt.keyCode;
	}
	if( 13 == keyCode ) {
		frm.submit();
		return false;
	}
	return true;
}

function getPrintPage(){
	if(document.getElementById('AjrPrintContent') != null){
		var pageP = window.open('/print.asp','Print','width=680, height=650, resizable=1')
	}
}

function printPage(){

	window.document.title = window.opener.document.title;

	var sOut;
	sOut = '';

	if (window.opener.document.getElementById('AjrPrintContent')) {
	  sOut = sOut + window.opener.document.getElementById('AjrPrintContent').innerHTML;
	}

	if (window.opener.document.getElementById('AjrPrintContent2')) {
	  sOut = sOut + '<div style="margin-top: 30px;">' + window.opener.document.getElementById('AjrPrintContent2').innerHTML + '</div>';
	}

	document.getElementById('AjrPrintContent').innerHTML = sOut;
	document.body.style.backgroundImage='none';
	document.body.style.backgroundColor='#ffffff';

	window.print();
}

function setSelectedIndex( me, valsearch )
{
  for (i = 0; i< me.options.length; i++)
  {
    if ( me.options[i].value == valsearch )
    {
	  me.options[i].selected = true;
    //me.options[i].style.backgroundColor = '#dddddd';
      break;
    }
  }
  return;
}

function CalculateChars( strId, sname, ivalue, obj )
{
  var strValue = document.getElementById( strId ).value;
  var strReplaceAllR = strValue.indexOf('\r');
  var strReplaceAllN = strValue.indexOf('\n');
  
  /*
  while(strReplaceAllR != -1) {
    strValue = strValue.replace('\r','');
    strReplaceAllR = strValue.indexOf('\r');
  }
  while(strReplaceAllN != -1) {
    strValue = strValue.replace('\n','');
    strReplaceAllN = strValue.indexOf('\n');
  }
  */
  
  document.getElementById( sname ).innerHTML = ( ivalue - strValue.length );
  
  var mlength = obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
  
  if( strValue.length > mlength )
    obj.value = strValue.substring( 0, mlength )
    
}

function flipText( id, text )
{
  selectthisGuide('rightGuideTab_3pc01');
  
  var str = text;
  
  document.getElementById( id ).innerHTML = str;
}

function showText( id, text )
{
  var str = text;
  
  document.getElementById( id ).innerHTML = str;
}

function CheckboxShadow( me )
{
	var s = ''; 
	var o = document.getElementsByName( me.name );
	var f = document.getElementsByName( me.name.substring( 0, me.name.length - 7 ))[0];
		
	for(i=0; i< o.length; i++){ if(o[i].checked){ s+=o[i].value+', ' } } if(s.length>0){ s = s.substring(0, s.length-2); } f.value = s;
}
