

if (document.images) //check for browser support
{
    var popup1_img = new Image();
    popup1_img.src = 'images/popup1.png';
    
    var popup2_img = new Image();
    popup2_img.src = 'images/popup2.png';
    
    var popup3_img = new Image();
    popup3_img.src = 'images/popup3.png';
    
    var popup4_img = new Image();
    popup4_img.src = 'images/popup4.png';
    
    var popup5_img = new Image();
    popup5_img.src = 'images/popup5.png';
    
    var arrow_img = new Image();
    arrow_img.src = 'images/arrow_right.png';
}


function DisplayDiv2(id, state)
{
	if (state == 0)
	{
		document.getElementById(id).style.display='block';
	}
	else
	{
		document.getElementById(id).style.display='none';
	}
}

function MouseoverThis(id, state)
{
	//alert(id);
	if (state == 0)
	{
		document.getElementById(id).style.background='#ef853f';
		document.getElementById(id).style.color='#ffffff';
	}
	else
	{
		document.getElementById(id).style.background='transparent';
		document.getElementById(id).style.color='#00356c';
	}
}

function MouseoverThis2(id, id2, state)
{
	if (state == 0)
	{
		document.getElementById(id).style.background='#ccd7e2';
		document.getElementById(id2).style.color='#00356c';
	}
	else
	{
		document.getElementById(id).style.background='transparent';
		document.getElementById(id2).style.color='#f8f9f9';
	}
}

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 DisplayPopUpDiv(counter, drug_counter, popup_txt, drug_stage)
{
	var state = document.getElementById('popup_div' + counter).style.display;

	if (state != 'block')
	{
		document.getElementById('popup_div' + counter).style.display='block';
		document.getElementById('popup_div' + counter).style.top= drug_counter*30 - 27 + 'px';	
		document.getElementById('TXTpopup_div' + counter).innerHTML = popup_txt;
		document.getElementById('IMGpopup_div' + counter).style.background= "url('images/popup" + drug_stage + ".png')";
	}
	else
	{
		document.getElementById('popup_div' + counter).style.display='none';
	}
}

//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()
{
	var strSearchTerm = document.searchform.q.value
	
	if (strSearchTerm == "" || strSearchTerm == "search" )
	{
	    return;
	}
	
	//var strAction="default.asp?PageId=24&q=" + strSearchTerm + "&type=q"
	
	//location.href = strAction
	
	document.searchform.submit();
	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;
}

function SignUpNewsletter()
{
    
    if (  document.updates.updates_name.value == "" )
        {
           alert ( "Please enter name" );
		    updates.updates_name.focus()
            return false;
        }

    if (  document.updates.updates_email.value == "" )
        {
           alert ( "Please enter email" );
		    updates.updates_email.focus()
            return false;
        }	
    		
    	   
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(updates.updates_email.value)){

    document.updates.submit()
    return true;
    }
    alert("Invalid email")

    updates.updates_email.focus()
    return false;
}

// Contact form validation
function CheckContactForm()
{

if (  document.contact_form.contact_name.value == "" )
    {
       alert ( "Please enter name" );
		contact_form.contact_name.focus()
        return false;
    }

 if (  document.contact_form.contact_phone.value == "" )
    {
       alert ( "Please enter phone number" );
		contact_form.contact_phone.focus()
        return false;
    }
	
	
if (  document.contact_form.contact_email.value == "" )
    {
       alert ( "Please enter email" );
		contact_form.contact_email.focus()
        return false;
    }	
		
	   
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(contact_form.contact_email.value)){

document.contact_form.submit()
return true;
}
alert("Invalid email")

contact_form.contact_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; }
}



// set min-height because of background image gradient
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' )"
	}*/
}




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 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();        
    }

	
	// 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 + ' \'>');
	}

