$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	$("a[rel='example1']").colorbox();
	$("a[rel='example2']").colorbox({transition:"fade"});
	$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
	$("a[rel='example4']").colorbox({slideshow:true});
	$(".single").colorbox({}, function(){
		alert('Howdy, this is an example callback.');
	});
	$(".colorbox").colorbox();
	$(".youtube").colorbox({iframe:true, width:650, height:550});
	$(".iframe").colorbox({width:"80%", height:"80%", iframe:true});
	$(".iframe_close").colorbox.close();
	
	$(".inline").colorbox({width:"50%", inline:true, href:"#errormsg"});
	// changed css styles for escalado
	$(".artphoto_resized").colorbox({width:"80%", height:"615px", iframe:true});
	// events for escalado alert box replacement
	$(".errmsg_falsemail").colorbox({width:"50%", inline:true, href:"#msg_falsemail"});
	$(".errmsg_falsereceipient").colorbox({width:"50%", inline:true, href:"#msg_falsereceipient"});
	$(".errmsg_falsesender").colorbox({width:"50%", inline:true, href:"#msg_falsesender"});
	$(".errmsg_deliveryaddress").colorbox({width:"50%", inline:true, href:"#msg_deliveryaddress"});
	$(".errmsg_emptyfields").colorbox({width:"50%", inline:true, href:"#msg_emptyfields"});
	$(".errmsg_changemail").colorbox({width:"50%", height:"50%", inline:true, href:"#msg_changemail"});
	$(".errmsg_noantispam").colorbox({width:"50%", inline:true, href:"#msg_noantispam"});
	$(".errmsg_terms").colorbox({width:"50%", inline:true, href:"#msg_terms"});
	$(".errmsg_passesnotmatch").colorbox({width:"50%", inline:true, href:"#msg_passesnotmatch"});
	$(".errmsg_passlesssecure").colorbox({width:"50%", inline:true, href:"#msg_passlesssecure"});
	// small inner frames (recommendation, questons)
	$(".window_recommend").colorbox({width:"550px", height:"525px", iframe:true});
	$(".window_artrequest").colorbox({width:"550px", height:"525px", iframe:true});
	
	//Example of preserving a JavaScript event for inline calls.
	$("#click").click(function(){ 
		$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		return false;
	});
});

function mail_validate(str) 
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = str;
   if(reg.test(address) == false) return false;
   return true;
}

 function ShowMessage( idname )
 {	elementname = "onclick_" + idname;
	document.getElementById( elementname ).click();
	return false;
 }

 function ShowWindow( idname )
 {	elementname = "onclick_" + idname;
	document.getElementById( elementname ).click();
	return false;
 }

 function formatZahl(zahl, k, fix) 
{
	if(!k) k = 0;
	var neu = '';
	var dec_point = ',';
	var thousands_sep = '.';

	// Runden
	var f = Math.pow(10, k);
	zahl = '' + parseInt(zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ;

	// Komma ermittlen und fehlende Nullen einfügen
	var idx = zahl.indexOf('.');
	if(fix)    
	{	zahl += (idx == -1 ? '.' : '' )
		 + f.toString().substring(1);
	}

	var sign = (zahl < 0);
	if(sign) zahl = zahl.substring(1);
	idx = zahl.indexOf('.');

	// Nachkommastellen ermittlen
	if( idx == -1) idx = zahl.length;
	else neu = dec_point + zahl.substr(idx + 1, k);

	while(idx > 0)    
	{	if(idx - 3 > 0)
			neu = thousands_sep + zahl.substring( idx - 3, idx) + neu;
		else
			neu = zahl.substring(0, idx) + neu;

		idx -= 3;
	}

	return (sign ? '-' : '') + neu;
}				

