function showlogintype(type)
{
	if (type==1)
		{document.getElementById('userlogin').className='';
		document.getElementById('storelogin').className='hidden';}
	else
		{document.getElementById('userlogin').className='hidden';
		document.getElementById('storelogin').className='';}

}
function showContent(ID){
	var oElement = document.getElementById(ID);
	if (oElement){
	    if ( oElement.className == "hidden"){oElement.className ="";}
	    else{oElement.className ="hidden";}
		}
	}

function gebid(obj)
{
	if (document.getElementById(obj))
		return document.getElementById(obj);
	else
		return null;
}
function gebidit(obj)
{
	if(document.all)
		return document.getElementById(obj).innerText;
	else
		return document.getElementById(obj).textContent;
}
function removeproductstousers(code)
{
	if (confirm('האם להסיר את המוצר מרשימת המעקב ?'))
	{
		gebid(code).className='hidden';
		deleteproductstousers(code);
		showmessage('topmessage','success-msg','המוצר הוסר מרשימת המעקב שלך. <a nohref onclick=restoreproduct(' + code + ')>לחץ כאן להחזרת המוצר לרשימת המעקב</a>.');
	}
	

}

function removeproductstousersbyproductcode(code)
{
	if (confirm('האם להסיר את המוצר מרשימת המעקב ?'))
	{
		gebid(code).className='hidden';
		deleteproductstousersbyproductcode(code);
		showmessage('topmessage','success-msg','המוצר הוסר מרשימת המעקב שלך. <a nohref onclick=restoreproduct(' + code + ')>לחץ כאן להחזרת המוצר לרשימת המעקב</a>.');
	}
	

}

function stopscanning(code)
{
	if (confirm('האם להסיר את המוצר מרשימת המוצרים שלך ?'))
	{
		gebid(code).className='hidden';
		deleteproductstostoresbyproductcode(code);
		showmessage('topmessage','success-msg','המוצר הוסר מרשימת המוצרים שלך. <a nohref onclick=restorestoreproduct(' + code + ')>לחץ כאן להחזרת המוצר לרשימת המוצרים</a>.');
	}
	

}

function addproductstousers(code)
{
	if (confirm('האם להוסיף את המוצר לרשימת המעקב ?'))
	{
		gebid('addremove' + code).innerHTML='<a class="alterhref" onclick="removeproductstousersbyproductcode(' + code + ')" title="הסר ממעקב">מחק</a>';
		insertproductstousers(code);
		showmessage('topmessage','success-msg','המוצר נוסף לרשימת המעקב שלך.');
	}
	

}

function showmessage(id,classname,message)
{
	var obj=gebid(id);
	if (obj)
	{
		obj.className=classname;
		obj.innerHTML=message;
	}
}

function updatereaddate(messageid)
{
	httprequest('/utils.asp?action=1&value=' + messageid);
}

function deletemessage(messageid)
{
	httprequest('/utils.asp?action=2&value=' + messageid);
}

function deleteproductstousers(code)
{
	httprequest('/utils.asp?action=3&value=' + code);
}

function restoreproduct(code)
{
	gebid(code).className='';
	httprequest('/utils.asp?action=4&value=' + code);
	showmessage('topmessage','success-msg','המוצר הוחזר לרשימת המעקב שלך.');
	
}

function insertproductstousers(code)
{
	httprequest('/utils.asp?action=5&value=' + code);
}

function deleteproductstousersbyproductcode(code)
{
	httprequest('/utils.asp?action=6&value=' + code);
}

function sendverificationsms()
{
	if (confirm('האם לשלוח קוד אימות למספר שציינת בהרשמה ?'))
	{
		xmlHttp=GetXmlHttpObject()
		var url="/utils.asp?action=7"
		xmlHttp.onreadystatechange=function () { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			if (xmlHttp.responseText!="")
				alert(xmlHttp.responseText);
			gebid('verifybox').className='';
		} 
		}
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	
}

