﻿
    function jsInclude(url)
    {
      document.write('<scr' + 'ipt type="text/javascript" src="' + url + '"></scr' + 'ipt>');
    }
    function cssInclude(url)
    {
      document.write('<link href="' + url + '" type="text/css" rel="stylesheet"></link>');
    }

	// skrypty strony
    
    
	// skrypty modułów
    $(document).ready(function() {
    $("#bSzukajWWW").click(function() {
        if ($("#txtSzukajWWW").val()!=null)
        {
                document.location="http://www.euroglas.com.pl/32,Wyszukiwarka.aspx?Szukaj="+$("#txtSzukajWWW").val();
        }
    });

    $("#txtSzukajWWW").focus(function() {
        $("#txtSzukajWWW").val("");
    });

});

jsInclude('http://www.euroglas.com.pl/css/js/menu/hoverIntent.js'); 
jsInclude('http://www.euroglas.com.pl/css/js/menu/superfish.js'); 
     
    $(document).ready(function() { 
        $('#menu').superfish({ 
            delay:       30000,                            // one second delay on mouseout 
            speed:       'fast',                          // faster animation speed 
            dropShadows: false,                            // disable drop shadows 
            pathClass:  'currentX' 			
        }); 
    }); 
		
            

            function doPokazHover(id)
            {	
                if (document.getElementById(id)!=null)
                {
	                $("#"+id).css('background-color', '#820089');
    	            $("#"+id+" ul").css('visibility', 'visible');
        	        $("#"+id+" ul").css('display', 'block');
                }
            }

$(document).ready(function() {
 $("#podmenu"+$("#Current").html()).css('font-weight', 'bold');
});
jsInclude('http://maps.google.com/maps?file=api&v=2&key=ABQIAAAACjNJ7PwiL77bnkxBW4OVyxQKeMv1GIkWtAAcHrLbi4OeV5YCxBSHFrZIYJ7Jpd02sPJQk25_q87FvA'); 

var map;
var gdir;
 
function initialize() {
  if (GBrowserIsCompatible()) {      
    map = new GMap2(document.getElementById("map_canvas"));
    gdir = new GDirections(map, document.getElementById("directions"));
    GEvent.addListener(gdir, "error", handleErrors);
    GEvent.addListener(gdir, "addoverlay", onGDirectionsAddOverlay); // Triggers marker swap, Esa
    map.setCenter(new GLatLng(0,0),0);	// inital setCenter()  added by Esa.
    //setDirections("Kraków", "Kraków, ul. Lokietka 141", "pl_PL");
    // api version display added by Esa
  }
}
 
function setDirections() {
//alert( $("#toAddress option:selected").text());
var toAddres = $("#toAddress option:selected").text();
var fromAddres = $("#fromAddress").val();
var locale = 'pl';

  gdir.load("from: " + fromAddres + " to: " + toAddres,
  { "locale": locale , "getSteps":true});
}
 
function handleErrors(){
  if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
    alert("Nie znaleziono wprowadzonego adresu.\nError code: " + gdir.getStatus().code);
  else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
    alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
  else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
    alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
  else if (gdir.getStatus().code == G_GEO_BAD_KEY)
    alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
  else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
    alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
  else alert("An unknown error occurred.");
}
  
///////////////////////////////////////////////////////////////////////
 
/**
* The add-on code for draggable markers
* @author Esa 2008
*/
var newMarkers = [];
var latLngs = [];
var icons = [];
 
// Note the 'addoverlay' GEvent listener inside initialize() function of the original code (above).
// 'load' event cannot be used
 
function onGDirectionsAddOverlay(){ 
  // Remove the draggable markers from previous function call.
  for (var i=0; i<newMarkers.length; i++){
    map.removeOverlay(newMarkers[i]);
  }
 
  // Loop through the markers and create draggable copies
  for (var i=0; i<=gdir.getNumRoutes(); i++){
    var originalMarker = gdir.getMarker(i);
    latLngs[i] = originalMarker.getLatLng();
    icons[i] = originalMarker.getIcon();
    newMarkers[i] = new GMarker(latLngs[i],{icon:icons[i], draggable:true, title:'Draggable'});
    map.addOverlay(newMarkers[i]);
 
    // Get the new waypoints from the newMarkers array and call loadFromWaypoints by dragend
    GEvent.addListener(newMarkers[i], "dragend", function(){
      var points = [];
      for (var i=0; i<newMarkers.length; i++){
        points[i]= newMarkers[i].getLatLng();
      }
      gdir.loadFromWaypoints(points);
    });
 
    //Bind 'click' event to original markers 'click' event
    copyClick(newMarkers[i],originalMarker);
 
    // Now we can remove the original marker safely
    map.removeOverlay(originalMarker);
  }
 
  function copyClick(newMarker,oldMarker){
    GEvent.addListener(newMarker, 'click', function(){
      GEvent.trigger(oldMarker,'click');
    });
  }
}

