var WEBROOT;
var SESSION_NAME;
var SESSION_ID;
/**
 * INIT
 */
function init(strWebroot,strSessionName,strSessionId) {
    WEBROOT = strWebroot;  
    SESSION_NAME = strSessionName;
    SESSION_ID = strSessionId;
}


/**
 * Benutzerverwaltung:
 * Alle Benutzer auswählen (Select-Box)
 */
function select_all(name){
    $("input[name='"+name+"']").each(function()
    {
    	if(this.checked) {
        	this.checked = '';
        } else {
        	this.checked = 'checked';
        }
    });
}

/**
 * Benutzerverwaltung:
 * E-Mail Vorlage laden (Select-Box)
 */
function loademail(url) {
	$.get(url, function(data){
		var content = unescape($(data).find("content").text());
		var title = unescape($(data).find("title").text());
		document.getElementById('email_message').innerHTML=content;
		document.getElementById('email_title').value=title;

	});

}


/**
 * Umfrage:
 * Zur nächsten Fragen springen (URL)
 */
function go_question(id) {
	if(id>1) {
		var lastid = id-1;
		$('#page'+lastid).hide('slow');
	}

	$('#page'+id).show('slow');
	var nextid = id+1;
	if($('#page'+nextid)) {
		$('#page'+nextid).hide('slow');
	}

}

/**
 * Werbcodes:
 * Eingabefelder für Werbung ein/ausblenden
 */
function showAdcodeInput(type){
	if (type == 0) {
		$('#divTitle').css("display","");
		$('#divDescription').css("display","");
	} else {
		$('#divTitle').hide();
		$('#divDescription').hide();
	}
}

/**
 * Abuse Archiv:
 * Eingabefelder für Archiv ein/ausblenden
 */
function showAbuseEditInput(type){
	if (type == 'changeabuser') {
		$('#abuser').css("display","");
		$('#workedid').css("display","none");
		$('#status').css("display","none");
		$('#btnEdit').css("display","");
	} else if (type == 'changeworker') {
		$('#abuser').css("display","none");
		$('#workedid').css("display","");
		$('#status').css("display","none");
		$('#btnEdit').css("display","");
	}  else if (type == 'changestatus') {
		$('#abuser').css("display","none");
		$('#workedid').css("display","none");
		$('#status').css("display","");
		$('#btnEdit').css("display","");
	} else {
		$('#abuser').css("display","none");
		$('#workedid').css("display","none");
		$('#status').css("display","none");
		$('#btnEdit').css("display","none");

	}
}

/**
 * Account Verwaltung
 * Eingabefelder für Rechte ein/ausblenden
 */
function showUserRightsSettings(type){
	if (type == 'Contact') {
		$('#rightsAbuser').css("display","none");
		$('#rightsWebmaster').css("display","none");
		$('#rightsMod').css("display","none");
		$('#webmasterOptions').css("display","none");
		$('#adcompanyOptions').css("display","none");
	} else if (type == 'Webmaster') {
		$('#rightsAbuser').css("display","none");
		$('#rightsWebmaster').css("display","");
		$('#rightsMod').css("display","none");
		$('#webmasterOptions').css("display","");
		$('#adcompanyOptions').css("display","none");
	} else if (type == 'Abuser') {
		$('#rightsAbuser').css("display","");
		$('#rightsWebmaster').css("display","none");
		$('#rightsMod').css("display","none");
		$('#webmasterOptions').css("display","none");
		$('#adcompanyOptions').css("display","none");
	} else if (type == 'Mod') {
		$('#rightsAbuser').css("display","none");
		$('#rightsWebmaster').css("display","none");
		$('#rightsMod').css("display","");
		$('#webmasterOptions').css("display","none");
		$('#adcompanyOptions').css("display","none");
	} else if (type == 'Adcompany') {
		$('#rightsAbuser').css("display","none");
		$('#rightsWebmaster').css("display","none");
		$('#rightsMod').css("display","none");
		$('#webmasterOptions').css("display","none");
		$('#adcompanyOptions').css("display","");
	} else {
		$('#rightsAbuser').css("display","none");
		$('#rightsWebmaster').css("display","none");
		$('#rightsMod').css("display","none");
		$('#webmasterOptions').css("display","none");
		$('#adcompanyOptions').css("display","none");

	}
}

