

function DisplayDiv2(id, state)
{
	if (state == 0)
	{
		document.getElementById(id).style.display='block';
	}
	else
	{
		document.getElementById(id).style.display='none';
	}
}

function DisplayDiv(id)
{
	//alert(id);
	
	var state = document.getElementById(id).style.display;
	
	/*var imgid="img" + id;
	if (lastdisplayed != null)
	{
		//lastimgid = "img" + lastdisplayed;
		document.getElementById(lastdisplayed).style.display='none';
		//document.getElementById(lastspan).style.display='none';
		//document.getElementById(lastimgid).src='images/ques.jpg';
		//document.getElementById(lastimgid).alt='לחץ כאן להסבר';
	}
	*/
	
	if (state != 'block')
	{
		document.getElementById(id).style.display='block';
		//lastdisplayed = id;
		//document.getElementById(spanid).style.display='block';
		//lastspan= spanid;
		//document.getElementById(imgid).src='images/x.png';
		//document.getElementById(imgid).alt='לחץ כאן לסגור הסבר';
	}
	else
	{
		document.getElementById(id).style.display='none';
		//document.getElementById(spanid).style.display='none';
		//document.getElementById(imgid).src='images/ques.jpg';
		//document.getElementById(imgid).alt='לחץ כאן להסבר';
	}
}

 
//function prints received content
function printContent(id1, window_width){

     // str= '<b>' + document.getElementById(title).innerHTML + '</b><br><br>' + document.getElementById(id1).innerHTML + '<br><br>' + document.getElementById(id2).innerHTML

	  str=  document.getElementById(id1).innerHTML 

      newwin=window.open('','printwin','left=300,top=100,width=' + window_width + ',height=500')

      newwin.document.write('<HTML>\n<HEAD>\n')
      
      newwin.document.write('<LINK REL="Stylesheet" HREF="CSS/css.css" TYPE="text/css">')

      newwin.document.write('<TITLE>קופון קפהקפה</TITLE>\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()",3000)\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 onload="print_win()">\n')

      newwin.document.write('<center>' + str + '</center>')

      newwin.document.write('</BODY>\n')

      newwin.document.write('</HTML>\n')

      newwin.document.close()

}



function Change_Image_old(id)
	{
	
		var imgPath = new String()
		imgPath = document.getElementById(id).style.backgroundImage;
	
		if (imgPath == "url(images/pixel.gif)")
		{
			document.getElementById(id).style.backgroundImage = "url(images/overlay.png)";
		}
		else
		{
			document.getElementById(id).style.backgroundImage = "url(images/pixel.gif)";
		}
	}


// navigation menu mouseover
function Change_Image(id, img_over)
	{
		document.getElementById(id).style.backgroundImage = "url(images/" + img_over + ")";
	}




//search button submit
function SearchSubmit()
{
	//alert("Search");
	var strSearchTerm = document.searchform.q.value
	
	var strAction="default.asp?PageId=20&q=" + strSearchTerm + "&type=q"
	
	location.href = strAction
	return false
}


//newsletter sign up
function Newsletter()
{
	if (  document.newsletter.newsletter.value == "" )
    {
       alert ( "אנא מלא כתובת אימייל" );
		newsletter.newsletter.focus()
        return false;
    }	
		
	   
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(newsletter.newsletter.value)){

	document.newsletter.action='default.asp?pageid=28';
	document.newsletter.submit();
	return true;
	}
	alert("הפורמט של המייל שהזנת שגוי. אנא נסה שנית")
	newsletter.newsletter.focus()
	return false;
}



// Sign up form validation
function CheckContactForm()
{

/*if (  document.signup.agree.checked == false )
    {
       alert ( "יש לאשר שקראת והנך מסכים לתנאי האתר" );
		signup.agree.focus()
        return false;
    }
    
   */

 if (  document.contact_form.Name.value == "" )
    {
       alert ( "אנא מלא את שמך" );
		contact_form.Name.focus()
        return false;
    }
	
	
if (  document.contact_form.Phone.value == "" )
    {
       alert ( "אנא מלא את הטלפון שלך" );
		contact_form.Phone.focus()
        return false;
    }
	
if (  document.contact_form.email.value == "" )
    {
       alert ( "אנא מלא כתובת אימייל" );
		contact_form.email.focus()
        return false;
    }	
		
	   
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(contact_form.email.value)){

document.contact_form.submit()
return true;
}
alert("הפורמט של המייל שהזנת שגוי. אנא נסה שנית")

