var is_ff = is_rw = timer_wl = timer_cart = null;

function TopSubMenuRW(){
	var ttt=document.getElementById('main_roll_menu').scrollLeft;
	document.getElementById('main_roll_menu').scrollLeft-=2;
	if(ttt.toFixed(1)<=3)
		document.getElementById('start_dots').style.visibility='hidden';
	document.getElementById('end_dots').style.visibility='visible';
}
function TopSubMenuFF(){
	var ttt=document.getElementById('main_roll_menu').scrollLeft;
	document.getElementById('main_roll_menu').scrollLeft+=2;
	if(ttt.toFixed(1)+3>=document.getElementById('main_roll_menu').scrollLeft)
		document.getElementById('end_dots').style.visibility='hidden';
	document.getElementById('start_dots').style.visibility='visible';
}


function StopFF(){clearInterval(is_ff);}
function StopRW(){clearInterval(is_rw);}

function TopSubmenuShow(id){
	HideAllTM();
	var div = document.getElementById('tm_div_'+id);
	var td=document.getElementById('tm_td_'+id);
	div.style.left = getAscendingLefts(td) - document.getElementById('main_roll_menu').scrollLeft;
	div.style.top = getAscendingTops(td);
	div.style.display = '';
}

function TopSubmenuHide(id){
	document.getElementById(id).style.display='none';	
}


function getAscendingLefts(elem){
	if (elem == null)
		return 0;
	else
		return elem.offsetLeft + getAscendingLefts(elem.offsetParent);
}

function getAscendingTops(elem){
	if (elem == null)
		return 0;
	else
		return elem.offsetTop + getAscendingTops(elem.offsetParent);
}


/*WishLists infobox START*/
function WLInfoBoxShow(flag){
	try{document.getElementById("sel_pages").style.visibility="hidden";}catch (e){}
	var div = document.getElementById('WL_infobox');
	var td=document.getElementById('tm_td_wl');
	div.style.left = getAscendingLefts(td)-123;
	div.style.top = getAscendingTops(td) + 19;
	div.style.display = '';

	switch(flag){
		case 0:{
			var sub_url = "action=show";	 
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}
		case 2:{
			var sub_url = "action=registration&email=" + document.getElementById('email_regist').value+ '&passwd1=' + document.getElementById('pass_regist').value;
			$('#tm_td_wl').html('&nbsp;<a style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(2)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					response = response.split("::");
					if(response[0] == 1){
						$('#tm_td_wl').html('<a style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(6)">Выход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark(' + "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')"+ '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
						$('#WL_infobox').html(response[1]);
					}
					else{
						$('#tm_td_wl').html('&nbsp;<a style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(5)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
						$('#WL_infobox').html(response[1]);
					}
				}
			});
			break;
		}
		case 3:{
			var sub_url = "action=show_forg_pass";	 
			$('#tm_td_wl').html('&nbsp;<a style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(3)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}
		case 4:{// залогинился
			var sub_url = "action=log_true";	 
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}
		case 5:{// неверный пароль
			var sub_url = "action=log_false";	 
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}

		case 6:{// выход
			var sub_url = "action=exit_answ";	 
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}

		case 7:{
			var sub_url = "action=send_email&email=" + document.getElementById('email_regist').value;
			$('#tm_td_wl').html('&nbsp;<a style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(2)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					response = response.split("::");
					if(response[0] == 1){
						$('#tm_td_wl').html('&nbsp;<a style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(9)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
						$('#WL_infobox').html(response[1]);
					}
					else{
						$('#tm_td_wl').html('&nbsp;<a  style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(8)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
						$('#WL_infobox').html(response[1]);
					}
				}
			});
			break;
		}
		case 8:{
			var sub_url = "action=wrong_mail";	 
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#tm_td_wl').html('&nbsp;<a  style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(8)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
					$('#WL_infobox').html(response);
				}
			});
			break;
		}
		case 9:{
			var sub_url = "action=pass_mail";	 
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}
		case 10:{
			var sub_url = "action=receive_form";	 
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}
		case 11:{
			if(document.getElementById('passwd').value == document.getElementById('passwd2').value){
				var sub_url = "action=save_passswd&passwd="+document.getElementById('passwd').value+"&restore_id="+document.getElementById('restore_id').value+"&session_id="+document.getElementById('session_id').value;	 
			     $.ajax({
        			url: '/dinamic/registration',
		        	data: sub_url,
	        		type: 'get',
			        success: function (response) {
						response = response.split("::");
						if(response[0] == 1){
							$('#tm_td_wl').html('&nbsp;<a  style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(12)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
							$('#WL_infobox').html(response[1]);
						}
						else{
							$('#tm_td_wl').html('&nbsp;<a  style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(10)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
							$('#WL_infobox').html(response[1]);
						}
						
					}
				});
			}
			else{
				alert("Пароль и его подтверждение не совпадают");
				document.getElementById('passwd').value = document.getElementById('passwd2').value = '';
			}
			break;
		}
		case 12:{
			var sub_url = "action=re_sign_in";	 
		    //$('#WL_infobox').html('Loadging...');
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}
		case 14:{
			//$('#tm_td_wl').html('<a  style="cursor:pointer;" OnMouseOver="WLInfoBoxShow(0)">Вход</a>');
			$('#tm_td_wl').html('&nbsp;<a  style="cursor:pointer;"  OnMouseOver="WLInfoBoxShow(0)">Вход</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">На главную</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onMouseDown="addBookmark('+ "'Агенство бизнес-технологий в интернете','http://vistar.com.ua')" + '">В избранное</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/site/sendtofriend">Отправить другу</a>&nbsp;');
			var sub_url = "action=exit";	 
		    //$('#WL_infobox').html('Loadging...');
		     $.ajax({
        		url: '/dinamic/registration',
		        data: sub_url,
        		type: 'get',
		        success: function (response) {
					$('#WL_infobox').html(response);
				}
			});
			break;
		}



	}
//	var sub_url = "action=send_email&table_prefix="+table_prefix+"&email=" + document.getElementById('email_subscr').value;	 

// 	  response = response.split("=");

}

function WLInfoBoxHide(){
	document.getElementById('WL_infobox').style.display='none';
	try{document.getElementById("sel_pages").style.visibility="visible";}catch (e){}
}
/*WishLists infobox END*/


/*Cart infobox START*/
function CartInfoBoxShow(){
	try{document.getElementById("sel_pages").style.visibility="hidden";}catch (e){}
	var div = document.getElementById('cart_infobox');
	var td=document.getElementById('tm_td_cart');
	div.style.left = getAscendingLefts(td) - 140;
	div.style.top = getAscendingTops(td) + 3;
	div.style.display = '';
}

function CartInfoBoxHide(){
	document.getElementById('cart_infobox').style.display='none';
	try{document.getElementById("sel_pages").style.visibility="visible";}catch (e){}
}
/*Cart infobox END*/