function sharemenu(div)
{
	if (gebid('share' + div).className=='')
	{
		gebid('share' + div).className='hidden';
	}
else
	{
	xmlHttp=GetXmlHttpObject()
	var url="/sharemenu.asp?code=" + div
	xmlHttp.onreadystatechange=function () { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		gebid('share' + div).innerHTML=xmlHttp.responseText;
		gebid('share' + div).className='';
	} 
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function checkverification()
{
	xmlHttp=GetXmlHttpObject()
	var url="/utils.asp?action=8&value=" + gebid('txtCode').value;
	xmlHttp.onreadystatechange=function () { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		if (xmlHttp.responseText!="OK")
		{
			alert(xmlHttp.responseText);
		}
		else
			location.href='/myproducts.asp?action=welcome';
		
	} 
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function checkverificationchrome()
{
	xmlHttp=GetXmlHttpObject()
	var url="/utils.asp?action=8&value=" + gebid('txtCode').value;
	xmlHttp.onreadystatechange=function () { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		if (xmlHttp.responseText!="OK")
		{
			alert(xmlHttp.responseText);
		}
		else
			location.href='/myproducts.asp?action=added';
		
	} 
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}


function deleteproductstostoresbyproductcode(code)
{
	httprequest('/utils.asp?action=9&value=' + code);
}

function restorestoreproduct(code)
{
	gebid(code).className='';
	httprequest('/utils.asp?action=10&value=' + code);
	showmessage('topmessage','success-msg','המוצר הוחזר לרשימת המוצרים שלך.');
	
}

function httprequest(page)
{
	xmlHttp=GetXmlHttpObject()
	var url = page
	xmlHttp.open("GET",url,false)
	xmlHttp.send(null)
}

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 

function getCalendar(params,divName,fieldName)
{
xmlHttp=GetXmlHttpObject()
var url="/calendar.asp"
url=url+params;
if (params!='')
	url=url+'&fieldName=' + fieldName+'&divName=' + divName
else
	url=url+'?fieldName=' + fieldName + '&divName=' + divName
xmlHttp.onreadystatechange=function () { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById(divName).innerHTML=xmlHttp.responseText 
} 
}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function validateregisteruser()
				{
					if (!gebid('readagreement').checked)
					{
						alert('יש לאשר את תנאי השימוש');
						return false;
					}
					return true;
				}	

				function plugvalidateregisteruser()
				{
					if (!gebid('readagreement').checked)
					{
						alert('יש לאשר את תנאי השימוש');
						return false;
					}
					return true;
				}	


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function numericControl( txt )  {
    var msg=txt.value;
    var chr;
    for ( i=0; i < msg.length; i++ )  {
      chr=msg.substring(i,i+1);
      if ( chr<"0" || chr>"9" )  {
    msg=msg.substring(0,i);
    txt.value=msg;
      }
    }
  }
  function textControl( txt )  {
    var msg=txt.value;
    var chr;
    for ( i=0; i < msg.length; i++ )  {
      chr=msg.substring(i,i+1);
      if ( chr>="0" && chr<="9" )  {
    msg=msg.substring(0,i);
    txt.value=msg;
      }
    }
  }

  function ReplaceBadChars(txt)
{
var x;var ch = new Array();ch[0] = "+";ch[1] = "-";ch[2] = " ";ch[3] = "/";for (x in ch)
{
	while (txt.indexOf(ch[x])>-1)
	{
		txt=txt.replace(ch[x],"");	}
}
return txt;}

function wrongprice(code)
{
	httprequest('/utils.asp?action=12&value=' + code);
	refreshwrongtimedCount(code);
}

function refreshwrongtimedCount(productcode)
{
	var t1=setTimeout("refreshwrongproduct(" + productcode + ")",1500);
}

function refreshwrongproduct(pcode)
{
	xmlHttp=GetXmlHttpObject()
	var url="/utils.asp?action=11&value=" + pcode;
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			if (xmlHttp.responseText=="OK")
			{
				location.href=location.href;
			}
		}	
	} 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	refreshwrongtimedCount(pcode);
}
