﻿$jquery(document).ready(function(){
    	window.setTimeout("fadeInSite()", 1500);
    	
    	/*
    	$jquery("#flash_header").click(function () {
    		$jquery(".toOpacFade").fadeOut("slow");
    		$jquery(".toFade").slideUp(1500,loadContent);
    	});
    	function loadContent() {
    		$.post("inc/lib.contentLoader.php", { site: "home" },
			  function(data){
			    $jquery("#content").html(data);
			  });   		    		
    		window.setTimeout("fadeInSite()", 400);
    	}*/
    });
    
    function specialInit() {
    	$jquery(".togHead").css('cursor','pointer');
    	$jquery(".togHeadDown").css('cursor','pointer');
    	
    	$jquery(".togHead").click(function () {
	      $jquery(this).next('.togPar').slideToggle("slow");
	      $jquery(this).toggleClass('togHead');
	      $jquery(this).toggleClass('togHeadDown');
	    });
		$jquery(".togHeadDown").click(function () {
	      $jquery(this).next('.togPar').slideToggle("slow");
	      $jquery(this).toggleClass('togHead');
	      $jquery(this).toggleClass('togHeadDown');
	    });
    }
    
    
    
    function fadeOutAndLoad(article_id, clang) {
    	
   		$jquery(".toFade").slideUp(1500,loadIt(article_id, clang));
    }
    function soundTog(obj) {
    	alert(obj);
    }
    
    function loadIt(article_id, clang) {
    	artnr = article_id;
    	lang1 = clang;
    	window.setTimeout("changeIt()", 1500);    	
    }
    function changeIt() {
    	/*if (siteStore=='shop/index.php') {
    		window.location.href = siteStore;   
    	if (siteStore=='impressum.php') {
    		window.location.href = '/8-0-impressum.html';
    	}*/
    	 	
    	if (artnr =='0') {
    		if(lang1 ==0){
	    		window.location.href = '../shop/index.php/home?___store=default';
	    	}else if(lang1 == 1){
	    		window.location.href = '../shop/index.php?___store=english';	    	
	    	}else if(lang1 == 2){
	    		window.location.href = '../shop/index.php?___store=russisch';	    	
	    	}else if(lang1 == 3){
	    		window.location.href = '../shop/index.php?___store=jugos';	    	
	    	}
    	} else {
    		$jquery.post("index.php", { article_id: artnr, clang: lang1 ,header: '1' },
			  function(data){
			 
			    $jquery("#content").html(data);
			  });   		    		
	    		window.setTimeout("fadeInSite()", 400);
	   			if (artnr=='6') {
	    			window.setTimeout("loadGmap()", 1500);
	    		}	
    		
    	}
    	
    	
	    	//window.location.href = siteStore;
    }
    function loadGmap() {
    			var map = new GMap2(document.getElementById("map"));
				map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
				//<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.de/maps?f=q&amp;source=s_q&amp;hl=de&amp;geocode=&amp;q=Geislinger+Strasse+99,+Balingen&amp;sll=51.151786,10.415039&amp;sspn=22.865142,38.847656&amp;ie=UTF8&amp;ll=48.290103,8.846226&amp;spn=0.011809,0.018969&amp;t=h&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe><br /><small><a href="http://maps.google.de/maps?f=q&amp;source=embed&amp;hl=de&amp;geocode=&amp;q=Geislinger+Strasse+99,+Balingen&amp;sll=51.151786,10.415039&amp;sspn=22.865142,38.847656&amp;ie=UTF8&amp;ll=48.290103,8.846226&amp;spn=0.011809,0.018969&amp;t=h&amp;z=14&amp;iwloc=addr" style="color:#0000FF;text-align:left">Größere Kartenansicht</a></small>
				map.setCenter(new GLatLng(48.286273495503366, 8.72464656829834), 15, G_HYBRID_MAP);
				var bounds = new GLatLngBounds;
				/*                    var icon = new GIcon();
									icon.image = "../Marker_RC.png";
									icon.iconSize = new GSize(81, 40);
				                                        icon.shadow = "../Marker_RC_s.png";
									icon.shadowSize = new GSize(81, 40);
				
									icon.iconAnchor = new GPoint(0, 40);
									icon.infoWindowAnchor = new GPoint(5, 1);*/
									var point = new GPoint(8.72464656829834,48.286273495503366);
				                                        var html = "<p>Peter Horvat</p>";
				                                        var beck = new GMarker(point);
				                                        GEvent.addListener(beck, "click", function() {beck.openInfoWindowHtml(html)})
				                                        map.addOverlay(beck);
    	
    }
    
    function fadeInSite() {
    	$jquery(".toFade").slideDown(1500);
    	window.setTimeout("fadeOpacElements()", 1000);
    	
    }
    function fadeOpacElements() {
    	$jquery(".toOpacFade").fadeIn("slow");
    	specialInit();
    }
    /**
    		Ideen:	- HashLoader um unterseiten direkt Über seite.html#id aufzurufen (Angemerkt)
    				- Boxen umbauen, nicht nur auf links!! (RL)
    				- NoScript-Seite!!!! NoFlash auch! IPhone is das Stichwort! (50% done)
    				- scrollbar immer sichtbar (done)
    **/
    
    function checkInput(defValue,isValue) {
    	if (isValue=='') {
    		return defValue;	
    	} else {
    		return isValue;
    	}
    
    }
    
    function phmout(specialCase,lang) {
      	//Gets the test.php page contents which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>)
		$jquery.post("inc.mail.php", { 
				n: $jquery('#myname').val(),
				nd: $jquery('#myname').attr('title'),
				t: $jquery('#telefon').val(),
				td: $jquery('#telefon').attr('title'), 
				m: $jquery('#nachricht').val(),
				md: $jquery('#nachricht').attr('title'),
 				em: $jquery('#mail').val(),
				emd: $jquery('#mail').attr('title'),
				
				specialCase: specialCase,
				lang: lang,
				street: $jquery('#mystreet').val(),
				streetd: $jquery('#mystreet').attr('title'),
				city: $jquery('#mycity').val(),
				cityd: $jquery('#mycity').attr('title'),
				country: $jquery('#mycountry').val(),
				countryd: $jquery('#mycountry').attr('title')
				
			},
			function(data){
		    	if (data.error) {
				//	alert(data.error);
					$jquery('#mailContainerMessage').hide();
					$jquery('#mailContainerMessage').html(data.error);
					$jquery('#mailContainerMessage').slideDown('slow',
						function callbackHide () {
							window.setTimeout("$jquery('#mailContainerMessage').slideUp('slow')",10000);
						}
					);
		    	} else {
		    		$jquery('#mailContainerMessage').hide();
		    		$jquery('#mailContainer').remove();
					$jquery('#mailContainerMessage').html(data.msg);
					$jquery('#mailContainerMessage').slideDown('slow');		    		
		    	}
		   		
		  }, "json");
		  return false;


    	
    }
    
    
    
    
    
    
    
    
    
    
    
    
