﻿//Общаемся с серваком по ajax
function ServerMessage(keyword,table,name_div)
{
	var req;
	var sss;
	if (window.XMLHttpRequest)
	{
		req=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		try	{req=new ActiveXObject('MSXML2.XMLHTTP.3.0');}
		catch(e){}
	}
	if(req)
	{
		req.open("post","/ajax.php",true);
		req.setRequestHeader("Content-Type"," application/x-www-form-urlencoded;");
		req.onreadystatechange=function()
		{
	   	 if (req.readyState==4 && req.status==200)
	    	{
	    		sss=req.responseText;
	    		document.getElementById(name_div).style.display='block';
	    		document.getElementById(name_div).innerHTML=sss;
	    	}
		}
		req.send('keyword='+table+'|'+encodeURIComponent(keyword));
	}
}
function OpenFile(){
var b = getBrowserInfo();
/*if(b.type == 'IE')
{window.showModelessDialog("/admin/loadfile.php?model="+model+"&file="+file,"File","width=500px,height=150px,alwaysRaised=yes,directories=no,location=no,menubar=no,statusbar=no,resizable=no,scrollbar=no,toolbar=no");}
else*/
{
window.open("/loadfile.php","File","width=500px,height=150px,alwaysRaised=yes,directories=no,location=no,menubar=no,statusbar=no,resizable=no,scrollbar=no,toolbar=no");
}
}


function DelFile()
{
	if(confirm("Удалить файл?")==true)
	document.getElementById("pdffile").innerHTML="";
}

function ShowDiv(div)
{
	if(document.getElementById(div)!=null)
	document.getElementById(div).style.display="block";
}

function ShowHideDiv(div)
{
	if(document.getElementById(div)!=null)
	if(document.getElementById(div).style.display=='none')
	document.getElementById(div).style.display="block";
	else
	document.getElementById(div).style.display="none";
}
function HideDiv(div)
{
	if(document.getElementById(div)!=null)
	document.getElementById(div).style.display="none";
}
function VisibleDiv(div)
{
	if(document.getElementById(div)!=null)
	document.getElementById(div).style.visibility="visible";
}

function unVisibleDiv(div)
{
	if(document.getElementById(div)!=null)
	document.getElementById(div).style.visibility="hidden";
}

function ShowMenu(div)
{
	ShowDiv(div);
	$("a.submenu").animate(
	{
		opacity: 1
	},
	100
	);
}

function HideMenu(div)
{
	$("#"+div).animate(
	{
		opacity: 0.01
	},
	100
	);
	setTimeout("HideDiv('"+div+"'),100");
}

//Проверка textarea на количестов символов
function isNotMax(e,div){
	e = e || window.event;
	var target = e.target || e.srcElement;
	var code=e.keyCode?e.keyCode:(e.which?e.which:e.charCode)
	if(target.value.length > target.getAttribute('maxlength')) target.value=target.value.substr(0,target.getAttribute('maxlength'))
	if(div!="empty")
	document.getElementById(div).innerHTML=target.value.length;
	return target.value.length <= target.getAttribute('maxlength');
}

function setScroll()
{
document.body.style.overflowX='auto';
}
function SetScroll()
{
document.body.style.overflowX='auto';
}

function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (window.sidebar) t = 'Netscape';
 return {type:t,version:v};
}

function bookmark(a){
// var id_connection=document.getElementById('code_connection_user').value;
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE') window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
// SM1(id_connection,'addfav');
 return false;
}
function ShowDop(id)
{
    $('#contentpanel'+id).show("slide", {}, 400);

//	$('#contentpanel'+id).slideLeft("slow", function() {})
}
function HideDop(id)
{
    $('#contentpanel'+id).hide("slide", {}, 200);

//	$('#contentpanel'+id).slideLeft("slow", function() {})
}


jQuery(document).ready(function($) {

// Hover for homepage client-banner project list
var fancyHover = {
	init: function() {
		var project = $('.client-banner li');
			
		project.hover(
			function () { 
				$(this).children('.hover').removeClass('offscreen'); 
				$(this).children('.project-info').css( 'background-color' , '#44423e' );
			}, 
			function () { 
				$(this).children('.hover').addClass('offscreen');
				$(this).children('.project-info').css( 'background-color' , '#272623' );
			}
		);
		
	}
};
fancyHover.init();


// Hover for homepage client-banner project list
var hoverAnim = {
	init: function() {
		var project = $('.client-banner li');
		var projectTxt = project.children('.hover');
		var projectInfo = project.children('.project-info');
		var originalBG = "#272623"; 
		var fadeColor = "#44423e";
		
		project.children('.hover').css({left: '0px'})
 		project.children().children('.hover-bg').fadeTo(1, 0.0)
		project.children().children('.hover-content').css({left: '-250px'})
 			
		project.hover(
			function () {
				$(this).children().children('.hover-content').css({left: '-250px'});
				$(this).children().children('.hover-bg').stop().fadeTo(600, 0.70);
				$(this).children().children('.hover-content').stop().animate({left: '0px'} , { queue: false, duration: 450, easing: 'easeOutQuint' });
				$(this).children('.project-info').stop().animate({backgroundColor:fadeColor}, 750);
			}, 
			function () {
				$(this).children().children('.hover-bg').stop().fadeTo(800 , 0.0);
				$(this).children().children('.hover-content').stop().animate({left: '250px'} , { queue: false, duration: 300, easing: 'easeOutQuint' });
				$(this).children('.project-info').stop().animate({backgroundColor:originalBG},850);
			}
		);
		
	}
};
hoverAnim.init();


});

