﻿
/* Tab switcher
-------------------------------------------------------------- */
function lomSwitchTab(element,root){
     selected = 0;
     if (element.className !== 'active'){
          /* vyber vsetkych elementov vramci taboveho elementu (mozu tam byt kludne aj nejake delimitre a pod...) */
          temp = element.parentNode.childNodes;
          itemList = new Array();
          j = -1;
          /* vyselektovanie tabovych poloziek a ich zresetovanie na neaktivne */
          for (i = 0; i < temp.length; i++){
               if(temp[i].className == 'active'){
                    temp[i].className = 'inactive'
                    j++;
                    itemList[j] = temp[i];
               }
               else if (temp[i].className == 'inactive'){
                    j++;
                    itemList[j] = temp[i];
                    if (temp[i] == element){
                         selected = j;
                    }
               }
          }
          /* zmena vybranej polozky na aktivnu */
          element.className = 'active';
          /* vyber vsetkych elementov vramci hlavneho taboveho kontajnera */
          temp = document.getElementById(root).getElementsByTagName('*');
          contentList = new Array();
          j = -1;
          /* vyselektovanie len contentovych kontajnerov */
          for(i = 0; i < temp.length; i++){
               if (temp[i].className == 'tabbed-content'){
                    j++;
                    contentList[j] = temp[i];
               }
          }
          /* zresetovanie contentovych kontajnerov na nezobrazujuce sa */
          for(i = 0; i < contentList.length; i++){
               contentList[i].style.display = 'none';
          }
          /* zobrazenie contentoveho kontajnera prinaleziaceho k zvolenemu tabu */
          contentList[selected].style.display = 'block';
     }
}
$(document).ready(function(){
     // Change the image of hoverable images
   	$("#print-button").click(function(){
		var printUrl = window.location.pathname + (window.location.search.length ? window.location.search + "&" : "?") + "p=true";
		window.open(printUrl, 'win', 'location=1,status=1,scrollbars=1,width=980,height=700');
		return false;
	});
	
	$("input[name=q], #SearchForm").focus(function(){
        if($(this).attr("value") == $(this).attr("title")){
            $(this).attr("value","");
        }
	  });
	
	$("input[name=q], #SearchForm").blur(function(){
	     if($(this).attr("value") == ""){
	       $(this).attr("value",$(this).attr("title"));
	     }
	});
		
	$("#SearchForm").submit(function(){
		if($('#search_id').val().length < 3 || $('#search_id').val() == $('#search_id').attr("title")){
			return false;
		} 
	});

 
 	$("#email_id, #newsletter-form").focus(function(){
        if($(this).attr("value") == $(this).attr("title")){
            $(this).attr("value","");
        }
    });

    $("#email_id, #newsletter-form").blur(function(){
        if($(this).attr("value") == ""){
            $(this).attr("value",$(this).attr("title"));
        }
    });

	$("#newsletter-form").submit(function(){
		$("#newsletter-ajax-loader").html("<img src=\"/images/newsletter-ajax-loader.gif\" />");
		var data = {};
		data['email'] = $("input[name=email]", this).val();
		$.post("/tool/mailing-subscribe", data,
			function(result){
				$("#newsletter-ajax-loader").html('');
				$("#newsletter-result").html(result);
				$("#email_id").val("")
			}, 
			"html"
		);
		return false;
	});
	
	$(".send-link-button").click(function(){

		var dialog = $("#send-link-dialog");
		dialog.load("/tool/send-link-form");
		dialog.dialog({
			bgiframe: true,
			autoOpen: false,
			modal: true,
			width: 508,
			minHeight: 150,
			draggable: false
		});
		dialog.dialog("open");
		return false;

	});
	
		$("#personage-video").click(function(){

		var dialog = $("#video-show");
		dialog.load("/personage/video");
		dialog.dialog({
			bgiframe: true,
			autoOpen: false,
			modal: true,
			width: 580,
			minHeight: 315,
			draggable: false
		});
		dialog.dialog("open");
		return false;

	});
 
});

$(document).ready(function(){
			     
            $(".val").dgStyle(elmHeight = "33");
            $(".dev").dgStyle(elmHeight = "33");
            $(".sell").dgStyle(elmHeight = "33");
            $(".buy").dgStyle(elmHeight = "33");
			      
			       
		 $( "#tabs" ).tabs({
			ajaxOptions: {
				error: function( xhr, status, index, anchor ) {
					$( anchor.hash ).html(
          );
				}
			}
		});

			
		  });
		  
		  
/* SPIN BOX ***/
	var myOptions = {
					min: 0,						// Set lower limit.
					max: 100,					// Set upper limit.
					step: 1					// Set increment size.
					}
 
	$(document).ready(function(){

		// Initialise INPUT element(s) as SpinButtons: (passing options if desired)
		$("#children_id").SpinButton(myOptions);
		
		
		})
		
		$(document).ready(function(){
		  $('.curr-inside select').selectmenu({style:'dropdown'});
		});
		
	
    
    	
