var subdomains = "";
$(window).load(function(){			   
//external link to new window			   
$('body a').filter(function() { 
    return this.hostname && this.hostname !== location.hostname; 
  }).addClass('external')
  .click(function() { 
    window.open(this.href); 
    return false; 
  });
 });
 
$(document).ready(function(){

//vybrana reference
$('a.image-listing_1').live('click', function(){ 
   var idrRef = $(this).text();
   $("a.image-listing_1").each(function() {
      $(this).removeClass('active-list');
   })
   $(this).addClass('active-list');
   $("a.refthb").each(function() {
      $(this).removeClass('active');
   });
   
   $('#refImg'+idrRef).addClass('active');
});
		
$('.hide').click(function() {  
    $(this).parent().next('p').toggle('slow');
	});	

$('#footer form #input').click(function(){
    if ($(this).val()=='your e-mail @'){
      $(this).val('@'); 
    }
});

$('#contact .definput').live('click', function(){ 
      $(this).val('');
      $(this).attr('class',''); 

});

$('#contact .mail').live('click', function(){ 
      $(this).val('@');
      $(this).attr('class',''); 

}); $('a.refthb').lightBox();
//$('.galery-list a').lightBox();
$('a.refthb').live('click', function(){
     $('a.refthb').lightBox();
	//CB_Gallery('http://www.piis.cz/files/cache/40.jpg'); 
	 //CB_Open('href=http://www.piis.cz/files/cache/40.jpg');  
      //return false;
     //CB_Open();
});   
 $('#sendQ').click(function(e) {  
     $("form#contact").submit();
     e.preventDefault();
	});
$('.newsletter').live('click', function(){  
        if($('#terms').attr('checked') == false){
        alert("Prosíme potvrďte souhlas s podmínkami.");
        return false;
        }else{
            var email = $('.email').val();   
            $.get('http://'+location.hostname+'/'+subdomains+'inc/ajax.php', {newsletter: 'newsletter', email: email}, function(vystup) {resultDialog(vystup);} );
        }
        return false; 

});

$('#refall h4 a').live('click', function(){  
		var idreference = $(this).parent().next().next('input').val();   
        obj = $(this).attr('rel');
      
        $.get('http://'+location.hostname+'/'+subdomains+'modules/reference/detail-ajax.php', {code: idreference}, function(vystup) {$("#selectedReference").html(vystup);} );
        $("#refall h4 a").each(function() {
      $(this).removeClass('active');
   });
		$(this).addClass("active");
	
        return false; 

});
//obj = 0;
if($('#indexref').length){
jsonObj = eval($('#indexref').val());
}
$('#nextbutton').live('click', function(){  

         obj++; 
           
       var idreference =  jsonObj[obj]; 
       if(idreference>0){
        $.get('http://'+location.hostname+'/'+subdomains+'modules/reference/detail-ajax.php', {code: idreference}, function(vystup) {$("#selectedReference").html(vystup);} );
        $("#refall h4 a").each(function() {
      $(this).removeClass('active');
   });
		$('h4.ref'+idreference+' a').addClass("active");
		
		}else{
		  obj--;
		}

        return false; 

});
$('#prevbutton').live('click', function(){  

         if(obj > 0){obj--;} 
           
       var idreference =  jsonObj[obj]; 
        $.get('http://'+location.hostname+'/'+subdomains+'modules/reference/detail-ajax.php', {code: idreference}, function(vystup) {$("#selectedReference").html(vystup);} );
        $("#refall h4 a").each(function() {
      $(this).removeClass('active');
   });
	if(idreference>0){	$('h4.ref'+idreference+' a').addClass("active"); }

        return false; 

});
$('#contact .submit').live('click', function(){ 
    
    if($('#term').attr('checked') == false){
      alert("Prosíme potvrďte souhlas s podmínkami.");
      return false;
    }else{
      return true;
    }
  

});

$('#flash').flash({src:'http://'+location.hostname+'/swf/homepage-hlavicka.swf',
                        height:250,
                        width:769, 
                        wmode: 'transparent'
                        });                        

 
    		
});


function resultDialog(val){
    $(document).ready(function(){
        $("div#dialog #d-text").html(val);
        $("div#dialog").show().animate({opacity: 1.0},4000).hide('fast');
        //close dialog manually
        $('div#dialog span').live ('click' , function() { 
            $(this).parent().hide();
	       }); 
     });
}
