// JScript File



function ChangePageto (elmID)
{	 
	if (document.getElementById(elmID).value != '0')
	{
		location.href = 'default.aspx?pageid=' + document.getElementById(elmID).value;
	} 
	
}

// This function allows you to call the fancy box from javascript
// origional source: http://outburst.jloop.com/2009/08/06/call-fancybox-from-flash/
function callBoxFancy(my_href) 
{
	var j1 = document.getElementById("hiddenclicker");
	j1.href = my_href;
	$('#hiddenclicker').trigger('click');
}



// the key ENTER button capture
function kd(e,function_name)
{
    var intKey = (window.Event) ? e.which : e.keyCode;
    if (intKey == 13) 
    { 
      if (eval (function_name) == false)
		{
			return false;
		}	      
    }
    return true;
}


function clickButton(e, buttonid){
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){
          if (evt.keyCode == 13){				
                bt.click();
                return false;
          }
      }
}

function clickButtonCart(e, buttonid,input1,input2){
		
	  if (document.getElementById("dummynameofOrder").value == '')
	  {
		alert ('יש להזין את שם המזמין')
		return false;
	  }
	  
	  document.getElementById(input1).value = document.getElementById("dummyReheshOrder").value;  
	  document.getElementById(input2).value = document.getElementById("dummynameofOrder").value;  	
		
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      bt.click();      
}

function chkFreeSearch (q_ClientID,SboxClient_ID)
{	
	var q = document.getElementById(q_ClientID);
	
	// this for iterate thrugh all selectbox Cats
	// and check if non of the is changed > else return true
	for (var i = 1; i < 5 ;i++)
	{
		selectedlistboxID = SboxClient_ID + i;
		obj = document.getElementById(selectedlistboxID);
		if (obj.selectedIndex != 0)
		{
			return true;
		}
	} 	
	

	if (q.value == '' || q.value == 'חפש באמטל')
	{
		alert ('יש להזין ערך לחיפוש');
		q.focus();
		return false;
	}	
	
	if (q.value.length < 3)
	{
		alert ('יש להזין לפחות 2 תווים');
		q.focus();
		return false;
	}
	
	
	return true;
}

// this function change the input text value if the txt is "search in amtel";
function onSearchFocus (q)
{
	if (q.value == 'חפש באמטל')
	{
		q.value = '';
	}	
}


// this function fires when user change listbox on search widget
function OnChangeSearchListbox(listboxID,listboxClientID)
{
	// when 1 listbox was selected all other rest to 0 mode 
	for (var i = 1; i < 5 ;i++)
	{
		if (listboxID != i)
		{		 
			selectedlistboxID = listboxClientID + i
			obj = document.getElementById(selectedlistboxID);
			obj.selectedIndex = 0;						
		}
	} 
}


// this function Fire when user press on filter 
// the function pass filter that contain key and value
// the function split and divide the string to key and value
// so it can be pass to ReplaceQueryString and add them to url 
function AddFilter (strFilter)
{
	// split string (delimiter "=")
	arrFilter = strFilter.split("=");
	// put the results in parms
	filter_key = arrFilter[0];
	filter_value = arrFilter[1];
	
	// call the function that rebuild the current url address with the new filter
	strUrl = ReplaceQueryString( location.href , 'index' , '0' );	
	
	// call the function that rebuild the current url address with the new filter
	strUrl = ReplaceQueryString( strUrl , 'itemid' , '0' );	
	
	// call the function that rebuild the current url address with the new filter
	strUrl = ReplaceQueryString( strUrl , filter_key , filter_value );		
	
	// redirect to new url
	location.href = strUrl;
	//alert (strUrl)
}

function ChangePage (strFilter)
{
	// split string (delimiter "=")
	arrFilter = strFilter.split("=");
	// put the results in parms
	filter_key = arrFilter[0];
	filter_value = arrFilter[1];
	
	// call the function that rebuild the current url address with the new filter
	strUrl = ReplaceQueryString( location.href , filter_key , filter_value );		
	
	// redirect to new url
	location.href = strUrl;
	//alert (strUrl)
}

