// check and uncheck list of checkbox's
function CheckAll(formObject) 
{
	var chk = formObject.checkAll.checked;
	var len = formObject.elements.length;
	for(var i=0; len >i; i++) 
	{
		var elm = formObject.elements[i];
		if (elm.type == "checkbox")
		{
			elm.checked = chk;
		}
	}
}

// Confirm Delete
function confirmSubmit()
{
	var agree=confirm("?לא ניתן לשחזר את הפריטים המסומנים,האם אתה בטוח שאתה רוצה למחוק את הפריטים המסומנים");
	if (agree)
		return true ;
	else
		return false ;
}

/* Show Product Image Popup */
function showPopup(popURL,popName,popWidth,popHeight) 
{
	var popWin;
	var popAttr = "width="+popWidth+",height="+popHeight+",resizable=1,scrollbars=1";
	popWin = window.open(popURL,popName,popAttr);
	if (popWin.opener == null) popWin.opener = self;
	popWin.focus();
}

function EditMenuItems_confirmSubmit()
{			
	var len = prodForm.elements.length;
	var counter = 0;
	// CHECKING IF THERE ARE CHCKBOX'S CHECKED IN ORDER TO DISPLAY THE CONFIRM MESSAGE.
	for(var i=0; len >i; i++) 
	{
		var elm = prodForm.elements[i];
		if (elm.type == "checkbox" && elm.checked)
		{
			counter+=1;
		}
	}
	// IF COUNTER > 0 IT MEAN THAT THERE ARE CHECKBOX'S CHECKED WHICH NEED TO BE DELETE.
	if (counter>0)
	{
		var agree=confirm("?לא ניתן לשחזר את הקישור, האם אתה בטוח שאתה רוצה למחוק את הקישורים המסומנים");
		if (agree)
			return true ;
		else
			return false ;
	}
	return true;
}


/* Basic product field validations */
function checkForm(form)
{
	if (form.Title.value == "")
	{	alert(".יש להזין כותרת");
		form.Name.focus();
		return false; }
	return true;
}


// THIS FUNCTION WILL CHANGE THE CHECKBOX STAT
function ChangeSmallState(Item)
{
	var objSmallItem = document.getElementById('DelSmallImage1');	
	var objSmallImage = document.getElementById('DelSmallImage');
				
	// change the small image status
	if (objSmallItem.value == 'on')
	{
		objSmallImage.value	=	'1';
		objSmallItem.value	=	'';
	}
	else
	{
		objSmallImage.value	=	'0';
		objSmallItem.value	=	'on';
	}
}

// THIS FUNCTION WILL CHANGE THE CHECKBOX STAT
function ChangeBigState(Item)
{
	var objBigItem	 = document.getElementById('DelBigImage1');
	var objBigImage = document.getElementById('DelBigImage');
	
	// change the big image status
	if (objBigItem.value == 'on')
	{
		objBigImage.value	=	'1';
		objBigItem.value	=	'';
	}
	else
	{
		objBigImage.value	=	'0';
		objBigItem.value	=	'on';
	}
}	

/* SHOW AND HIDE A GIVEN DIV */
function DisplayHideDiv(DivID)
{
	if (DivID.style.display == 'none')
	{
		DivID.style.display = 'block';
	}
	else
	{
		DivID.style.display = 'none';
	}
}

/*
	**********************************************************************
	THIS IS THE SCRIPT THAT WILL SHOW AND HIDE THE SEND TO FRIEND FORM
	**********************************************************************
*/
function toggleSend2Friend()
{
	if (document.getElementById('divSend2Friend').style.display != '')
		document.getElementById('divSend2Friend').style.display = '';
	else
		document.getElementById('divSend2Friend').style.display = 'none';
}
				
function VerifyForm()
{
	var SenderEmail	=	document.getElementById('SenderEmail');

	if (document.getElementById('SenderName').value == '')
	{
		document.getElementById('SenderName').className='TextBoxIn';
		alert ('נא מלא את שמך');
		return false;
	}
	
	if (SenderEmail.value == '')
	{
		SenderEmail.className='TextBoxIn';
		alert ('יש למלא את כתובת דואר האלקטרוני שלך');
		return false;
	}
	
	if (check_email(SenderEmail.value) == false)
	{
		SenderEmail.className='TextBoxIn';
		alert ('כתובת הדואר האלקטרוני שהזנת לא חוקית');
		return false;		
	}	

	if (document.getElementById('Subject').value == '')
	{
		document.getElementById('Subject').className='TextBoxIn';
		alert ('יש להזין את נושא יצירת הקשר');
		return false;
	}

	if (document.getElementById('Message').value == '')
	{
		document.getElementById('Message').className='TextBoxIn';
		alert ('יש למלא את שדה ההודעה');
		return false;
	}

	return true;
}

