// JavaScript Document
var printWin = null;
window.onresize = doResize;


function doResize() {
	
	var viewportwidth;
	//var viewportheight;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined') {
		//viewportwidth = window.innerWidth,
		//viewportheight = window.innerHeight
		viewportwidth = window.innerWidth	
	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		//viewportwidth = document.documentElement.clientWidth,
		//viewportheight = document.documentElement.clientHeight
		viewportwidth = document.documentElement.clientWidth
	}
	// older versions of IE
	else {
		//viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		//viewportheight = document.getElementsByTagName('body')[0].clientHeight
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth
	}
	//alert(viewportwidth);
	
	var scrollX = "hidden;";
	if (viewportwidth < 1000){
		scrollX = "auto";
	} else {
		scrollX = "hidden";
	}
	var d = document;
	var dsS = d.styleSheets;
	if (dsS[0].insertRule) dsS[0].insertRule("html { overflow-x: " + scrollX +" }", dsS[0].cssRules.length); // W3C DOM2 Style
	else if (dsS[0].addRule) dsS[0].addRule("html", "overflow-x: " + scrollX ); // Microsoft
}


function MenuOverSetzen(){
	var m = "menu" + jsBereich + jsMenuID;
	/*if(typeof(jsMenuID2) !== undefined) {
		if(jsBereich != jsBereichOrig){
			var m = "menu" + jsBereich + jsMenuID2;
		}else{
			var m = "menu" + jsBereichOrig + jsMenuID;
		}	
	}*/
	//alert(m);
	//Überprüfen, ob MenuPunkt auf der Seite existiert
	if (document.getElementById(m) != null){
		//welches Bild ist aktuell
		var el = document.images[m];
		var b = el.src;
		
		var b2 = b.substring(0,b.length - 5) + "2.jpg";
		//Überprüfen, ob neues Bild existiert??? ->nö
		//Bild austauschen
		MM_swapImage(m,'',b2,0)
		//Link deaktivieren
		el.onmouseover = el.onmouseout = null;
		el.parentNode.style.cursor = 'default';
		el.parentNode.href = 'javascript:void(0)';
	}
}


$(document).ready(function() {
	
	doResize(); //Scroll Balken Fenster aktualisieren
	
	//MenuOver Bildaustausch
	if (jsMenuID != 0){
		MenuOverSetzen();
	}

	//Titel und diverse Texte setzen
	switch (jsLan) {
		case "de": 
		bildTitel = "Bild";
		PrintTitel = "Seite drucken";
		break;
		
		case "se":
		bildTitel = "Bild";
		PrintTitel = "Skriv ut";
		break;
		
		default:
		bildTitel = "Image";
		PrintTitel = "Print page";
		break;	
	}
	
	//alert(Lan);
	$("a.FancyBoxLink").fancybox({
		'autoScale'			: true,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'easingIn'     		: 'easeOutBack',
		'easingOut'     	: 'easeInBack',
		'speedIn'			: 600,
		'speedOut'			: 300,
		'overlayOpacity'  	: 0.6,
		'overlayColor'  	: '#000',
		'titleShow'     	: true,
		'titlePosition' 	: 'over',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return '<span id="fancybox-title-over">'+ bildTitel + '&nbsp;'+ (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	

	$('a[href=#top]').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
	
	
	$("a.printIt").click(function(){
	
	if (!printWin || printWin.closed) {
		printWin =  window.open('','PrintFenster','menubar=1,resizable=1,status=1,toolbar=1,location=1,scrollbars=1,width=800,height=600');
	} else {
		printWin.focus();
	}
	/*<script type=\"text/javascript"\>function ReplaceIt(){alert(\"hallo\");}</script>*/
	
	
	//var html = '<html><head><title>' + PrintTitel + ' - ' + jsUe +'</title></head><body><div id="printDIV">' + $('<div />').append($('#contentDIV').clone()).html() + '</div></body></html>';
	var html = '<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>' + PrintTitel + ' - ' + jsUe +'</title><link href=\"../css/print.css\" rel=\"stylesheet\" type=\"text/css\" /><script type=\"text/javascript\" src=\"../js/jquery-1.4.2.min.js\"></script><script type=\"text/javascript\" src=\"../js/print.js\"></script></head>';	
	html = html + '<body><div id=\"printDIV\">';
	html = html + '<img src=\"../images/images_screen/print_logo_200.jpg\" alt=\"logo\" name=\"logo\" width=\"200\" height=\"56\" id=\"logo\" /><h1>' + jsUe +'</h1>';
	html = html + ' <p>&nbsp;</p><div>' + $('<div />').append($('#contentDIV').clone()).html() + '</div>';
	html = html + '</div></body></html>';
	html = html + '<table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\" id=\"footer\"><tr><th class=\"TDLinie\" scope=\"col\">Fam. Johansson Jones<br />villa &amp; chalet augustine<br />Hasenbachweg 174<br />5754 Saalbach Hinterglemm<br />Salzburgerland<br />Austria</th><th class=\"TDLinie\" scope=\"col\">Phone: 0043 (0)6541 20027<br /><img src=\"../images/images_screen/img_tel_pr.jpg\" width=\"9\" height=\"16\" />0043 (0)664 644 6359<br /><img src=\"../images/images_screen/img_print_pr.jpg\" width=\"22\" height=\"16\" />info@chaletaugustine.com<br /><img src=\"../images/images_screen/img_web_pr.jpg\" width=\"15\" height=\"16\" />www.chaletaugustine.com<br /><br />UID: ATU62014288</th><th scope=\"col\">Bank institut:<br />Raiffeisenkasse Hinterglemm<br />BANKCODE 35.052 / ACCOUNT-No. 056309<br /><br />SWIFT/BIC CODE: RVSA AT 2S 052<br />IBAN AT 81 3505 2000 0005 6309</th></tr></table>'; 	

	printWin.document.open();
	printWin.document.write(html);
	printWin.document.close();
	return false; 
	});
});


//FancyBox von Flash
function showFancyBox(BildLink) {
	//alert(BildLink);
	$(document).ready(function() {
		$("a.FancyBoxFlashLink").fancybox({
		'autoScale'			: true,
		
		'speedIn'			: 600,
		'speedOut'			: 300,
		'overlayOpacity'  	: 0.6,
		'overlayColor'  	: '#000',
		'titleShow'     	: false,
		'href'				: BildLink
		});
	});
	
	// trigger click
	$('#inlineFlashLink').trigger('click');
}


/*function email(name, domain, suffix, text){
	if (name != ""){
		 var address = name + "\u0040" + domain + "." + suffix;
  	 var url = "mailto:" + address;
  	 if( ! text ){
      	text = address;
   	}
	document.write("<a href=\"" + url + "\">" + text + "</a>");
	}
}*/


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
