﻿$(function() {
		   
$(".view_photo").click(function(event){
		 var top = $(event.target).offset().top;
		 var left = $(event.target).offset().left;
		 var linkwidth = $(event.target).width();
		 var id = $(event.target).attr("title");					   
		 var chTop = $("#" + id).height();

//		 chTop = top - (chTop/2);
		 chTop = top - (500/2);
//		 var chWidth = $("#" + id).width();
                 
                 var chWidth = 500;
		 chWidth = (left + linkwidth/2) - (chWidth/2);
//alert(chTop);
//alert(chWidth);

$("#"+id).css("top", chTop).css("left", chWidth).css("display", "block");

//$("#"+id).css("top", chTop).css("left", chWidth).fadeIn(300);		 

					   });
$(".close").click(function(event){
//	$(event.target).parents("div.view-punct-photo").fadeOut(300);	
		
		var id = $(event.target).attr("title");
		$("#"+id).css("display", "none");	

								});
		   
//popup (services)
					var poptop = $("#you_voite a").offset().top;
					var popleft = $("#you_voite a").offset().left;
					var popscroll = $("body").scrollTop();
					var id = $("#you_voite a").attr("rel");
										
					popleft = popleft - $("#" + id).width()/2 - 10;
if (GetCookie('isvote')!=1)
{		   
					$("#" + id+":hidden").css("top", poptop - popscroll).css("left", popleft).css("display", "block");
}
					
$("#you_voite a").click(function(){	
					$("#" + id).css("top", poptop - popscroll).css("left", popleft).css("display", "block");
							   });
$(".closer").click(function(){
					$("#" + id).css("display", "none");
					SetClose();
								});

//popap (arhiv)

		poptop_arh = $("#arhiv_pop a").offset().top+20;
		popleft_arh = $("#arhiv_pop a").offset().left;
		popscroll_arh = $("body").scrollTop();
		id_arh = $("#arhiv_pop a").attr("rel");
										
		popleft_arh = popleft_arh - $("#" + id_arh).width()/1.25;
$("#" + id_arh+":visible").css("top", poptop_arh - popscroll_arh).css("left", popleft_arh).css("display", "none");
					
$("#arhiv_pop a").click(function(){
		if($("#" + id_arh + ":hidden").size()) {								 
$("#" + id_arh).css("top", poptop_arh - popscroll_arh).css("left", popleft_arh).css("display", "block");
			}
			else {
		$("#" + id_arh).css("display", "none");
								 }
								 
							   });
//zajavka_form

			poptop_zaj = $("#kontact_zaj").offset().top+20;
			popleft_zaj = $("#kontact_zaj").offset().left;
			
			popscroll_zaj = $("body").scrollTop();
			id_zaj = $("#kontact_zaj").attr("rel");		
										
//			popleft_zaj = popleft_zaj - $("#" + id_zaj).width()/1.34;
//								 alert($("#" + id_zaj).width()); 
//								 alert(popleft_zaj); 
			$("#" + id_zaj+":visible").css("top", poptop_zaj - popscroll_zaj).css("left", popleft_zaj).css("display", "none");
					
$("#kontact_zaj").click(function(){
								 if($("#" + id_zaj + ":hidden").size()) {	
		$("#" + id_zaj).css("top", poptop_zaj - popscroll_zaj).css("left", popleft_zaj).css("display", "block");
								 }
								 else {
		$("#" + id_zaj).css("display", "none");
								 }
								 
							   });
$(".form_closer").click(function(){
					$(this).parents("div").css("display", "none");		
								});

		   
		   });
		   
//if (GetCookie('isvote')!=1)
//{
//	window.onload=function(){
//		if (xget('you_voite').style.display!='none'){
//		pop_form2();
//		show_yy (getAbsolutePosition(xget('you_voite_link')).y, 'popup_vote');
//		document.getElementById('popup_vote').style.left=getAbsolutePosition(xget('you_voite_link')).x+'px';
//		document.getElementById('popup_vote').style.marginLeft='-105px';
//		}
//	}
//}

function SetCookie (name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
                ((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
                ((path == null) ? "" : ("; path=" + path)) +
                ((domain == null) ? "" : ("; domain=" + domain)) +
                ((secure == true) ? "; secure" : "");
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}


function GetCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}

function SetClose () {
pathname = location.pathname;
myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/';
var largeExpDate = new Date ();
largeExpDate.setTime(largeExpDate.getTime());
SetCookie('isvote',1,null,'/');
}		   