function VerifyNewsLetterForm()
{
	var SiteURL	=	document.getElementById('SiteURL') ;
	var Email	=	document.getElementById('Email');
	
	if (SiteURL.value == '')
	{
		SiteURL.className='TextBoxIn';
		alert ('יש להזין את כתובת האתר שאותו תרצה שנבחן וננתח');
		return false;
	}
	if (check_url(SiteURL.value) == false)
	{
		SiteURL.className='TextBoxIn';
		alert ('כתובת האתר שהזנת אינה חוקית');
		return false;		
	}	
	
	if (Email.value == '')
	{
		Email.className='TextBoxIn';
		alert ('יש להזין את כתובת הדואר האלקטרוני של איש הקשר');
		return false;
	}	
	
	if (check_email(Email.value) == false)
	{
		Email.className='TextBoxIn';
		alert ('כתובת הדואר האלקטרוני שהזנת לא חוקית');
		return false;		
	}	
		
	if (document.getElementById('Name').value == '')
	{
		document.getElementById('Name').className='TextBoxIn';
		alert ('יש להזין את שם איש הקשר לצורך התקשרות');
		return false;
	}

	if (document.getElementById('Phone').value == '')
	{
		document.getElementById('Phone').className='TextBoxIn';
		alert ('יש להזין מספר הטלפון של איש הקשר');
		return false;
	}

	return true;
}

function check_email(e) 
{
	var apos=e.indexOf("@");
	var dotpos=e.lastIndexOf(".");
	
	if (apos< 1 || dotpos-apos<2 || e.length < 1) 
	{
		return (false);
	}
	else 
	{
		return (true);
	}
} 

function check_url(url) 
{
	var dotpos	=	url.lastIndexOf(".");
	
	if (dotpos < 0 || url.length < 1) 
	{
		return (false);
	}
	else 
	{
		return (true);
	}
} 


/*SET THE PAGE TO BE YOUR HOME PAGE */
function makeHomePage(homepageurl) 
{ 
	document.body.style.behavior='url(#default#homepage)'; 
	//document.body.setHomePage(window.location.href); 
	document.body.setHomePage(homepageurl);
	alert('!אתר זה הפך להיות עמוד הבית שלך');
} 


/* SHOW AND HIDE FUNCTION GET A NAME OF AN ELEMENT TO SHOW AND HIDE*/
function ShowHideItem(Item)
{
	var ele	=	document.getElementById(Item)
	
	if (ele.style.display == "none")
	{
		ele.style.display	=	"";
	}
	else
	{
		ele.style.display = "none";
	}
}


function VerifyAffiliateForm()
{
	var Username		=	document.getElementById('User') ;
	var Password		=	document.getElementById('PassWD') ;
	var PasswordConfirm	=	document.getElementById('PasswordConfirm') ;
	var CheckName		=	document.getElementById('CheckName') ;
	var CheckAddress	=	document.getElementById('CheckAddress') ;
	var CheckZipcode	=	document.getElementById('CheckZipcode') ;
	var Phone			=	document.getElementById('AffPhone') ;
	var Email			=	document.getElementById('AffEmail');
	
	if (Username.value == '')
	{
		Username.className='TextBoxIn';
		alert ('כל השדות חובה, נא לבחור שם משתמש');
		return false;
	}
	if (Password.value == '')
	{
		Password.className='TextBoxIn';
		alert ('כל השדות חובה, נא לבחור סיסמא');
		return false;
	}
	if (PasswordConfirm.value == '')
	{
		PasswordConfirm.className='TextBoxIn';
		alert ('כל השדות חובה, נא לכתוב את הסיסמא בשנית לצורך אימות הסיסמא');
		return false;
	}
	if (Password.value != PasswordConfirm.value)
	{
		PasswordConfirm.className='TextBoxIn';
		alert ('סיסמת האימות שונה מהסיסמא המקורית, נא לכתוב את שוב את הסיסמא');
		return false;
	}
	if (Email.value == '')
	{
		Email.className='TextBoxIn';
		alert ('יש להזין את כתובת הדואר האלקטרוני של מקבל ההמחאה');
		return false;
	}	
	if (check_email(Email.value) == false)
	{
		Email.className='TextBoxIn';
		alert ('כתובת הדואר האלקטרוני שהזנת לא חוקית');
		return false;		
	}	
	if (CheckName.value == '')
	{
		CheckName.className='TextBoxIn';
		alert ('כל השדות חובה, נא למלא את השם אשר לפקודתו תשלח ההמחאה');
		return false;
	}
	if (CheckAddress.value == '')
	{
		CheckAddress.className='TextBoxIn';
		alert ('כל השדות חובה, נא למלא את הכתובת למשלוח ההמחאה');
		return false;
	}
	if (CheckZipcode.value == '')
	{
		CheckZipcode.className='TextBoxIn';
		alert ('כל השדות חובה, נא למלא את המיקוד שאליו תשלח ההמחאה');
		return false;
	}
	if (Phone.value == '')
	{
		Phone.className='TextBoxIn';
		alert ('כל השדות חובה, נא למלא את מספר הטלפון של מקבל ההמחאה');
		return false;
	}
	
	return true;
}

function VerifyAffiliateLoginForm()
{
	var Username	=	document.getElementById('Username') ;
	var Password	=	document.getElementById('Password');
	
	if (Username.value == '')
	{
		Username.className='TextBoxIn';
		alert ('יש למלא את שם המשתמש');
		return false;
	}
	
	if (Password.value == '')
	{
		Password.className='TextBoxIn';
		alert ('יש למלא את הסיסמא');
		return false;
	}
	
	return true;
}