<!--
	function show_sub_menu(id){
		var target = $(id);
		target.className == "sub_menu_hidden" ? target.className = "sub_menu_visible" : target.className = "sub_menu_hidden";
	}

window.onload = function() {
	
	//Запуск регистрации
	reg_test(1); var regForm = $('regForm');if(regForm){
	regForm.onsubmit = function(){ if(reg_test(0)) return true;
	return false}}
	 
	//Запуск корзины
	var my_cart = new Cart(); my_cart.add();
	
	/* search */
		var text = $('text');
		if(text){
		$('text').onfocus  = function() { if (this.value == 'Я ищу...') {this.value = '';}
		$('searchStat').className = 'sub_menu_visible';}
		}
	/* search */


	
	/* vote */
	var vote = $('vote');
	if(vote){
	var tags=vote.getElementsByTagName('a');
		for (var v=0;  v<tags.length; v++){
					$("commentForm").onreset = function () { for (var f=0;  f<tags.length; f++) tags[f].className = tags[f].className.replace(/ vote_hover/g,'')}
					tags[v].onclick = function () {
					for (var f=0;  f<tags.length; f++) tags[f].className = tags[f].className.replace(/ vote_hover/g,'');				
					this.className += ' vote_hover';
					$('comment_vote').value = this.rel;
					return false
					} 
			}
		}
		
		
		//var tags = regForm.getElementsByTagName('input');
		//Note for all input
		/*if(vote){
			
		var tags = vote.getElementsByTagName('*');
			for (var v=0; v<tags.length; v++){		
			if(tags[v].type == 'text' || tags[v].type == 'password'){
				tags[v].onfocus = function(){
					var input_note = this.id+'_Note';
					if (this.value == this.defaultValue) this.value = "";
					$(input_note).className = $(input_note).className.replace(/ sub_menu_hidden/g,' sub_menu_visible')}
				tags[v].onblur = function(){
					var input_note = this.id+'_Note';
					if (!this.value) this.value = this.defaultValue;
					$(input_note).className = $(input_note).className.replace(/ sub_menu_visible/g,' sub_menu_hidden');
					saveComment()}
			}
		}
		}*/
		//Note for all input
	
	var slide = new Array(0,1,2);
	var prev = $('prev');
		if(prev){
		prev.onclick = function(){	var len = slide.length-1; slide.unshift(slide[len]); slide.pop(slide); 
		doRequest('slide/displaySlide', slide[0], 'null', 'null', 'banner_content');
		}
		}
	var next = $('next');
		if(next){
		next.onclick = function(){ slide.push(slide[0]); slide.shift(slide[0]);
		doRequest('slide/displaySlide', slide[0], 'null', 'null', 'banner_content');
		}
		}
		
		
		//var slideInterval = setInterval(function() { slide.push(slide[0]); slide.shift(slide[0]); doRequest('slide/displaySlide', slide[0], 'null', 'null', 'banner_content'); },5000);
	
}


function saveComment() {
	var invalid = 0;
	var name = $$('comment_name')[0].value;
	var mail = $$('comment_mail')[0].value;
	var text = $$('comment_text')[0].value;
	
	if(name.match(/^[\wа-яёЁ ]{1,20}$/i)){ $$('comment_name')[0].className = 'valid'}else{
	$$('comment_name')[0].className = 'invalid'; invalid++}
	if(mail.match(/^[-a-z0-9\.\_]+@[-a-z0-9\.]+\.[a-z]{2,4}$/i)){ $$('comment_mail')[0].className = 'valid'}else{
	$$('comment_mail')[0].className = 'invalid'; invalid++}
	if(text.match(/^[\w\sа-яёЁ\.\+\-\,\?\!\"\'\(\)\;\:\[\]]{5,500}$/i)){ $$('comment_text')[0].className = 'valid'}else{	
	$$('comment_text')[0].className = 'invalid'; invalid++}
	
	if(!invalid){ 
		doRequest('comment/saveComment', 'id', 'controlVar', $('commentForm'), 'commentNote');
		$('commentNote').innerHTML = '<input type="submit" value="Идет cохранение..." class="submit" disabled="disabled" />'}
}


/* vote */



/* Cart */
function Cart() {	
	this.add = function() {
		var modelCard = $('modelCard');
		if(modelCard){
			var a=modelCard.getElementsByTagName('a');
			for (var v=0;  v<a.length; v++){
				var obj = a[v].id;
				if(obj.match(/^buy_(.*)$/i)){
					$(obj).onclick = function() {
						GWindow('buy', 'cart/cart', 'null', 'null', this.id, 250, 410, 100, 'Добавление в корзину');
					return false}
				}	
			}
		}
	}

}	   
/* Cart */


function displayNews(id) {
		doRequest('news/displayNews', id, 'null', 'null', 'cnews');
}




/* AuthParam */

function addAuthProperty(property){
	
	GWindow('add'+property, 'authparam/addAuthProperty', 'null', 'null', this.id, 370, 750, 100, 'Редактирование адреса доставки');
	
return false}


function updateAuthPerson(){
	GWindow('updateAuthPerson', 'authparam/updateAuthPerson', 'null', 'null', this.id, 350, 650, 100, 'Редактирование персональных данных');

return false}

/* AuthParam */




function GWindow_WRX(WinName, content, id, controlVar, value, Height, Width, Zindex, WinTitle){
	var WinBoxExist = $(WinName);
	if(!WinBoxExist){
	Window(WinName, WinTitle, Height, Width, Zindex);
	$(WinName+'_Body').innerHTML = content;
	WindowRegister(WinName);
	WindowPosition($(WinName));
	}else{
	//doRequest(ScriptName, id, controlVar, value, WinName+'_Body');
	}
}

function openImagePopup(url,title){
	var WinBoxExist = $('imagePopup');
	if(WinBoxExist) GWindowClose('imagePopup');
	
	//Сообщение о начале загрузки
	GWindow_WRX('imagePopup_loading', "<img src='"+HOST_PROTOCOL+''+HOST+PORT+"/elm/ajax-loader.gif' width='20' height='20' vspace='10' hspace='10' alt='Идет Загрузка...' /><br />Идет загрузка...", 'null', 'null', 'null', 80, 200, 100, title);
	
	//Загрузка изображения
	var Img = new Image();
	Img.onload = function ()
	{	
		GWindowClose('imagePopup_loading');
		GWindow_WRX('imagePopup', '<img src="'+url+'" alt="'+title+'" />', 'null', 'null', 'null', this.height, this.width, 100, title);
	}
	Img.src=url;
		
}


//-->

