﻿
function Moredetails(tagName,tblName)
{
	document.getElementById(tagName).style.display=(document.getElementById(tagName).style.display=='none'?'inline':'none');
	document.getElementById(tblName).style.backgroundColor = '#fff'; 

	if (document.getElementById(tagName).style.display=='inline'){
	document.getElementById(tblName).style.backgroundColor = '#e4eef8';
	}
}

function Lessdetails(tagName,tblName)
{
	document.getElementById(tagName).style.display=(document.getElementById(tagName).style.display=='none'?'inline':'none');
	document.getElementById(tblName).style.backgroundColor = '#fff'; 
	if (document.getElementById(tagName).style.display=='none'){
	//	document.getElementById(tagName+'A').innerHTML = '��� ����';
	} else {
	//	document.getElementById(tagName+'A').innerHTML = '����';
	}
}

function popup(id)
{
	window.open(""+id, "_blank","toolbar=no, titlebar=no, fullscreen=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=700, height=400")
}

function popup500(id)
{
	window.open(""+id, "_blank","toolbar=no, titlebar=no, fullscreen=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=750, height=520")
}
function popup650(id)
{
	window.open(""+id, "_blank","toolbar=no, titlebar=no, fullscreen=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=680, height=680")
}

function changePicSrc(itemId,picSrc)
{
document.getElementById(itemId).src=picSrc;	
}

function changeBackground(itemId,backColor)
{
document.getElementById(itemId).style.backgroundColor=backColor;		
}


function changeBigImg(imgSrc)
{
document.getElementById("largeImg").src="images/upload/exhibitions/" + imgSrc
}

function deliverActiveX(content)
{
	document.write(content);	
}




var lastItemOpened = '0';
function doToggle(itemId) {
	textItemSp=document.getElementById("spans_" + itemId);
	headerObj=document.getElementById("header_" + itemId);

	if (itemId == lastItemOpened) {
		textItemSp.style.display="none";
		headerObj.style.backgroundImage="url(images/questionBack.jpg)"
		lastItemOpened = '0';
	} else {
		if (lastItemOpened != '0') {
			textItemSpOld=document.getElementById("spans_" + lastItemOpened);
			headerObjOld=document.getElementById("header_" + lastItemOpened);
			headerObjOld.style.backgroundImage="url(images/questionBack.jpg)"
			textItemSpOld.style.display="none";
		}
		lastItemOpened = itemId;
		headerObj.style.backgroundImage="url(images/questionBackOver.jpg)"
		textItemSp.style.display = "";
	}

}






// functions for calculator module
function numbersOnlyForCalculator(itemId)
{
num=document.getElementById(itemId).value;	
	if (isNaN(num)==true)
	{
		document.getElementById('assetValue').value="";
		alert ("ספרות בלבד בשדה זה")
		
	}
}

