//Funktionen die funktionieren und benötigt werden

//@description: Emailstrings zu richtigen Email URIs umwandeln
//@params: a href from rel="email"
jQuery(document).ready(function(){
    jQuery("a[rel=email]").each(function(){
        // Modify the mailto: value
        var mailtoVal = jQuery(this).attr('href');
        mailtoVal = mailtoVal.replace(/\[email\]/g,"mailto:");
        mailtoVal = mailtoVal.replace(/\[at\]/g,"@");
        mailtoVal = mailtoVal.replace(/\[dot\]/g,".");
        // Auto-generate title tags for users
        var mailtoTitle = mailtoVal.replace("mailto:","Email: ");
        jQuery(this).attr('title',mailtoTitle);
        // onClick Event
        jQuery(this).click(function(){
            window.location.href = mailtoVal;
            return false;
        });
    });
});

//@description: Newsletter PopUp
function loadNewsletterForm()
{
	$('facebox-message').innerHTML='<div id="loading-carousel" class="loading"><div class="loading-image"></div></div>';
	$('facebox-header').innerHTML = 'Ruhrportal Newsletter';
	// select the overlay element - and "make it an overlay"
	jQuery("#facebox").overlay({
	// custom top position
	top: 70,
	// some expose tweaks suitable for facebox-looking dialogs
	expose: {
		// you might also consider a "transparent" color for the mask
		color: '#000',
		// load mask a little faster
		loadSpeed: 1000,
		// highly transparent
		opacity: 0.5
	},
	// disable this for modal dialog-type of overlays
	closeOnClick: false,
	// we want to use the programming API
	api: true
	// load it immediately after the construction
	}).load();
	new Ajax.Updater('facebox-message', '/owncode/ajax/newsletter', {asynchronous:true, evalScripts:true });; return false;
}

// Funktionen von Musterhaus
// @todo: gucken was hiervon noch benötigt wird
function loading()
{
	var elem = $('loading');
	elem.style.display = 'block';
	var news_elem = jQuery("#news_items").fadeTo("medium", 0.5);
}

function completed()
{
	var elem = $('loading');
	elem.style.display = 'none';
	var news_elem = jQuery("#news_items").fadeTo("fast", 1);
}

function makeError(message)
{
	if(message){
		$('facebox-message').innerHTML = message;
	}
	// select the overlay element - and "make it an overlay"
	jQuery("#facebox").overlay({
		// custom top position
		top: 272,
		// some expose tweaks suitable for facebox-looking dialogs
		expose: {
			// you might also consider a "transparent" color for the mask
			color: '#000',
			// load mask a little faster
			loadSpeed: 200,
			// highly transparent
			opacity: 0.5
		},
		// disable this for modal dialog-type of overlays
		closeOnClick: false,
		// we want to use the programming API
		api: true
	// load it immediately after the construction
	}).load();
}

function sendNewsletterForm(){
	var commentForm = new VarienForm('newsletter-validate-detail');
	commentForm.submit();
}

function loadVideo(product_id,video_title)
{
	$('facebox-message').innerHTML='<div id="loading-carousel" class="loading"><img src="/sk/gfx/loading.gif" alt="loading"/></div>';
	$('facebox-header').innerHTML = video_title;
	// select the overlay element - and "make it an overlay"
	jQuery("#facebox").overlay({

	// custom top position
	top: 70,

	// some expose tweaks suitable for facebox-looking dialogs
	expose: {

		// you might also consider a "transparent" color for the mask
		color: '#000',

		// load mask a little faster
		loadSpeed: 1000,

		// highly transparent
		opacity: 0.5
	},

	// disable this for modal dialog-type of overlays
	closeOnClick: false,

	// we want to use the programming API
	api: true

	// load it immediately after the construction
	}).load();

	new Ajax.Updater('facebox-message', '/owncode/ajax/video?id='+product_id, {asynchronous:true, evalScripts:true });; return false;
}

//text einblenden / ausblenden
function einblenden(div) {
	with(document.getElementById(div).style){
		if(display=="none"){
			display="inline";
			document.getElementById('ebene2').style.display = "none";
		}
		else{
			display="none";
			document.getElementById('ebene2').style.display = "inline";
		}
	}
}
