function set_button_cancel(language, type){
	
	//delete the old button with the form
	document.getElementById('abo_tr').removeChild(document.getElementById('abo_td'));
	//create a new form with button to delete the notification 
	aboTD = document.createElement("td");
    aboTD.id='abo_td';
	aboTD.vAlign = 'top';
	aboTD.align = 'left';
	if(type == 3) aboTD.setAttribute("colspan", 4);
	aboTD.innerHTML = '<input type="image" src="../catalog/includes/languages/'+language+'/images/buttons/button_news-abo-abbestellen.jpg" alt="Abbestellen"   onclick="location=\'http://www.dvderotik.com/catalog/account_abos.php\'">';
	value = aboTD.innerHTML;
	document.getElementById('abo_tr').appendChild(aboTD);
}

function addNotification(customers_id, customers_email, notification_type, notification_id, name, language, active){
    
	if(active == '0'){
		if(language == 'german'){
		  alert('Sie müssen Ihr Abo nach Aktivieren!');	
		}else if(language == 'english'){
		  alert('You have to activate your subscription!');
		}
	}else if(active == '5'){
		if (language == 'german') {
			alert('Sie erhalten nun eine Mail die Sie bestätigen müssen.' + "\r\n" + 'Vorher können Sie Ihre Abos nicht einsehen');
		}else if(language == 'english'){
			alert('You will get a mail which you have to confirm.' + "\r\n" + 'Without this, you will not be able to see your subscriptions');
		}
	}

	jQuery.ajax({
		url 	: '/catalog/manage_notifications.php',
		type	: 'POST',
		global	: false,
		dataType: 'json',
		data	: {
				cid 	: customers_id,
				cmail	: customers_email,
				not_type: notification_type,
				not_id	: notification_id,
				sName   : name,
				language: language,
				active  : active
			},
		success: function(res) {
		    if (res.error > 0) {
                switch(res.error) {
                    case 2: // not logged in
                        alert(res.msg);
					     break;  
                    default:
                        alert(res.msg); break;
                }
            } else {
                alert(res.msg);
            }

        },
        error: function(xhr, errmsg, e) {
			alert('Bereits vorhanden');
        }
    }
	);
	return false;
}


/*
 * Show Image for not logged in users
 */

function loadLoader(language) {
  var WindowWidth = 0, WindowHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    WindowWidth = window.innerWidth-18;
    WindowHeight = window.innerHeight;
  } else if( document.documentElement ( document.documentElement.clientWidth || document.documentElement.clientHeight )){
	    //IE 6+ in 'standards compliant mode'
	    WindowWidth = document.documentElement.clientWidth;
	    WindowHeight = document.documentElement.clientHeight;
  } else if( document.body( document.body.clientWidth || document.body.clientHeight )){
	    //IE 4 compatible
	    WindowWidth = document.body.clientWidth;
	    WindowHeight = document.body.clientHeight;
  }

    loadDiv = document.createElement("div");
    loadDiv.id = 'container';
	document.getElementById('header').appendChild(loadDiv);
	
    link = "http://www.dvderotik.com/catalog/create_account.php";
	
	loadMap = document.createElement("div");
	loadMap.id='imgMap';
	loadMap.innerHTML = '<img src="../catalog/includes/languages/'+language+'/images/img_notify_new.jpg" width="650" height="500" border="0" usemap="#map" />'
						+'<map name="map">'
						+'<area shape="rect" coords="177,406,279,422" alt="create account" href="'+link+'" />'
                        +'<area shape="rect" coords="377,407,478,422" id="abort" nohref="nohref" />'
						+'</map>'; 
	document.getElementById('container').appendChild(loadMap);					
 }

$(document).ready(function(){
	
    $('#abort').live('click', function(){
        $('#container').remove();
    });
	
    $('#uacode').focus(function(){
		if($('#register_code').val() == "" || $('#register_code').val().length != 6){
			alert('Geben Sie einen gültigen Aktivierungscode ein.');
			$('#register_code').focus ;
			}
    });
	
	  $('#ubcode').focus(function(){
		if($('#code_booking').val() == "" || $('#code_booking').val().length != 8){
			alert('Geben Sie einen gültigen Aktivierungscode ein.');
			$('#code_booking').focus ;
			}
    });
	
	$('#bt_booking').click(function(){
		input = $('#text_output').val().toLowerCase();
		match = $('#ubcode').val().toLowerCase();
	  if (input != match){
	   	alert('Der Sicherheitscode ist nicht korrekt!');
		document.getElementById('ubcode').value = "";
		$('#ubcode').focus();
		return false;
	   }
	  if($('#ubcode').val().length != 5){
	   	alert('Geben Sie einen gültigen Sicherheits-Code ein!');
		$('#ubcode').focus();
		return false;
	   }	
	})
	
	
	$('#bt_activate').click(function(){
		input = $('#text_output').val().toLowerCase();
		match = $('#uacode').val().toLowerCase();
	   if (input != match){
	   	alert('Der Sicherheitscode ist nicht korrekt!');
		document.getElementById('uacode').value = "";
		$('#uacode').focus();
		return false;
	   }
	   if($('#uacode').val().length != 5){
	   	alert('Geben Sie einen gültigen Sicherheits-Code ein!');
		$('#uacode').focus();
		return false;
	   }	
	})
}); 