function calculate(reactionStyle)
{
varAssetValue=document.getElementById("assetValue").value
varBirthYear=document.getElementById("birthYear").value
varBirthMonth=document.getElementById("birthMonth").value
varBirthDay=document.getElementById("birthDay").value
var theDate=new Date();


		if (varBirthYear=="" || varBirthMonth=="" || varBirthDay=="")
		{
		alert("נא להקליד תאריך לידה תקני")
		}


		else if (varAssetValue=="")
		{
		alert("נא להקליד ערך כלשהו לנכס")
		}

		else if (isNaN(varAssetValue)==true)
		{
		document.getElementById("assetValue").value="";
		alert ("יש להזין ספרות בלבד בשדה שווי הנכס")		
		}

		else if (varAssetValue<300000)
		{
		alert ("שווי הנכס חייב להיות גבוה מ-300,000 שקלים")		
		}

		else if (varAssetValue>4000000)
		{
		alert ("יש לפנות לחברה")		
		}


		else
		{
	
				// get exact age		
				tempYear=theDate.getFullYear()-varBirthYear
				tempMonth=theDate.getMonth()+1

				if (varBirthMonth>tempMonth)
				{
				tempMonth=(varBirthMonth-tempMonth)/12
				age=tempYear-tempMonth
				}
				else if (varBirthMonth==tempMonth)
				{
				age=tempYear
				}
				else if (varBirthMonth<tempMonth)
				{
				tempMonth=(tempMonth-varBirthMonth)/12
				age=tempYear+tempMonth
				}

				// check age by range
				if (age<=60.5)
				{
				loanPrecent=15.01
				}
				else if (age>60.5 && age<=61.5)
				{
				loanPrecent=15.92
				}
				else if (age>61.5 && age<=62.5)
				{
				loanPrecent=16.88
				}
				else if (age>62.5 && age<=63.5)
				{
				loanPrecent=17.88
				}
				else if (age>63.5 && age<=64.5)
				{
				loanPrecent=18.94
				}
				else if (age>64.5 && age<=65.5)
				{
				loanPrecent=20.04
				}
				else if (age>65.5 && age<=66.5)
				{
				loanPrecent=21.19
				}
				else if (age>66.5 && age<=67.5)
				{
				loanPrecent=22.40
				}
				else if (age>67.5 && age<=68.5)
				{
				loanPrecent=23.67
				}
				else if (age>68.5 && age<=69.5)
				{
				loanPrecent=24.73
				}
				else if (age>69.5 && age<=70.5)
				{
				loanPrecent=25.85
				}
				else if (age>70.5 && age<=71.5)
				{
				loanPrecent=27.03
				}
				else if (age>71.5 && age<=72.5)
				{
				loanPrecent=28.25
				}
				else if (age>72.5 && age<=73.5)
				{
				loanPrecent=29.53
				}
				else if (age>73.5 && age<=74.5)
				{
				loanPrecent=30.87
				}
				else if (age>74.5 && age<=75.5)
				{
				loanPrecent=32.27
				}
				else if (age>75.5 && age<=76.5)
				{
				loanPrecent=33.73
				}
				else if (age>76.5 && age<=77.5)
				{
				loanPrecent=35.26
				}
				else if (age>77.5 && age<=78.5)
				{
				loanPrecent=36.86
				}
				else if (age>78.5 && age<=79.5)
				{
				loanPrecent=38.52
				}
				else if (age>79.5 && age<=80.5)
				{
				loanPrecent=40.24
				}
				else if (age>80.5 && age<=81.5)
				{
				loanPrecent=42.02
				}
				else if (age>81.5 && age<=82.5)
				{
				loanPrecent=43.84
				}
				else if (age>82.5 && age<=83.5)
				{
				loanPrecent=45.70
				}
				else if (age>83.5 && age<=84.5)
				{
				loanPrecent=47.59
				}
				else if (age>84.5 && age<=85.5)
				{
				loanPrecent=49.25
				}
				else if (age>85.5)
				{
				loanPrecent=50
				}

				
				// print loan high
				loanHigh=Math.round(varAssetValue*loanPrecent/100)
				if (loanHigh>4000000)
				{
				loanHigh=4000000
				}

				if (reactionStyle=="alertFormat")
				alert ("שווי ההלוואה לה הנכם זכאים: " +loanHigh + " שקלים")
				else if (reactionStyle=="innerFormat")
				document.getElementById("whatLoanHigh").innerHTML=loanHigh


		}

}