contact_form.email.focus()
return false;
}


// Login validation
function CheckLoginForm()
{

 if (  document.login.user_name.value == "" || document.login.user_name.value == "שם משתמש" )
    {
       alert ( "אנא מלא את שם המשתמש שלך" );
		login.user_name.value = ""
		login.user_name.focus()
        return false;
    }
	
	
if (  document.login.user_pass.value == ""  || document.login.user_pass.value == "סיסמא" )
    {
       alert ( "אנא מלא את הסיסמא שלך" );
		login.user_pass.value = ""
		login.user_pass.focus()
        return false;
    }
    document.login.submit();
}

// Bookmark page to favorites
function AddToFavorites()
{
	title = "MarketWinners - לימודי שוק הון, מערכות מסחר באינטרנט, עבודה מהבית - מרקט ווינרז";
	url = "http://marketwinners.co.il/";

	if (window.sidebar) { // Mozilla Firefox Bookmark
	window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
	window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
	return true; }
}

// open pop up window
function OpenRadarWindow()
{
	//alert("dsfsfds");
	RadarWindow  = window.open("radar.asp","Radar","menubar=0,scrollbars=0,directories=0,location=0,top=110,left=200%,toolbar=0,status=0,titlebar=0,width=1013,height=613");
	//formwindow.document.getElementById(elementid).value = elementvalue;
	RadarWindow.focus();
}

// Load images for caching
function LoadImages()
{
	if (document.images) //check for browser support
	{ 
		var HpOver = new Image(); 
		var SuccessOver = new Image(); 
		var EitanOver = new Image(); 
		var CourseOver = new Image(); 
		var RadarOver = new Image(); 
		var LiveOver = new Image(); 
		var PixelGif = new Image(); 
		
		HpOver.src = 'images/hp_over.png';
		SuccessOver.src = 'images/success_over.png';
		EitanOver.src = 'images/eitan_over.png';
		CourseOver.src = 'images/course_over.png';
		RadarOver.src = 'images/radar_over.png';
		LiveOver.src = 'images/live_over.png';
		PixelGif.src = 'images/pixel.gif';
	
	} 

}

// set min-height because footer is always vertically aligned with bottom of browser window
function Adjust2ScreenHeight()
{
	//alert( document.body.offsetHeight );
	//alert(document.getElementById('content_txt').clientHeight);
	//264 pixels - height to deduct from offsetHeight
	window_height_2_fill = document.body.offsetHeight - 264;
	
	content_div_height = document.getElementById('content_txt').clientHeight;
	 
	difference_between_heights = window_height_2_fill - content_div_height ;
	
	//alert(difference_between_heights );
	
	if (difference_between_heights  > 0) //if there is a gap to fill
	{
		document.getElementById('content_txt').style.minHeight = content_div_height + difference_between_heights;
		document.getElementById('content_txt').style.height = content_div_height + difference_between_heights; // "expression( this.scrollHeight < " + adjusted_height + " ? '350px' : 'auto' )"
	}
	
	/*var screen_height_left = document.body.offsetHeight - 150; //450 //deduct 450 pixels from total screen height. result must be at least 450 px high, maybe more
	//alert(screen_height_left);
	if (screen_height_left > 450 )
	{
		//adjust min-height in div
		adjusted_height = 450 + screen_height_left;
		document.getElementById('content_txt').style.minHeight = adjusted_height;
		document.getElementById('content_txt').style.height = adjusted_height // "expression( this.scrollHeight < " + adjusted_height + " ? '350px' : 'auto' )"
	}*/
}

// sets clock in header
function Clock ()
{

 var currentTime = new Date ( );

 var currentHours = currentTime.getHours ( );
 var currentMinutes = currentTime.getMinutes ( );
 var currentSeconds = currentTime.getSeconds ( );

 // Pad the minutes and seconds with leading zeros, if required
 currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
 currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

 // Choose either "AM" or "PM" as appropriate
 // var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

 // Convert the hours component to 12-hour format if needed
 //currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

 // Convert an hours component of "0" to "12"
 currentHours = ( currentHours == 0 ) ? 12 : currentHours;

 // Compose the string for display
 var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;

 // Update the time display
 //document.getElementById("clock").firstChild.nodeValue = currentTimeString;
 document.getElementById("clock").innerHTML = currentTimeString;

} 

