function getattrinfo(attrval) {
  if (attrval.indexOf('-') > -1) {
	  attrval = attrval.substr(attrval.indexOf('-')+1);
		if (attrval.indexOf('-') > -1) {
			return attrval.split('-');
		}
	}
	return attrval;
}

function getanchor(href) {
  if (href.indexOf('#') > -1) {
	  href = href.substr(href.indexOf('#')+1);
	}
	return href;
}

String.prototype.asInt = function() {
  return parseInt(this) ? parseInt(this) : 0;
}
function asInt(s) {
  return parseInt(s) ? parseInt(s) : 0;
}

$(document).ready(function() {
   var site = String(document.location)
       .replace(/^(https?:\/\/[^:\/]+).*$/, "$1")
       .replace(/^((site)?(file:\/\/.+\/))[^\/]+$/, "$3")
       .replace(/(\\.)/g, "\\$1");
   $("a", this).filter(function (i) {
     if ($(this).attr('rel')=='external') 
			 return false;
     var href = $(this).attr("href");
     if (href == null)
       return false;
     return (href.match(RegExp("^("+site+"|(https?:)?/[^/])")) == null && 
					 href.match(RegExp("^(https?|ftp)://.+")) != null);
   }).each(function () {
     if($(this).attr('class')!='iframe') {
     $(this).click(function() {
		   //window.open('/externalurl.php?source='+escape(document.location)+'&destination='+escape($(this).attr('href')));
       window.open($(this).attr('href'));
	     return false;
  	 });
     }
   });													 
   if ($('a[rel="external"]').length) {
		 $('a[rel="external"]').click(function() {
		 	 window.open($(this).attr('href'));
			 return false;
		 });
	 }
	 if ($('form.external').length) {
	   $('form.external').attr('target', '_blank');
	 }
	 if ($('a.zoom').length) {
	 if ($('a.zoom').length) {
		 switch(language) {
			 case 'it':
			  $('a.zoom').lightbox(
				 {strings : {
						help: ' \u2190 / P - n&auml;chstes Bild\u00a0\u00a0\u00a0\u00a0\u2192 / N -vorheriges Bild\u00a0\u00a0\u00a0\u00a0ESC / X - Bildergalerie schlie&szlig;en',
						prevLinkTitle: 'Immagine precedente',
						nextLinkTitle: 'Immagine successiva',
						prevLinkText:  '&laquo; indietro',
						nextLinkText:  'avanti &raquo;',
						closeTitle: 'Chiudi galleria d\'immagini',
						closeHint: 'Cliccare per chiudere.',
						image: 'Immagine ',
						of: ' di '
					}}									
				);
			 break;
			 case 'en':
			  $('a.zoom').lightbox(
				 {strings : {
						help: ' \u2190 / P - next picture\u00a0\u00a0\u00a0\u00a0\u2192 / N -n&auml;chstes Bild\u00a0\u00a0\u00a0\u00a0ESC / X - Bildergalerie schlie&szlig;en',
						prevLinkTitle: 'previous picture',
						nextLinkTitle: 'next picture',
						prevLinkText:  '&laquo; back',
						nextLinkText:  'next &raquo;',
						closeTitle: 'close gallery',
						closeHint: 'click to close.',
						image: 'picture ',
						of: ' of '
					}}									
				);
			 break;
			 default:
			   $('a.zoom').lightbox();
			 break;
		 }
	 }
	 }
     var cboxopts = {
    transition:"fade",
    previous: "<p>&laquo</p>",
    current: "<p>{current} / {total}</p>",
    next: "<p>&raquo;</p>",
    close: "<p>x</p>"
  };

   $('div#footer').after('<div id="familotel-banner"><a target="_blank" href="http://www.familotel.de/"><span>Familotel</span></a></div>');
   $('a.iframe').click(function() {
     var size = $(this).attr('rel');
     if (!size) size = '640x480';
     size = size.split('x');
    $.colorbox($.extend({}, cboxopts, {
      width:size[0],
      height:size[1],
      iframe:true,
      href:$(this).attr('href'),
      close: "x",
      title:$(this).attr('title')
    }));
    return false;
   });
});
