function ReplaceAll(Source,stringToFind,stringToReplace)
{
  var temp = Source;
    var index = temp.indexOf(stringToFind);
        while(index != -1)
		{
            temp = temp.replace(stringToFind,stringToReplace);
            index = temp.indexOf(stringToFind);
        }
        return temp;
}


function decode_heburl(url) 
{
   var newUrl = url;
    if( url == '' ) return;
    var urlhebdecode = new Array ("%D7%90", "%D7%91", "%D7%92", "%D7%93", "%D7%94", "%D7%95", "%D7%96", "%D7%97", "%D7%98", "%D7%99", "%D7%9B", "%D7%9C", "%D7%9E", "%D7%A0", "%D7%A1", "%D7%A2", "%D7%A4", "%D7%A6", "%D7%A7", "%D7%A8", "%D7%A9", "%D7%AA", "%D7%9F", "%D7%9D", "%D7%9A", "%D7%A3", "%D7%A5");
    var urlheb = new Array ( 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק', 'ר', 'ש', 'ת', 'ן', 'ם', 'ך', 'ף', 'ץ' );
	var newUrl = url;
	var i=0;
	for (; i < 27 ; i++)
	{
		newUrl = ReplaceAll(newUrl,urlheb[i], urlhebdecode[i]);

	}
    return newUrl;
} 

function OpenWindow(mypage,myname,w,h,scroll)
{
	var pos="center";
	var LeftPosition;
	var TopPosition;
	if (typeof pos == 'undefined') pos='center';
	if (typeof scroll == 'undefined') scroll='auto';
	if(pos=="random")
	{
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="center")
	{
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	else if((pos!="center" && pos!="random") || pos==null)
	{
		LeftPosition=0;TopPosition=20
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
}


function MapPopup(a,c)
{
	var url = decode_heburl("map.php?city="+c+"&address="+a);
	OpenWindow(url,'',670,500,'yes')	
}

function sendContact()
{
	name = document.minisiteLead.name.value;
	phone = document.minisiteLead.phone.value;
	email = document.minisiteLead.email.value;
	toEmail = document.minisiteLead.toEmail.value;
	document.getElementById("minisiteLeadForm").innerHTML ="sendContact.php?name=" + name + "&email=" + email + "phone=" + phone+ "toEmail="+toEmail;
	//gadgets.io.makeRequest("sendContact.php?name=" + name + "&email=" + email + "phone=" + phone+ "toEmail="+toEmail);
}

function OpenCloseDiv3(a, b,d,e,f) 
{
     if (document.getElementById(a).style.display=='none')
     {
       
        document.getElementById(a).style.display='block';
        document.getElementById(b).src="pam.php?city=" + d + "&Address=" + e;
        if (f=='yes')
        {
        //document.getElementById(c).src='images\\map_close.jpg';
        }
        else
        {
       // document.getElementById(c).src='images\\map_close.gif';
        }
        
        
       
        
    }

    else
    {
        document.getElementById(a).style.display='none';
        if (f=='yes')
        {
            document.getElementById(c).src='images\\map.jpg';
        }
        else
        {
            document.getElementById(c).src='images\\map.gif';
        }
        
        }
}