/**
 * Projekt Verwaltung
 * Eingabefelder für Typen ein/ausblenden
 */
function showProjectTypeSettings(type){
	if (type == 'Crypter') {
		$('#divAbusesystem').css("display","");
		$('#divLayersystem').css("display","");
	} else if (type == 'Website') {
		$('#divAbusesystem').css("display","none");
		$('#divLayersystem').css("display","");
	} else if (type == 'Hoster') {
		$('#divAbusesystem').css("display","");
		$('#divLayersystem').css("display","");
	}  else {
		$('#divAbusesystem').css("display","none");
		$('#divLayersystem').css("display","none");

	}
}

/**
 * Zeitraum f�r Werbekampagne einblenden
 */
function showCampaignPeriod(intShow) {
	if (intShow == 2) {
		$('#divCampaignPeriod').css('display','inline');
	} else {
		$('#divCampaignPeriod').css('display','none');
	}
}

/**
 * Zone entfernen
 */
function deleteZone(zone) {
 if(confirm('Wirklich löschen?'))
 {
	 $('#zone_'+zone).remove();
 }
return false;
}

/**
 * Zone hinzufügen
 */
function addZone()
{


  $("#zoneselect option:selected").each(function () {
		var $id;
		$id = $(this).val();
		$id = $id.replace(/;/g,'');
		if(!$("#zone_"+$id).html())
		{
			$("#zone_box").html($('#zone_box').html()+'<span style="padding:2px;background-color: rgb(238, 238, 238);margin:2px;" id="zone_'+$id+'">'+$(this).text()+'<a onclick="return deleteZone(\''+$id+'\');" title="Löschen" href="#"><img alt="Löschen" src="http://www.selsin.net/gfx/icon_remove.gif"></a><input type="hidden" name="strPartnerZones[]" value="'+$(this).val()+'"></span>');
		}
	  });

  
}

/**
 * BZone entfernen
 */
function deleteBZone(zone) {
 if(confirm('Wirklich löschen?'))
 {
	 $('#bzone_'+zone).remove();
 }
return false;
}

/**
 * BZone hinzufügen
 */
function addBZone()
{


  $("#bzoneselect option:selected").each(function () {
		var $id;
		$id = $(this).val();
		$id = $id.replace(/;/g,'');
		if(!$("#bzone_"+$id).html())
		{
			$("#bzone_box").html($('#bzone_box').html()+'<span style="padding:2px;background-color: rgb(238, 238, 238);margin:2px;" id="bzone_'+$id+'">'+$(this).text()+'<a onclick="return deleteBZone(\''+$id+'\');" title="Löschen" href="#"><img alt="Löschen" src="http://www.selsin.net/gfx/icon_remove.gif"></a><input type="hidden" name="strPartnerBZones[]" value="'+$(this).val()+'"></span>');
		}
	  });

  
}

/**
 * Eingabefelder f�r Werbung ein/ausblenden
 */
