//==============================================================================
function my_counter() 
{ 
	_d=document; 
	_n=navigator; 
	_t=new Date(); 
	
	_c="0"; 
	_r="0"; 
	_j="U"; 
	_k="U"; 
	_d.cookie="_c=y";
	_d.cookie.length > 0 ? _k="Y" : _k="N";
	
	_b=screen; 
	_r=_b.width; 
	_n.appName != "Netscape" ? _c=_b.colorDepth : _c=_b.pixelDepth;
	_n.javaEnabled() ? _j="Y" : _j="N";

	_d.write('<img src="http://counter.search.bg/cgi-bin/c?_id=partnior&_z=0&_r='+_r+'&_c='+_c+'&_j='+_j+'&_t='+(_t.getTimezoneOffset())+'&_k='+_k+'&_l='+escape(_d.referrer)+'" width="70" height="15" border="0">');
}
//==============================================================================
function my_counter_tyxo()
{
	d=document;
	d.write('<img width="80" height="15" border="0" alt="Tyxo.bg counter" src="http://cnt.tyxo.bg/105767?rnd='+Math.round(Math.random()*2147483647)+'&sp='+screen.width+'x'+screen.height+'&r='+escape(d.referrer)+'">');
}
//==============================================================================
//==============================================================================
var MyTimeZoneOffset = 0;
function CreateSystemDateTime()
{
	var TimezoneOffset = MyTimeZoneOffset;
	var localTime      = new Date();
	//var ms             = localTime.getTime() + (localTime.getTimezoneOffset() * 60000) + (TimezoneOffset * 3600000);
	var ms             = localTime.getTime() + (localTime.getTimezoneOffset() * 60000) + (TimezoneOffset * 1000);
	var time           = new Date(ms);

	this.day     = time.getDate();
	this.month   = time.getMonth() + 1;
	this.year    = time.getFullYear();
	this.hour    = time.getHours();
	this.minute  = time.getMinutes();
	this.seconds = time.getSeconds();
	
	if(this.day < 10) this.day = '0'+this.day;
	if(this.month < 10) this.month = '0'+this.month;
	if(this.hour < 10) this.hour = '0'+this.hour;
	if(this.minute < 10) this.minute = '0'+this.minute;
	if(this.seconds < 10) this.seconds = '0'+this.seconds;
}
//=============================================================================
function RunClock()
{
	var my_date    = new CreateSystemDateTime();
	var my_day     = my_date.day;
	var my_month   = my_date.month;
	var my_year    = my_date.year;
	
	var my_hour    = my_date.hour;
	var my_minute  = my_date.minute;
	var my_seconds = my_date.seconds;
	
	var res = my_day+'.'+my_month+'.'+my_year+'&nbsp;'+my_hour+':'+my_minute;
	
	if(document.getElementById("ObjectClock") != null)
		document.getElementById("ObjectClock").innerHTML = res;
		
	setTimeout("RunClock()", 2000); //1000
}
//==============================================================================
//==============================================================================
function GetXmlHttpObject(handler)
{
      var xmlHttp = null;
      if (window.XMLHttpRequest) 
      { // Mozilla, Safari,...
         xmlHttp = new XMLHttpRequest();
         if(xmlHttp.overrideMimeType) 
         {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            xmlHttp.overrideMimeType('text/html');
         }
      } 
      else if (window.ActiveXObject) 
      { // IE
         try 
         {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
         } 
         catch (e) 
         {
            try 
            {
               xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) 
            {
            	
            }
         }
      }
      return xmlHttp;
}
//==============================================================================
//==============================================================================
function ChangeBackgroundColor(id, my_color)
{
	var prefix = "left_menu_";
	var object_id = prefix+id;

	if(document.getElementById(object_id) != null)
	{
		document.getElementById(object_id).style.backgroundColor = my_color;
		document.getElementById(object_id).style.cursor = "pointer";
		document.getElementById(object_id).style.cursor = "hand";
	}
}
//==============================================================================
function ChangeBackgroundColor1(id, num, my_color, color_font)
{
	if(document.getElementById(id) != null)
	{
		document.getElementById(id).style.backgroundColor = my_color;
		var i;
		for(i = 1; i <= num; i++)
		{
			if(document.getElementById(id+'_'+i) != null)
				document.getElementById(id+'_'+i).style.color = color_font;
		}
	}
}
//==============================================================================
//==============================================================================
function ChangeLocation(file_name)
{
	if(file_name != '')
		location = file_name;
}
//==============================================================================
function OperationWizardAndChangeAction(val, val1, new_action)
{
	ChangeLocation(new_action);
}
//==============================================================================
//==============================================================================
//==============================================================================
var popy;
function PopUpOpen(theURL,winName,features)
{
	if(!window.focus)
		return true;

	if(popy!=null)
	{
		if(false == popy.closed)
		{
			popy.window.close();
		}
    }
	popy = window.open(theURL,winName,features);
	popy.focus();

    return false;
}
//==============================================================================
var popy1;
function PopUpOpen1(theURL,winName,features)
{
	if(!window.focus)
		return true;

	if(popy1!=null)
	{
		if(false == popy1.closed)
		{
			popy1.window.close();
		}
    }
	popy1 = window.open(theURL,winName,features);
	popy1.focus();

    return false;
}
//==============================================================================
//==============================================================================
function OpenNewWin(url, width, height)
{
	var dev_width  = '600';
	var dev_height = '400';
	
	var my_width;
	var my_height;
	
	if(width == null || width == 0)
		my_width = dev_width;
	else
		my_width = width;
		
	if(height == null || height == 0)
		my_height = dev_height;
	else
		my_height = height;
			
	var theURL   = url;
	var winName  = 'new_win';
	var features = 'width='+my_width+',height='+my_height+',status=no,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no';

	PopUpOpen(theURL,winName,features);
}
//==============================================================================
function OpenNewWinFlash(url, width, height)
{
	var dev_width  = '600';
	var dev_height = '400';
	
	var my_width;
	var my_height;
	
	if(width == null || width == 0)
		my_width = dev_width;
	else
		my_width = width;
		
	if(height == null || height == 0)
		my_height = dev_height;
	else
		my_height = height;
			
	var theURL   = url;
	var winName  = 'new_win';
	var features = 'width='+my_width+',height='+my_height+',status=no,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no';

	PopUpOpen1(theURL,winName,features);
}
//==============================================================================
//==============================================================================
function ResetContactForm()
{
	if(document.getElementById("your_name") != null)
		document.getElementById("your_name").value = '';
		
	if(document.getElementById("your_phone") != null)
		document.getElementById("your_phone").value = '';
		
	if(document.getElementById("your_mail") != null)
		document.getElementById("your_mail").value = '';
		
	if(document.getElementById("your_comment") != null)
		document.getElementById("your_comment").value = '';
}
//==============================================================================
function SendContactForm()
{
	if(document.getElementById("your_name") == null)
		return;
	else
		var your_name = document.getElementById("your_name").value;
		
	if(document.getElementById("your_phone") == null)
		return;
	else
		var your_phone = document.getElementById("your_phone").value;
		
	if(document.getElementById("your_mail") == null)
		return;
	else
		var your_mail = document.getElementById("your_mail").value;
		
	if(document.getElementById("your_comment") == null)
		return;
	else
		var your_comment = document.getElementById("your_comment").value;
		
	var params = 'your_name='+your_name+'&your_phone='+your_phone+'&your_mail='+your_mail+'&your_comment='+your_comment;
	
	xmlHttp = GetXmlHttpObject();
				
	if (xmlHttp == null)
	{
		alert("Browser does not support HTTP Request");
		return;
	}
	
	var url = 'objects/contact_us_ajax_inc.php';
		
	xmlHttp.onreadystatechange = function()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			if(xmlHttp.responseText == 1)
			{
				alert('Вашето съобщение е изпратено успешно!');
				
				ResetContactForm();
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
}
//==============================================================================
//==============================================================================
function ViewFlashFile(file_id, file_name, img_path, source_path, project_name)
{
	var my_param = 'ext_project_name='+project_name+'&ext_img='+img_path+'&ext_source='+source_path+'';
	
	var str = '';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="630" height="500" id="'+file_id+'" align="middle">';
	str += '<param name="allowScriptAccess" value="sameDomain">';
	str += '<param name="movie" value="'+file_name+'">';
	str += '<param name="FlashVars" value="'+my_param+'">';
	str += '<param name="quality" value="high">';
	str += '<param name="bgcolor" value="#d6dadd">';
	str += '<embed src="'+file_name+'" flashvars="'+my_param+'" quality="high" bgcolor="#d6dadd" width="630" height="500" name="'+file_id+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	str += '</object>';
	
	document.write(str);
}
//==============================================================================
//==============================================================================
function ViewFlashFileDetail(file_id, file_name, img_path, source_path, project_name, building, floor, apartment)
{
	var my_param = 'ext_building='+building+'&ext_floor_num='+floor+'&ext_apartment='+apartment+'&ext_project_name='+project_name+'&ext_img='+img_path+'&ext_source='+source_path+'';
	
	var str = '';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="630" height="500" id="'+file_id+'" align="middle">';
	str += '<param name="allowScriptAccess" value="sameDomain">';
	str += '<param name="movie" value="'+file_name+'">';
	str += '<param name="FlashVars" value="'+my_param+'">';
	str += '<param name="quality" value="high">';
	str += '<param name="bgcolor" value="#d6dadd">';
	str += '<embed src="'+file_name+'" flashvars="'+my_param+'" quality="high" bgcolor="#d6dadd" width="630" height="500" name="'+file_id+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	str += '</object>';
	
	document.write(str);
}
//==============================================================================
//==============================================================================
function SimpleSearch(sample_url, str_sample_id, str_sample_param)
{
	var my_arr_sample_id    = new Array();
	var my_arr_sample_param = new Array();
	
	my_arr_sample_id    = str_sample_id.split('|');
	my_arr_sample_param = str_sample_param.split('|');
	
	for(var i = 0; i < my_arr_sample_id.length; i++)
	{
		if(document.getElementById(my_arr_sample_id[i]) == null)
			return;
	}
	
	var sample_my_url = sample_url+'?';
	
	for(var i = 0; i < my_arr_sample_id.length; i++)
	{
		var my_temp_val = document.getElementById(my_arr_sample_id[i]).value;
		
		var toreplace1=/\"/g;
		var toreplace2=/\'/g;
		var toreplace3=/\\|\//g;
		
		my_temp_val = my_temp_val.replace(toreplace1, "%22");
		my_temp_val = my_temp_val.replace(toreplace2, "");
		my_temp_val = my_temp_val.replace(toreplace3, "");
		
		sample_my_url += ''+my_arr_sample_param[i]+'='+my_temp_val+'';
		
		if(i < (my_arr_sample_id.length - 1))
		{
			sample_my_url += '&';
		}
	}
	
	ChangeOnlyAction(sample_my_url);
}
//==============================================================================
//==============================================================================
function ChangeOnlyAction(my_action)
{
	location = my_action;
}
//==============================================================================
//==============================================================================
var ImgScrollTimer;
var ImgScrollObjects = [];
var ImgScrollObjectsSize = [];
var ImgScrollDirection;
function ScrollContentImg(direction, activate)
{
	ImgScrollDirection = direction;
	
	if(ImgScrollObjectsSize.length <= 0)
	{
		if(document.getElementById("ImgSetContainer") == null || document.getElementById("ImgSetContent") == null)
			return;
		
		var ObjectImgSetContainer = document.getElementById("ImgSetContainer");
		var ObjectImgSetContent   = document.getElementById("ImgSetContent");
		
		ImgScrollObjects[ImgScrollObjects.length] = ObjectImgSetContainer;
		ImgScrollObjects[ImgScrollObjects.length] = ObjectImgSetContent;
		
		ImgScrollObjectsSize[ImgScrollObjectsSize.length] = parseInt(ObjectImgSetContainer.style.width);
		ImgScrollObjectsSize[ImgScrollObjectsSize.length] = parseInt(ObjectImgSetContent.style.width); 
		ImgScrollObjectsSize[ImgScrollObjectsSize.length] = ImgScrollObjectsSize[0] - ImgScrollObjectsSize[1];
	}
	
	if(ImgScrollObjectsSize[0] >= ImgScrollObjectsSize[1])
		return;
		
	var ScrollSpeed = 2;
	var ObjectImgSetContentLeft = parseInt(ImgScrollObjects[1].style.left);
	
	if(activate == 1)
    {
    	if(direction == 1)
    	{
    		if(ObjectImgSetContentLeft > ImgScrollObjectsSize[2])
    			ImgScrollObjects[1].style.left = (ObjectImgSetContentLeft - ScrollSpeed)+'px';
    	}
    	else
    	{
    		if(ObjectImgSetContentLeft < 0)
    			ImgScrollObjects[1].style.left = (ObjectImgSetContentLeft + ScrollSpeed)+'px';
    	}
    	
    	ImgScrollTimer = setTimeout("ScrollContentImg(ImgScrollDirection, 1)", 1);
    }
    else
    {
    	clearTimeout(ImgScrollTimer);
    }
}
//==============================================================================
//==============================================================================