$(document).ready(function() {
   initialize();
});

$(document).unload(function() { GUnload(); });

function clearDefault(el) {  
if (el.defaultValue==el.value) el.value = ""
}     $(document).ready(function() {
	$("#WybierzModele").css('opacity', 0.5);
	$("#WybierzModele").attr('disabled', 'disabled');
    
	$("#WybierzTyp").css('opacity', 0.5);    
	$("#WybierzTyp").attr('disabled', 'disabled');

	$("#WybierzSzukaj").css('opacity', 0.5);    
	$("#WybierzSzukaj").attr('disabled', 'disabled');
    
    $("#WybierzMarke").change(function() {
		WezModele("0");
    });
    
    $("#WybierzModele").change(function() {
		WezTypy("0");
    });      
    
    
    $("#WybierzTyp").change(function() {
        $("#WybierzSzukaj").css('opacity', 1);                 
        $('#WybierzSzukaj').removeAttr('disabled');		
    });      
          
    $("#WybierzSzukaj").click(function() {
    	if ($("#WybierzTyp").val()=='wybierz typ') {
        	alert("Proszę wybrać typ szyby");
            return false;            
        }
        
    	if ($("#WybierzModele").val()=='wybierz model') {
        	alert("Proszę wybrać typ szyby");
            return false;            
        }
        
    	if ($("#WybierzMarke").val()=='wybierz markę') {
        	alert("Proszę wybrać typ szyby");
            return false;
        }                

       var pTS = _gat._getTracker('UA-9183397-11');
       pTS._trackPageview("/?Marka="+$("#WybierzMarke").val()+"&Model="+$("#WybierzModele").val()+"&Typ="+$("#WybierzTyp").val());
        
        document.location = "/"+$("#WybierzMarke").val()+"/"+$("#WybierzModele").val()+"/"+$("#WybierzTyp").val()+",27.aspx";
    });   
        
});

function WezModele(sPrzelacznik) {
        var sUrlMarka = "/eEuroglas/xml/" + $("option:selected", $("#WybierzMarke")).val().toLowerCase() + ".xml";
        $.ajax({
            url: sUrlMarka,
            type: 'GET',
            dataType: 'xml',
            timeout: 5000,
            error: function(){
                alert('Blad ladowania pliku XML, ' + sUrlMarka);
            },
            success: function(xml){
                $('#WybierzModele').find('option').remove().end();                    
                $('#WybierzModele').append("<option>wybierz model</option>");                                                       
                $(xml).find('Model').each(function(){
                    var item_text = $(this).text();
					$('#WybierzModele').append("<option value=" + item_text + ">" + item_text + "</option>");                                   
                });   
				$("#WybierzModele").css('opacity', 1);                 
		        $('#WybierzModele').removeAttr('disabled');
                
                if (sPrzelacznik=="1")
                {
                	if ($("#spModel").html()!=null) {
		                $("#WybierzModele").val($("#spModel").html());
    	                WezTypy("1");
                    }
                }      
            }        
        });
}

function WezTypy(sPrzelacznik) {
    	var sUrlTyp = "/eEuroglas/xml/" + $("option:selected", $("#WybierzMarke")).val() + $("option:selected", $("#WybierzModele")).val().toLowerCase()+ "Typ.xml";     
        $.ajax({
            url: sUrlTyp,
            type: 'GET',
            dataType: 'xml',
            timeout: 5000,
            error: function(){
                alert('Blad ladowania pliku XML, ' + sUrlTyp);
            },
            success: function(xml){
                $('#WybierzTyp').find('option').remove().end();                    
                $('#WybierzTyp').append("<option>wybierz typ</option>");                                                       
                $(xml).find('Typ').each(function(){
                    var item_text = $(this).text();
                    if (item_text=='szyba-czołowa') 
                    {
						$('#WybierzTyp').append("<option value='szyba-czołowa'>Szyba-czołowa</option>");                                   
                    }
                    if (item_text=='szyba-boczna') 
                    {
						$('#WybierzTyp').append("<option value='szyba-boczna'>Szyba-boczna</option>");                                   
                    }
                    if (item_text=='szyba-tylna') 
                    {
						$('#WybierzTyp').append("<option value='szyba-tylna'>Szyba-tylna</option>");                                   
                    }                                        

                });   
				$("#WybierzTyp").css('opacity', 1);                 
		        $('#WybierzTyp').removeAttr('disabled');
                
                if (sPrzelacznik=="1")
                {
                	if ($("#spTyp").html()!=null) {
		                $("#WybierzTyp").val($("#spTyp").html());
                    }
                }                 
            }        
        });
}