function showAdvertInput(type){
	var strShowRow = 'table-row';
	if (type == 1) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertCloseLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display',strShowRow);
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertHiddenBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display','none');
		$('#trAdvertLayerSize').css('display',strShowRow);
		$('#trAdvertOpen').css('display',strShowRow);
		$('#trMaxDeliveryPerDay').css('display',strShowRow);
		$('#trMaxDeliveryPerMonth').css('display',strShowRow);
		$('#trAdvertScrolling').css('display','none');
		$('#trAdvertButton').css('display',strShowRow);
	} else if (type == 2) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertCloseLink').css('display',strShowRow);        
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display',strShowRow);
		$('#trAdvertHiddenBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display','none');
		$('#trAdvertOpen').css('display',strShowRow);
		$('#trAdvertLayerSize').css('display','none');
		$('#trMaxDeliveryPerDay').css('display',strShowRow);
		$('#trMaxDeliveryPerMonth').css('display',strShowRow);
		$('#trAdvertScrolling').css('display','none');
		$('#trAdvertButton').css('display',strShowRow);
	} else if (type == 3) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertCloseLink').css('display',strShowRow);        
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertHiddenBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display','none');
		$('#trAdvertLayerSize').css('display',strShowRow);
		$('#trAdvertOpen').css('display','none');
		$('#trMaxDeliveryPerDay').css('display',strShowRow);
		$('#trMaxDeliveryPerMonth').css('display',strShowRow);
		$('#trAdvertScrolling').css('display',strShowRow);
		$('#trAdvertButton').css('display',strShowRow);
	} else if (type == 4) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertCloseLink').css('display',strShowRow);        
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertHiddenBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display',strShowRow);
		$('#trAdvertLayerSize').css('display',strShowRow);
		$('#trAdvertOpen').css('display',strShowRow);
		$('#trMaxDeliveryPerDay').css('display',strShowRow);
		$('#trMaxDeliveryPerMonth').css('display',strShowRow);
		$('#trAdvertScrolling').css('display',strShowRow);
		$('#trAdvertButton').css('display',strShowRow);
	} else {
		$('#trAdvertName').css('display','none');
		$('#trAdvertPartner').css('display','none');
		$('#trAdvertLink').css('display','none');
		$('#trAdvertCloseLink').css('display','none');        
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertHiddenBanner').css('display','none');
		$('#trAdvertCode').css('display','none');
		$('#trAdvertLayerSize').css('display','none');
		$('#trAdvertOpen').css('display','none');
		$('#trMaxDeliveryPerDay').css('display','none');
		$('#trMaxDeliveryPerMonth').css('display','none');
		$('#trAdvertScrolling').css('display','none');
		$('#trAdvertButton').css('display','none');
	}
}

function showPopupAdvertInput(type){
	var strShowRow = 'table-row';
	if (type == 1) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display',strShowRow);
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertHiddenBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display','none');
		$('#trAdvertPopupSize').css('display',strShowRow);
		$('#trAdvertOpen').css('display',strShowRow);
		$('#trMaxDeliveryPerDay').css('display',strShowRow);
		$('#trMaxDeliveryPerMonth').css('display',strShowRow);
		$('#trAdvertScrolling').css('display','none');
		$('#trAdvertButton').css('display',strShowRow);
	} else if (type == 2) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display',strShowRow);
		$('#trAdvertHiddenBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display','none');
		$('#trAdvertOpen').css('display',strShowRow);
		$('#trAdvertPopupSize').css('display','none');
		$('#trMaxDeliveryPerDay').css('display',strShowRow);
		$('#trMaxDeliveryPerMonth').css('display',strShowRow);
		$('#trAdvertScrolling').css('display','none');
		$('#trAdvertButton').css('display',strShowRow);
	} else if (type == 3) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertHiddenBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display','none');
		$('#trAdvertPopupSize').css('display',strShowRow);
		$('#trAdvertOpen').css('display','none');
		$('#trMaxDeliveryPerDay').css('display',strShowRow);
		$('#trMaxDeliveryPerMonth').css('display',strShowRow);
		$('#trAdvertScrolling').css('display',strShowRow);
		$('#trAdvertButton').css('display',strShowRow);
	} else if (type == 4) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertHiddenBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display',strShowRow);
		$('#trAdvertPopupSize').css('display',strShowRow);
		$('#trAdvertOpen').css('display',strShowRow);
		$('#trMaxDeliveryPerDay').css('display',strShowRow);
		$('#trMaxDeliveryPerMonth').css('display',strShowRow);
		$('#trAdvertScrolling').css('display',strShowRow);
		$('#trAdvertButton').css('display',strShowRow);
	} else {
		$('#trAdvertName').css('display','none');
		$('#trAdvertPartner').css('display','none');
		$('#trAdvertLink').css('display','none');
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertHiddenBanner').css('display','none');
		$('#trAdvertCode').css('display','none');
		$('#trAdvertPopupSize').css('display','none');
		$('#trAdvertOpen').css('display','none');
		$('#trMaxDeliveryPerDay').css('display','none');
		$('#trMaxDeliveryPerMonth').css('display','none');
		$('#trAdvertScrolling').css('display','none');
		$('#trAdvertButton').css('display','none');
	}
}