function ShowTour(id)
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 65) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 50) / 2);
	document.getElementById("tournow").value=id;
	w=parseInt(document.getElementById("width"+id).value);
	h=parseInt(document.getElementById("height"+id).value);
	name=document.getElementById("name_tour"+id).value;
	if(window.screen.width>1000)document.body.style.overflowX="hidden";
	document.getElementById('backrazdelbox').style.height=arrayPageSize[1]+'px';
	document.getElementById('backrazdelbox').style.width=arrayPageSize[0]+'px';
	document.getElementById('backrazdelbox').style.display='block';		
	document.getElementById('pplp').style.left=(lightboxLeft-150)+'px';	
	document.getElementById('pplp').style.top=(lightboxTop-150)+'px';
	document.getElementById('pplp').style.width=200+'px';
	document.getElementById('pplp').style.height=200+'px';	

	$('#pplp').animate(
	{
		top:(lightboxTop-h/2-20),
		left:(lightboxLeft-w/2-55),
		width:(w+110),
		height:(h+70),
		opacity:1
	},	
400
	);	
	setTimeout("ActivTour("+id+")",500);
	//AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width',w,'height',h,'src',"/"+name,'quality','high','wmode','transparent','allowFullScreen','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie',"/"+name);	

}

function SendZakaz()
{
	var feedback=true;
	var re2=/^[0-9a-zA-Z\-_]+@[0-9a-zA-Z\-_\.]+\.[a-zA-Z]{2,3}$/;	

	var namezakaz=document.getElementById('namezakaz').value;
	var mailzakaz=document.getElementById('mailzakaz').value;
	var companzakaz=document.getElementById('companzakaz').value;
	var phonezakaz=document.getElementById('phonezakaz').value;
	var textzakaz=document.getElementById('textzakaz').value;
	if(document.getElementById('filename')!=null)
	{var filezakaz=document.getElementById('filename').value;}
	else {var filezakaz="";}
	if(namezakaz==="") {feedback=false;mess="Вы не представились";}
	if(phonezakaz==="") {feedback=false;mess="Вы не указали номер телефон";}
	if(textzakaz==="") {feedback=false;mess="Вы не написали запрос";}
	if(mailzakaz==="" || !re2.test(mailzakaz)) {feedback=false;mess="Проверьте e-mail";}
	if(feedback==true)
	{
		document.getElementById('namezakaz').value="";
		document.getElementById('mailzakaz').value="";
		document.getElementById('companzakaz').value="";
		document.getElementById('phonezakaz').value="";
		document.getElementById('textzakaz').value="";
		document.getElementById("thumbnails").innerHTML="";
		document.getElementById('errorzakaz').innerHTML="";
		ServerMessage(mailzakaz+'|'+namezakaz+'|'+companzakaz+'|'+phonezakaz+'|'+textzakaz+'|'+filezakaz,'sendletter5','errorzakaz');
		//setTimeout('HideLetter()',2500);		
	}
	else
	{
		document.getElementById('errorzakaz').innerHTML=mess
	}
}

function ActivTour(id)
{

	name=document.getElementById("name").value;
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width',820,'height',540,'src',""+name,'quality','high','wmode','transparent','allowFullScreen','true','pluginspage','http://www.macromedia.com/go/getflashplayer','movie',""+name);
 	}
function ActivTour1(id)
{

	document.getElementById("flashmovie").innerHTML="<iframe src='http://virtual-tours.ru/"+document.getElementById("path").value+".swf' width=820px height=540px frameborder=0></iframe>";
 	}
function ActivTour2(id)
{

	document.getElementById("flashmovie").innerHTML="<iframe src='http://virtual-tours.ru/"+document.getElementById("pathtour").value+"/tour.php?path="+document.getElementById("path").value+"' width=820px height=540px frameborder=0></iframe>";
 	}
function CloseTour(id)
{
	document.getElementById("flashmovie").innerHTML="";
	HideDiv("pplp");
	HideDiv("backrazdelbox");setScroll();
} 

function NextTour()
{
 	document.getElementById("close").style.display="none";
	document.getElementById("textdesc").innerHTML="";
	document.getElementById("flashmovie").innerHTML="";
	id=document.getElementById("tournow").value;
	if(id==8)id=1;else id++;
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 65) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 50) / 2);
	document.getElementById("tournow").value=id;
	w=parseInt(document.getElementById("width"+id).value);
	h=parseInt(document.getElementById("height"+id).value);
	name=document.getElementById("name_tour"+id).value;
	if(window.screen.width>1000)document.body.style.overflowX="hidden";
	$('#pplp').animate(
	{
		top:(lightboxTop-h/2-20),
		left:(lightboxLeft-w/2-55),
		width:(w+110),
		height:(h+70),
		opacity:1
	},	
400
	);	
	setTimeout("ActivTour("+id+")",500);	
}
function PrevTour()
{
 	document.getElementById("close").style.display="none";
	document.getElementById("textdesc").innerHTML="";
	document.getElementById("flashmovie").innerHTML="";
	id=document.getElementById("tournow").value;
	if(id==1)id=8;else id--;
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 65) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 50) / 2);
	document.getElementById("tournow").value=id;
	w=parseInt(document.getElementById("width"+id).value);
	h=parseInt(document.getElementById("height"+id).value);
	name=document.getElementById("name_tour"+id).value;
	if(window.screen.width>1000)document.body.style.overflowX="hidden";
	$('#pplp').animate(
	{
		top:(lightboxTop-h/2-20),
		left:(lightboxLeft-w/2-55),
		width:(w+110),
		height:(h+70),
		opacity:1
	},	
400
	);	
	setTimeout("ActivTour("+id+")",500);	
}