function goItemPage (strFilter)
{	
	// split string (delimiter "=")
	arrFilter = strFilter.split("=");
	// put the results in parms
	filter_key = arrFilter[0];
	filter_value = arrFilter[1];
	
	// call the function that rebuild the current url address with the new filter
	strUrl = ReplaceQueryString( location.href , 'index' , '0' );	
	
	// call the function that rebuild the current url address with the new filter
	strUrl = ReplaceQueryString( strUrl , filter_key , filter_value );		
	
	// redirect to new url
	location.href = strUrl;
	//alert (strUrl)
}


function ReplaceQueryString( url, param, strValue ) 
{
	var preURL = "";
	var postURL = "";
	var newURL = "";

	var iStart_case_1 = url.indexOf( "?" + param + "=" );
	var iStart_case_2 = url.indexOf( "&" + param + "=" );

	if( iStart_case_1 == -1 && iStart_case_2 == -1 )
	{
		preURL = url;
		postURL = "&" + param + "=" + strValue;
	}
	else
	{
		var iStart;
		if( iStart_case_1 > -1 )
		{
			iStart = iStart_case_1 + 1;
		}
		else
		{
			iStart = iStart_case_2 + 1;
		}
		
		var iEnd = url.indexOf( "=" , iStart );
		preURL = url.substring( 0 , iEnd ) + "=" + strValue;

		var iStartRest = url.indexOf( "&" , iStart );
		postURL = "";
		if( iStartRest > -1)
		{
			postURL = url.substring( iStartRest );
		}
	}
	
	newURL = preURL+postURL;

	return newURL;
}


// this function validate that string date , the function get formats (DMY/MDY/YMD/YDM)
function isValidDate(dateStr, format) {
   if (format == null) { format = "MDY"; }
   format = format.toUpperCase();
   if (format.length != 3) { format = "MDY"; }
   if ( (format.indexOf("M") == -1) || (format.indexOf("D") == -1) || (format.indexOf("Y") == -1) ) { format = "MDY"; }
   if (format.substring(0, 1) == "Y") { // If the year is first
      var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
      var reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
   } else if (format.substring(1, 2) == "Y") { // If the year is second
      var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/
      var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/
   } else { // The year must be third
      var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/
      var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
   }
   // If it doesn't conform to the right format (with either a 2 digit year or 4 digit year), fail
   if ( (reg1.test(dateStr) == false) && (reg2.test(dateStr) == false) ) { return false; }
   var parts = dateStr.split(RegExp.$1); // Split into 3 parts based on what the divider was
   // Check to see if the 3 parts end up making a valid date
   if (format.substring(0, 1) == "M") { var mm = parts[0]; } else if (format.substring(1, 2) == "M") { var mm = parts[1]; } else { var mm = parts[2]; }
   if (format.substring(0, 1) == "D") { var dd = parts[0]; } else if (format.substring(1, 2) == "D") { var dd = parts[1]; } else { var dd = parts[2]; }
   if (format.substring(0, 1) == "Y") { var yy = parts[0]; } else if (format.substring(1, 2) == "Y") { var yy = parts[1]; } else { var yy = parts[2]; }
   if (parseFloat(yy) <= 50) { yy = (parseFloat(yy) + 2000).toString(); }
   if (parseFloat(yy) <= 99) { yy = (parseFloat(yy) + 1900).toString(); }
   var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
   if (parseFloat(dd) != dt.getDate()) { return false; }
   if (parseFloat(mm)-1 != dt.getMonth()) { return false; }
   return true;
}

// this function validate email
function checkMailValidty (email)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
	{
		return false;
	}
	else
	{
		return true;
	}
}