/**
 * Layerverwaltung:
 * Eingabefelder f�r Werbung ein/ausblenden  (ALT!!!!!!!!!!)
 */
function showLayerAdvertInput(type){

	var strShowRow = 'table-row';

	if (type == 1) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display',strShowRow);
		$('#trAdvertHideBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertCode').css('display','none');
		$('#trAdvertButton').css('display',strShowRow);
		$('#trAdvertMaxDelivery').css('display',strShowRow);
	} else if (type == 2) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertHideBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display',strShowRow);
		$('#trAdvertCode').css('display','none');
		$('#trAdvertButton').css('display',strShowRow);
		$('#trAdvertMaxDelivery').css('display',strShowRow);
	} else if (type == 3) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertHideBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertCode').css('display','none');
		$('#trAdvertButton').css('display',strShowRow);
		$('#trAdvertMaxDelivery').css('display',strShowRow);
	} else if (type == 4) {
		$('#trAdvertName').css('display',strShowRow);
		$('#trAdvertPartner').css('display',strShowRow);
		$('#trAdvertLink').css('display',strShowRow);
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertHideBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertCode').css('display',strShowRow);
		$('#trAdvertButton').css('display',strShowRow);
		$('#trAdvertMaxDelivery').css('display',strShowRow);
	} else {
		$('#trAdvertName').css('display','none');
		$('#trAdvertPartner').css('display','none');
		$('#trAdvertLink').css('display','none');
		$('#trAdvertBanner').css('display','none');
		$('#trAdvertHideBanner').css('display','none');
		$('#trAdvertOwnBanner').css('display','none');
		$('#trAdvertCode').css('display','none');
		$('#trAdvertButton').css('display','none');
		$('#trAdvertMaxDelivery').css('display','none');
	}
}

/**
 * Auszahlungsmethode anzeigen
 */
function showPaymentMethod(intValue) {
    if (intValue==1) {
        $('#divPaymentBank').css('display','none');
        $('#divPaymentPayPal').css('display','none');
        $('#divContingent').css('display','block');
    } else if (intValue==2) {
        $('#divPaymentBank').css('display','block');
        $('#divPaymentPayPal').css('display','none');
        $('#divContingent').css('display','none');
    } else if (intValue==3) {
        $('#divPaymentBank').css('display','none');
        $('#divPaymentPayPal').css('display','block');
        $('#divContingent').css('display','none');
    } else {
        $('#divPaymentBank').css('display','none');
        $('#divPaymentPayPal').css('display','none');
        $('#divContingent').css('display','none');
    }
}

/**
 * Details f�r Rechnungs�bersicht
 */
function openPaymentDetails(strId) {
    if ($.browser.msie) {
        if ($('#'+strId).css('display') != 'block') {
            $('#'+strId).css('display','block');
            $('#'+strId).attr('colspan','6');
        } else {
            $('#'+strId).css('display','none');
        }
    } else {
        if ($('#'+strId).css('display') != 'table-row') {
            $('#'+strId).css('display','table-row');
            $('#'+strId).attr('colspan','6');
        } else {
            $('#'+strId).css('display','none');
        }
    }
}

function downloadDTAUS($intAmount,strUrl) {    
    if (confirm('Mit dem Download des DTAUS-Format wird/werden die Zahlung(en) auf ausgezahlt gesetzt! Wirklich fortfahren?')) {
        win1 = window.open(strUrl,"Download","width=100,height=100,status=no,scrollbars=no,resizable=no");
        win1.focus();
        if ($intAmount==0) {
            window.setTimeout(function () { location.href=WEBROOT+"index.php?c=payments&"+SESSION_NAME+"="+SESSION_ID; }, 3000);
        }        
        return true;
    }
    return false;
}

function payPerPaypal(strUrl) {
    if (confirm('Mit dem Aufruf des PAYPAL-Zahlungsformulars wird die Zahlung auf ausgezahlt gesetzt! Wirklich fortfahren?')) {
        win2 = window.open(strUrl,"Download","width=800,height=600,status=no,scrollbars=no,resizable=no");
        win2.focus();
        return true;
    }
    return false;
}