function sendForm()
{
	
		if (document.getElementById("fname").value == "")
		{
           document.getElementById('fname').focus();
		   document.getElementById('errorPlace').innerHTML="אנא מלא שם"		
		}
		
		else if (document.getElementById("phone").value == "")
		{
           document.getElementById('phone').focus();
		   document.getElementById('errorPlace').innerHTML="אנא מלא טלפון"		
		}
				
		else
		{
		sendMail()
		}
			
}



    function sendMail() {
        var xmlHttp;
        try {
            xmlHttp=new XMLHttpRequest();    
        } catch (e) {
            try {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
            } catch (e) {
                try {
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                } catch (e) {
                    alert("Your browser does not support AJAX!");        
                    return false;
                }
            }
        }
            
        xmlHttp.onreadystatechange=function()
		{
            if(xmlHttp.readyState==4)
			{
			document.getElementById("fname").value=""
			document.getElementById("phone").value=""
			document.getElementById("city").value=""
			document.getElementById("message").innerHTML=""
			document.getElementById('errorPlace').innerHTML="טופס נשלח בהצלחה"		
            }
        }
            
        var url="contact/moduleContact.asp";
		var fname=document.getElementById("fname").value
		var phone=document.getElementById("phone").value
		var city=document.getElementById("city").value
		var message=document.getElementById("message").innerHTML
		message=message.replace(/\n/g, "<br />")

        url=url+"?fname="+fname+"&phone="+ phone+"&city="+ city+"&message="+ message;

        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);  
    }



    function handleFontSize(whatAction) {

        var xmlHttp;
        try {
            xmlHttp=new XMLHttpRequest();    
        } catch (e) {
            try {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
            } catch (e) {
                try {
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                } catch (e) {
                    alert("Your browser does not support AJAX!");        
                    return false;
                }
            }
        }
            
        xmlHttp.onreadystatechange=function()
		{
            if(xmlHttp.readyState==4)
			{
			var pxFontSize=xmlHttp.responseText;
			
				if (pxFontSize=="12px")
				{
				document.getElementById("minusImg").style.opacity="0.1";
				document.getElementById("minusImg").style.filter="alpha(opacity=10)";
				document.getElementById("plusImg").style.opacity="10";
				document.getElementById("plusImg").style.filter="alpha(opacity=100)";	
				document.getElementById("minusLinkTag").style.cursor="default";
				document.getElementById("plusLinkTag").style.cursor="pointer";
				}
				else if (pxFontSize=="16px")
				{
				document.getElementById("minusImg").style.opacity="1";
				document.getElementById("minusImg").style.filter="alpha(opacity=100)";
				document.getElementById("plusImg").style.opacity="0.1";
				document.getElementById("plusImg").style.filter="alpha(opacity=10)";
				document.getElementById("plusLinkTag").style.cursor="default";
				document.getElementById("minusLinkTag").style.cursor="pointer";
				}
				else
				{
				document.getElementById("minusImg").style.opacity="1";
				document.getElementById("minusImg").style.filter="alpha(opacity=100)";
				document.getElementById("plusImg").style.opacity="1";
				document.getElementById("plusImg").style.filter="alpha(opacity=100)";
				document.getElementById("plusLinkTag").style.cursor="pointer";
				document.getElementById("minusLinkTag").style.cursor="pointer";	
				}
			
			declareFontSizeOnPage(pxFontSize)			
            }
        }
          
		tempWhatAction=whatAction 
        var url="changeFontSize.asp?whatAction=" + tempWhatAction;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);  

    }


function declareFontSizeOnPage(pxFontSize)
{

		var obj=document.getElementsByTagName("div")
		for (var i=0; i<obj.length; i++)
		{
		if (obj[i].getAttribute("title") && obj[i].getAttribute("title")=="resizeFont")
			{ 
			obj[i].style.fontSize=pxFontSize;
			}
		}

		var obj=document.getElementsByTagName("span")
		for (var i=0; i<obj.length; i++)
		{
		if (obj[i].getAttribute("title") && obj[i].getAttribute("title")=="resizeFont")
			{ 
			obj[i].style.fontSize=pxFontSize;
			}
		}

		var obj=document.getElementsByTagName("a")
		for (var i=0; i<obj.length; i++)
		{
		if (obj[i].getAttribute("title") && obj[i].getAttribute("title")=="resizeFont")
			{ 
			obj[i].style.fontSize=pxFontSize;
			}
		}


}



function changePicSrc(itemId,picSrc)
{
document.getElementById(itemId).src=picSrc;	
}