// sets Date in header
function SetDate()
{
	var currentDateTime = new Date ( );

	var curr_date = currentDateTime.getDate();

	var curr_month = currentDateTime.getMonth() + 1;

	var curr_year = currentDateTime.getFullYear();

	var DateStr = curr_month + "/" + curr_date + "/" + curr_year ;

	var curr_day = currentDateTime.getDay();
	
	switch (curr_day)
	{
		case 0:
			curr_day = 'ראשון';
			break;
		case 1:
			curr_day = 'שני ';
			break;
		case 2:
			curr_day = 'שלישי';
			break;
		case 3:
			curr_day = 'רביעי';
			break;
		case 4:
			curr_day = 'חמישי';
			break;
		case 5:
			curr_day = 'שישי';
			break;
		case 6:
			curr_day = 'שבת';
			break;
	}
	
	document.getElementById("DateNow").innerHTML = DateStr;
	document.getElementById("heb_day").innerHTML = curr_day;

	

	//alert(currentDate);
	
	//alert(currentDateTime.getDay());
	//alert(currentDateTime.getDate());
	//alert(currentDateTime);
	
	//var currentyear = currentDateTime.getFullYear();
	
	//alert("currentyear=" + currentyear);

}


function updateBranches(page_id)
{
	city_array = document.branch_search.city;
	
	//cycle through the array options
	for(var i=0; i < city_array.length; i++) 
	{	
		//check if the option is selected
		if(city_array[i].selected) 
		{
			//alert(city_array[i].id);
			branch2search = city_array[i].id
		}
	}

	// build querystring according to current page 
	URL = 'default.asp?pageid=' + page_id + '&b2s=' + branch2search;
	location.href = URL;	
}

// blog add comment
function CommentSubmit(pg_id, itm_id)
{
	//validation
	 if (document.blog_comment.comment_name.value == "" )
    {
        alert ('יש להזין את השם שלך');
        document.blog_comment.comment_name.focus();
        return false;
    }
    
     if (document.blog_comment.comment_email.value == "" )
    {
        alert ('יש להזין את כתובת האימייל שלך');
        document.blog_comment.comment_email.focus();
        return false;
    }
       
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(blog_comment.comment_email.value)){

		 if (document.blog_comment.comment_content.value == "" )
		{
			alert ('יש להזין את תוכן ההודעה');
			document.blog_comment.comment_content.focus();
			return false;
		}
		
		//submit form
		document.blog_comment.action = 'default.asp?pageid=' + pg_id + '&itemid=' + itm_id + '&addblog=1';
		document.blog_comment.submit();
			
		return true;
	}
	alert("הפורמט של המייל שהזנת שגוי. אנא נסה שנית")

	blog_comment.comment_email.focus()
	return false;

}

function SearchBranch()
{
	branch = document.branch_search.branch.value;

	if (branch==0)
	{
		alert("אנא בחר סניף");
		return;
	}
	
	var selIndex = eval(strForm_Branch).selectedIndex;
	var BranchId = eval(strForm_Branch).options[selIndex].value;		
		
	//alert(BranchId );
	
	document.branch_search.action = 'default.asp?pageid=17&branch_id=' + BranchId;
	document.branch_search.submit();
	
}

function SearchBranch2()
{
	branch = document.branch_search.branch.value;

	if (branch==0)
	{
		alert("אנא בחר סניף");
	}
	else
	{
		
		branch_array = document.branch_search.branch;
	
		//cycle through the array options
		for(var i=0; i < branch_array.length; i++) 
		{	
			//check if the option is selected
			if(branch_array[i].selected) 
			{
				//alert(branch_array[i].city);
				branch_city = branch_array[i].city;
				branch_idd = branch_array[i].id;
				//alert(branch_array[i].id)
			}
		}

		//put value into select box - city
		document.branch_search.city.value = branch_city;
		document.branch_search.branch_id.value = branch_idd;
	
		document.branch_search.submit();
	}
}