// this function clear the border style color on non validated inputs
function ClearBorderstyle (elmID,color)
{
	var obj = document.getElementById(elmID);
	obj.style.border='1px solid ' + color;
}

// this function check the login widget inputs and policy
function chkLoginForm (customer_number_ClientID,password_ClientID)
{
	var Customer_number = document.getElementById(customer_number_ClientID);
	var Password = document.getElementById(password_ClientID);
	
	// check if Customer_number is empty
	if (Customer_number.value == '')
	{
		alert ("יש להזין מספר לקוח");
		Customer_number.style.border='1px solid red';			  // color input borders
		Customer_number.focus();								  // focus on element
		
		if (Customer_number.addEventListener)
		{
			Customer_number.addEventListener('change', function() {ClearBorderstyle(customer_number_ClientID,'#7f9db9');}, false);
		}
		else
		{
			//something for IE
			Customer_number.attachEvent('onchange', function() {ClearBorderstyle(customer_number_ClientID,'#7f9db9');});
		}
		return false;
	}
	
	// check for non numeric chars
	if (isNaN(Customer_number.value) == true)
	{
		alert ("יש להזין מספרים בלבד");
		Customer_number.style.border='1px solid red';			  // color input borders
		Customer_number.focus();								  // focus on element
		
		if (Customer_number.addEventListener)
		{
			Customer_number.addEventListener('change', function() {ClearBorderstyle(password_ClientID,'#7f9db9');}, false);
		}
		else
		{
			//something for IE
			Customer_number.attachEvent('onchange', function() {ClearBorderstyle(password_ClientID,'#7f9db9');});
		}
		return false;
	}
	
	// check if Customer_number is empty
	if (Password.value == '')
	{
		alert ("יש להזין סיסמא");
		Password.style.border='1px solid red';			  // color input borders
		Password.focus();								  // focus on element
		
		if (Password.addEventListener)
		{
			Password.addEventListener('change', function() {ClearBorderstyle(customer_number_ClientID,'#7f9db9');}, false);
		}
		else
		{
			//something for IE
			Password.attachEvent('onchange', function() {ClearBorderstyle(customer_number_ClientID,'#7f9db9');});
		}
		return false;
	}
	
}


// this function validate all input tags that have CheckEmpty = "1" , if they are empty it shows
// Error Message and colored the input borders, and attach event listener for onchage event
function chkForm (ExtendedFunctionCheck)
{
	// get into array all input tags
	var Inputlists = document.getElementsByTagName("input");
	
	// check if all input tags that have CheckEmpty attribute are not empty!
	for (var i = 0; i < Inputlists.length; i++) 
	{
		
		
		// check if CheckEmpty equal to 1
		if (Inputlists[i].getAttribute("CheckEmpty") == "1" && Inputlists[i].value == "")
		{
			// print error msg from tag
			alert(Inputlists[i].getAttribute("CheckEmptyError")); // show err msg
			Inputlists[i].style.border='1px solid red';			  // color input borders
			Inputlists[i].focus();								  // focus on element
			
			if (Inputlists[i].addEventListener)
			{
				Inputlists[i].addEventListener('change', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');}, false);
			}
			else
			{
				//something for IE
				Inputlists[i].attachEvent('onchange', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');});
			}
			
			return false;
		}		
		
		
		
		
		
		// check if CheckValidMail equal to 1
		if (Inputlists[i].getAttribute("CheckValidMail") == "1" && checkMailValidty(Inputlists[i].value) == true && Inputlists[i].value != "")
		{
			// print error msg from tag
			alert(Inputlists[i].getAttribute("CheckValidMailError")); // show err msg
			Inputlists[i].style.border='1px solid red';				  // color input borders
			Inputlists[i].focus();									  // focus on element
			
			if (Inputlists[i].addEventListener)
			{
				Inputlists[i].addEventListener('change', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');}, false);
			}
			else
			{
				//something for IE
				Inputlists[i].attachEvent('onchange', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');});
			}
			
			return false;
		}	
		
		
		
		
		
		// check if CheckValidDate equal to 1
		if (Inputlists[i].getAttribute("CheckValidDate") == "1" && isValidDate(Inputlists[i].value,"DMY") == false && Inputlists[i].value != "")
		{
			// print error msg from tag
			alert(Inputlists[i].getAttribute("CheckValidDateError")); // show err msg
			Inputlists[i].style.border='1px solid red';				  // color input borders
			Inputlists[i].focus();									  // focus on element
			
			if (Inputlists[i].addEventListener)
			{
				Inputlists[i].addEventListener('change', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');}, false);
			}
			else
			{
				//something for IE
				Inputlists[i].attachEvent('onchange', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');});
			}
			
			return false;
		}	
		
		
		
		
		// check if CheckNumeric equal to 1
		if (Inputlists[i].getAttribute("CheckNumeric") == "1" && isNaN(Inputlists[i].value) == true)
		{
			// print error msg from tag
			alert(Inputlists[i].getAttribute("CheckNumericError")); // show err msg
			Inputlists[i].style.border='1px solid red';				// color input borders
			Inputlists[i].focus();									// focus on element
			
			if (Inputlists[i].addEventListener)
			{
				Inputlists[i].addEventListener('change', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');}, false);
			}
			else
			{
				//something for IE
				Inputlists[i].attachEvent('onchange', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');});
			}
			
			return false;
		}	
		
		
		// check if minChars not empty
		if (Inputlists[i].getAttribute("minChars") != null && parseInt (Inputlists[i].value.length) < parseInt (Inputlists[i].getAttribute("minChars")))
		{					
			// print error msg from tag
			alert(Inputlists[i].getAttribute("minCharsError"));		// show err msg
			Inputlists[i].style.border='1px solid red';				// color input borders
			Inputlists[i].focus();									// focus on element
			
			if (Inputlists[i].addEventListener)
			{
				Inputlists[i].addEventListener('change', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');}, false);
			}
			else
			{
				//something for IE
				Inputlists[i].attachEvent('onchange', function() {ClearBorderstyle(Inputlists[i].id,'#C4C3C3');});
			}
			
			return false;
		}	
		
				
		
		// check if ExtendedFunction set to some function  > if true execute them 
		if (Inputlists[i].getAttribute("ExtendedFunction") != null)
		{
			if (eval (Inputlists[i].getAttribute("ExtendedFunction")) == false)
			{
				return false;
			}						
		}	
		
	} // close for statement
	
	
	if (ExtendedFunctionCheck != '')
	{
		if (eval (ExtendedFunctionCheck) == false)
		{
			return false;
		}	
	}
	

	// if everything is ok return true
	return true;
	
}

function ExtendedCheckChangePass ()
{
	// checbox intrests check at least one chosen
	var chbox_intrest1 = document.getElementById('_ctl0_Intrests1').checked;
	var chbox_intrest2 = document.getElementById('_ctl0_Intrests2').checked;
	var chbox_intrest3 = document.getElementById('_ctl0_Intrests3').checked;
	var chbox_intrest4 = document.getElementById('_ctl0_Intrests4').checked;
	
	if ( chbox_intrest1 == false && chbox_intrest2 == false && chbox_intrest3 == false && chbox_intrest4 == false )
	{
		alert ("יש לבחור לפחות תחום התעניינות אחד.");	
		document.getElementById('_ctl0_Intrests1').focus();
		return false;
	}	
	return true;
}


function ExtendedCheckRegistration ()
{
	// checbox intrests check at least one chosen
	var chbox_intrest1 = document.getElementById('_ctl0_Intrests1').checked;
	var chbox_intrest2 = document.getElementById('_ctl0_Intrests2').checked;
	var chbox_intrest3 = document.getElementById('_ctl0_Intrests3').checked;
	var chbox_intrest4 = document.getElementById('_ctl0_Intrests4').checked;
	
	if ( chbox_intrest1 == false && chbox_intrest2 == false && chbox_intrest3 == false && chbox_intrest4 == false )
	{
		alert ("יש לבחור לפחות תחום התעניינות אחד.");	
		document.getElementById('_ctl0_Intrests1').focus();
		return false;
	}
		
	// check agrrement checkbox
	if (document.getElementById('_ctl0_Aggrement').checked == false)
	{
		alert ("יש לאשר את נכונות הפרטים בטופס.");	
		document.getElementById('_ctl0_Aggrement').focus();
		return false;
	}
	
	return true;
}

function testComplex(val){	
	minAZ=1
	minDigits=0	
	
	if (minAZ &&/[a-z]/.test(val) && val.match(/[a-z]/gi).length < minAZ) return false	
	
return true
}


// this function check the Password Complexity
function PasswordComplexity ()
{
	var elm1 = document.getElementById('_ctl0_UserPass1');
	if (testComplex(elm1.value) == true)
	{
		return true;
	}
	else
	{			
		// print error msg from tag
		alert("אורך הסיסמא בין 6-20 תווים באותיות אנגלית או מספרים ללא רווחים"); // show err msg		
		elm1.focus();															 // focus on element
		return false;
	}
		
}

// this function compare between 2 inputs and return if they are equal
function ComparePassword()
{	
	var elm1 = document.getElementById('_ctl0_UserPass1');
	var elm2 = document.getElementById('_ctl0_UserPass2');
	if (elm1.value == elm2.value)
	{
		return true;
	}
	else
	{
		// print error msg from tag
		alert("הסיסמא וסיסמת האימות שהזנת אינם זהות");			// show err msg		
		elm2.focus();											// focus on element
		return false;
	}
	
	return false;
}


function Ch (ediv,obj)
{
    obj.style.display='none';
    document.getElementById(ediv).style.display='block';
}
        
function MenuOver (id)
{
 
     
    strElement = 'Tdmenu' + id;                        
    
    w1 = document.getElementById(strElement).offsetWidth;
    document.getElementById(strElement).style.background='#fefefe';
    
    strElement = 'Link' + id;
    document.getElementById(strElement).className='Menulinkhover';
    
    strElement = 'TdmenuLink' + id;
    document.getElementById(strElement).style.display = 'block';
    
 
                           
    strElement = 'tblMenu' + id;
    
    w2 = document.getElementById(strElement).offsetWidth;
    if (w1 > w2)
    {
        document.getElementById(strElement).style.width = w1 + 'px';   
    }
    
}  


function printContent(ContentElement,CssFilename,HeaderImgname){
	str=document.getElementById(ContentElement).innerHTML;
	newwin=window.open('','printwin','left=100,top=100,width=400,height=400,scrollbars=1,resizable=1')
	newwin.document.write('<HTML>\n<HEAD>\n')
	newwin.document.write('<TITLE>Print Page</TITLE>\n')
	newwin.document.write('<link href="' + CssFilename + '" rel="stylesheet" type="text/css" />\n')
	newwin.document.write('<script>\n')
	newwin.document.write('function chkstate(){\n')
	newwin.document.write('if(document.readyState=="complete"){\n')
	//newwin.document.write('window.close()\n')
	newwin.document.write('}\n')
	newwin.document.write('else{\n')
	newwin.document.write('setTimeout("chkstate()",2000)\n')
	newwin.document.write('}\n')
	newwin.document.write('}\n')
	newwin.document.write('function print_win(){\n')
	newwin.document.write('window.print();\n')
	newwin.document.write('chkstate();\n')
	newwin.document.write('}\n')
	newwin.document.write('<\/script>\n')
	newwin.document.write('</HEAD>\n')
	newwin.document.write('<BODY dir="rtl" onload="print_win()">\n')
	newwin.document.write('<table cellpadding="0" cellspacing="0" border="0" width="610" ><tr><td bgcolor="#5d98de">\n')
	newwin.document.write('<img width="165" src="images/logo2.png" alt=""></td></tr><tr><td><br><br>\n')
	newwin.document.write(str)
	newwin.document.write('</td></tr></table>\n')
	newwin.document.write('</BODY>\n')
	newwin.document.write('</HTML>\n')
	newwin.document.close()
}



function MenuOutselected (id)
{
    strElement = 'Tdmenu' + id;                        
    document.getElementById(strElement).style.background='';
    
    strElement = 'Link' + id;
    document.getElementById(strElement).className='MenulinkSelect';
     
    strElement = 'TdmenuLink' + id;
    document.getElementById(strElement).style.display = 'none';
    
    document.getElementById("Trselected").style.visibility = 'visible';        
}

function LinkTo (strUrl)
{
	document.location.href = strUrl;
}

       
function MenuOverselected (id)
{
 
    strElement = 'Tdmenu' + id;                        
    
    w1 = document.getElementById(strElement).offsetWidth;
    document.getElementById(strElement).style.background='#fefefe';
    
    strElement = 'Link' + id;
    document.getElementById(strElement).className='Menulinkhover';
            
    strElement = 'TdmenuLink' + id;
    document.getElementById(strElement).style.display = 'block';
    
    document.getElementById("Trselected").style.visibility = 'hidden';
        
                           
    strElement = 'tblMenu' + id;
    w2 = document.getElementById(strElement).offsetWidth;
    if (w1 > w2)
    {
        document.getElementById(strElement).style.width = w1 + 'px';   
    }
    
}  

function ChangePlus_Minus(id)
{
	strElement = id;
	if (document.getElementById(strElement).innerHTML == '-')
	{	
		document.getElementById(strElement).innerHTML = '+';
	}
	else
	{
		document.getElementById(strElement).innerHTML = '-';
	}
}


function ChangeDisplayElement(id)
{
	strElement = id;
	if (document.getElementById(strElement).style.display == 'none')
	{
		
		document.getElementById(strElement).style.display = 'block';
		
	}
	else
	{
		
		document.getElementById(strElement).style.display = 'none';
		
	}
	
	
}

function CloseNewsPopup(strElementID)
{
    document.getElementById(strElementID).style.display = 'none';   
}

function openNewsItem(strElementID)
{
    document.getElementById(strElementID).style.display = 'block';   
}


function ChangeSrc (obj,strFilename)
{
    obj.src='images/' + strFilename;
}
      
function MenuOut (id)
{
    strElement = 'Tdmenu' + id;                        
    document.getElementById(strElement).style.background='';
    
    strElement = 'Link' + id;
    document.getElementById(strElement).className='Menulink';
     
    strElement = 'TdmenuLink' + id;
    document.getElementById(strElement).style.display = 'none';
    
}

function ShowWidget(iType)
{
    if (iType == 1)
    {                
        document.getElementById("WidgetTitle1").src='images/SearchTitle_Selected.png';
        document.getElementById("WidgetTitle2").src='images/EnterProducers_NotSelected.png';
        document.getElementById("WidgetContainer1").style.display = 'block';
        document.getElementById("WidgetContainer2").style.display = 'none';
        
        
    }
    else
    {
        document.getElementById("WidgetTitle1").src='images/SearchTitle_notSelected.png';
        document.getElementById("WidgetTitle2").src='images/EnterProducers_Selected.png';
        document.getElementById("WidgetContainer2").style.display = 'block';
        document.getElementById("WidgetContainer1").style.display = 'none';
    }
    
}

function openMore(id)
{
    
    var divID= "MoreDiv" + id 
	var ImgID= "ClickImg" + id
	
    if (document.getElementById(divID).style.display == 'none')
    {
        document.getElementById(divID).style.display='block';  
        document.getElementById(ImgID).src= 'images/11_amtel_-message_09.png';
        
    }
    else
    {
        document.getElementById(divID).style.display='none';    
        document.getElementById(ImgID).src= 'images/+.png';
    }
    
    
}


function MarkAsRead(m,id)
{ 	
	var ImgID= "IsRead" + id;
	document.getElementById(ImgID).src= 'images/v.png';
	

	var req = null; 	 
	if (window.XMLHttpRequest)
	{
 		req = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
					} 
				catch (e) 
					{
					}
			}
    }

	req.onreadystatechange = function()
	{ 
		
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{	
				//alert (req.responseText)			
			}	
			else	
			{
				
			}	
		} 
	}; 
	
	urls = "default.aspx?pageid=44&o=2&m=" + m;
	//alert (urls);
	req.open("GET", urls , true); 
	req.send(null); 
}


function UpdateQtyCart(m,id,qty)
{ 		
	
	if (isNaN(qty)!= false)
	{
		alert ("יש להזין מספרים בלבד.");
		return false;
	}
	else
	{
		if (parseInt (qty) < 1)
		{
			alert ("יש להזין מספר גדול מ - 0");
			return false;
		}
	}
	
	
	//location.href="default.aspx?pageid=45&o=2&i=" + m + "&qty=" + qty;
	
	var req = null; 	 
	if (window.XMLHttpRequest)
	{
 		req = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
					} 
				catch (e) 
					{
					}
			}
    }

	req.onreadystatechange = function()
	{ 
		
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{	
				var SpanID= "ItemPriceTotal" + id;				
				var responsetxt = req.responseText;				
				var Totals_arr;
				
				//alert (req.responseText);
				
				Totals_arr = responsetxt.split("|");
				
				// first Array index is calculated Total
				document.getElementById(SpanID).innerHTML=Totals_arr[0];
				// tax total
				document.getElementById("tax_total").innerHTML=Totals_arr[1];
				// total with tax
				document.getElementById("total_withtax").innerHTML=Totals_arr[2];
				//total without tax
				document.getElementById("total_without").innerHTML=Totals_arr[3];																 
				
			}	
			else	
			{
				
			}	
		} 
	}; 
	
	urls = "default.aspx?pageid=45&o=2&i=" + m + "&qty=" + qty;
	//alert (urls);
	req.open("GET", urls , true); 
	req.send(null); 
} 








function UpdateCommentCart(m,id,comment)
{ 		
	
	//location.href="default.aspx?pageid=40&o=4&i=" + m + "&com=" + comment;
	
	var req = null; 	 
	if (window.XMLHttpRequest)
	{
 		req = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
					} 
				catch (e) 
					{
					}
			}
    }

	req.onreadystatechange = function()
	{ 
		
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{	
				
			}	
			else	
			{
				
			}	
		} 
	}; 	
	urls = "default.aspx?pageid=45&o=4&i=" + m + "&com=" + escape(comment);
	//alert (urls);
	//return false;
	req.open("GET", urls , true); 
	//req.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
	req.send(null); 
} 



function DelOrderItem (id)
{

	var r=confirm("האם אתה בטוח שהנך רוצה למחוק את פריט זה מעגלת הקניות?");
	if (r==true)
	{
		location.href='default.aspx?pageid=45&o=3&i=' + id;	
	}
	else
	{
		return false;
	}
	
}


function SendInventoryMail(id)
{ 		
	
	//location.href="default.aspx?pageid=40&o=4&i=" + m + "&com=" + comment;
	
	var req = null; 	 
	if (window.XMLHttpRequest)
	{
 		req = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
					} 
				catch (e) 
					{
					}
			}
    }

	req.onreadystatechange = function()
	{ 
		
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{	
				//alert (req.responseText);
			}	
			else	
			{
				
			}	
		} 
	}; 	
	urls = "SendInventoryMail.aspx?op=Send&i=" + id;
	//alert (urls);
	//return false;
	req.open("GET", urls , true); 
	//req.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
	req.send(null); 
} 