function UpdateSearch(branch_id,branch,city)
{
	//alert("branch_id=" + branch_id);
	alert("branch=" + branch);
	//alert("city=" + city);
	
	//document.branch_search.city.value = city;
	//document.branch_search.branch_id.value = branch_id;
	document.branch_search.branch.value = branch;
	
	//alert("document.branch_search.city.value=" + document.branch_search.city.value);
	//alert("document.branch_search.branch_id.value=" + document.branch_search.branch_id.value);
	alert("document.branch_search.branch.value=" + document.branch_search.branch.value );
	
	//document.branch_search.submit();
}

function OpenMap(id)
{
	URL = "map.asp?branch_id=" + id
	MapWindow  = window.open(URL,"Map","menubar=0,scrollbars=0,directories=0,location=0,top=110,left=200%,toolbar=0,status=0,titlebar=0,width=450,height=365");
	MapWindow.focus();
}




function ChangeCity()
    {
		var selIndex = eval(strForm_Branch).selectedIndex;
		var BranchId = eval(strForm_Branch).options[selIndex].value;		
		
		//var ind = 0
		
		for( i = 0 ; i < arrBrenches.length ; i++ ) 
		{		    		    		    
			if( Number( arrBrenches[i].BrenchId ) == Number( BranchId ) )
			{			    
				//eval(strForm_City).selectedvalue = arrBrenches[i].CityId;
				//eval(strForm_City).options[eval(strForm_City).selectedIndex].value = arrBrenches[i].CityId;
				//eval(strForm_City).value = 'יהוד';
				
				arr_position_cityID = arrBrenches[i].CityId;

				city_array = document.eval(strForm_City);
	
				//cycle through the array options
				for(var i=0; i < city_array.length; i++) 
				{	
					//check if the 
					if(city_array[i].value== arr_position_cityID) 
					{
						document.eval(strForm_City).selectedIndex = i;
						GetBrench(arr_position_cityID);
						
						//document.eval(strForm_Branch).selectedIndex = selIndex;
						
						//alert(selIndex );
					}
				}
				
				
				//alert(eval(strForm_City).options[eval(strForm_City).selectedIndex].value);
			}
		}
		
		
		//document.eval(strForm_City).value='';
    }
    
    
    
    
    function Brench( BrenchId , CityId , name )
	{
		this.BrenchId = BrenchId
		this.CityId = CityId
		this.name = name
	}


    function GetBrench( CityId, strForm_City, strForm_Branch )
	{
		eval(strForm_Branch).options.length = 0;
		
		var ind = 0
		
		eval(strForm_Branch).options[0] = new Option( "בחר סניף" , "0" )
		
		for( i = 0 ; i < arrBrenches.length ; i++ ) 
		{		    		    		    
			if( Number( arrBrenches[i].CityId ) == Number( CityId ) )
			{			    
				eval(strForm_Branch).options[++ind] = new Option( arrBrenches[i].name , arrBrenches[i].BrenchId  )
			}
		}
			
	}
	
	
	function OnChangeCategory(form_name , city_input, branch_input)
	{
	    // if no city selected, or user selected "choose city" option
	    
	    strForm_City = 'document.' + form_name + '.' + city_input
	    strForm_Branch = 'document.' + form_name + '.' + branch_input
	    
	    if (eval(strForm_City).value=='0')
	    {	
			eval(strForm_Branch).disabled = true ;
	    }
	    else
	    {
			eval(strForm_Branch).disabled = false ;
		}
	    
	    var selIndex = eval(strForm_City).selectedIndex;
		var CityId = eval(strForm_City).options[selIndex].value;		
		
		GetBrench( CityId, strForm_City, strForm_Branch )	
	}
	
	
	function UpdateInviteForm(form_name , city_input, branch_input, selected_city_value, selected_branch_id)
	{
	    // if invite friends from branch search with querystring
	    
	    strForm_City = 'document.' + form_name + '.' + city_input
	    strForm_Branch = 'document.' + form_name + '.' + branch_input
	    
	    eval(strForm_City).value = selected_city_value;
	    
		eval(strForm_Branch).disabled = false ;
		
	    
	    var selIndex = eval(strForm_City).selectedIndex;
		var CityId = eval(strForm_City).options[selIndex].value;		
		
		GetBrench( CityId, strForm_City, strForm_Branch )	
		
		
		eval(strForm_Branch).value = selected_branch_id;
	}
	

	function SetFormVariables(form_name , city_input, branch_input)
    {
	    // after search has been submitted
	    
	    strForm_City = 'document.' + form_name + '.' + city_input
	    strForm_Branch = 'document.' + form_name + '.' + branch_input
	}
    
    
    function submitForm ()
    {           
        if (document.getElementById("myname").value == "" )
        {
            alert ('יש להזין את השם שלך');
            document.getElementById("myname").focus();
            return false;
        }
        
        if (document.getElementById("myemail").value == "" )
        {
            alert ('יש להזין את המייל שלך');
            document.getElementById("myemail").focus();
            return false;
        }
        
        if (document.getElementById("1fname").value == "" )
        {
            alert ('יש להזין את שמו שלך החבר שלך');
            document.getElementById("1fname").focus();
            return false;
        }
        
        if (document.getElementById("1femail").value == "" )
        {
            alert ('יש להזין את המייל של החבר שלך');
            document.getElementById("1femail").focus();
            return false;
        }
        
        if (document.getElementById("cityi").value == "0" )
        {
            alert ('יש לבחור עיר');
            document.getElementById("cityi").focus();
            return false;
        }
        
        if (document.getElementById("brench").value == "0" )
        {
            alert ('יש לבחור סניף בו תערך הפגישה');
            document.getElementById("brench").focus();
            return false;
        }
        
        if (document.getElementById("start_min").value == "" )
        {
            alert ('יש לבחור שעת התחלה');
            document.getElementById("start_min").focus();
            return false;
        }
        
        if (document.getElementById("ADate").value == "" )
        {
            alert ('יש לבחור את תאריך הפגישה');
            document.getElementById("ADate").focus();
            return false;
        }
                     
    
        document.getElementById("op").value = 'submit';
        document.InviteForm.submit();        
    }

    function MakeZero (id)
    {
        if (document.getElementById(id).value == '')
        {
            document.getElementById(id).value = '00'
        }
    }

    function checkmin (obj)
    {
       
        if (parseInt (obj.value) < 10)
        {
            obj.value = '0' + parseInt (obj.value);
        }
        
        if (parseInt (obj.value) < 0)
        {
            obj.value = '00';
        }
        
        if (parseInt (obj.value) > 59)
        {
            obj.value = '59';
        }
    }
    
    function checkhr (obj)
    {
        if (parseInt (obj.value) < 10)
        {
            obj.value = '0' + parseInt (obj.value);
        }
        
        if (parseInt (obj.value) < 0)
        {
            obj.value = '00';
        }
        
        if (parseInt (obj.value) > 23)
        {
            obj.value = '23';
        }
    }

    function AddFriend ()
    {
        // get the Number of friends Counter + 1
        iFriendsCounter = parseInt(document.getElementById('FriendsCounter').value) + 1;
        
        // set friends Counter Input with +1
        document.getElementById('FriendsCounter').value = iFriendsCounter;
        
        // get Contents
        strTdContent  = document.getElementById('AddFriendTD').innerHTML;
        strDivContent = document.getElementById('AddFriendDiv').innerHTML;                
        
        // replace The Ids and names attributes
        strDivContent = strDivContent.replace(/fname/gi, "fname" + iFriendsCounter);
        strDivContent = strDivContent.replace(/femail/gi, "femail" + iFriendsCounter); 
        strDivContent = strDivContent.replace(/Fdiv/gi, "Fdiv" + iFriendsCounter);                
                
        
        var divTag = document.createElement("div");              
         
        divTag.innerHTML = strDivContent;

        document.getElementById("AddFriendTD").appendChild(divTag); 
        
    }
    
    // this function delete friend
    
    function rm (id)
    {
        document.getElementById(id).style.display='none';
        document.getElementById(id).innerHTML = '';
    } 

	
	// initialize img
	var facebox_img = new Image;
	facebox_img.src = 'images/pixel.gif';

	function OpenFacebox(file_name)
	{
		facebox_img.src = file_name;
		screen_height_left = screen.height-facebox_img.height;
		
		// if img too large for screen, display smaller
		if (screen_height_left < 340)
		{
			facebox_img.height = screen.height - 340;
		}
		
		document.getElementById('facebox_popup').style.top=0;
		jQuery.facebox('<img height=\' ' + facebox_img.height + ' \' src=\' ' + facebox_img.src + ' \'>');
	}
