var myimages=new Array();

function PreImages()
{
	for (i=0;i<PreImages.arguments.length;i++)
	{
		myimages[i]=new Image()
		myimages[i].src=PreImages.arguments[i]
	}
}

function Jump(url)
{
	top.location.href = url
}

function AddToFavorites()
{
	//url = "http://www.artisansonics.com"
	url = location.href
	name = "Artisan Sonics"
	
	if (window.external || window.opera)  // IE
	    window.external.AddFavorite(url, name);
	else if (window.sidebar)  // Mozilla Firefox
    	window.sidebar.addPanel(name, url, "");
	else 
	    alert('not supported');
}

function SendToFriend()
{
	if (document.getElementById("friend").innerHTML != "")
	{
		document.getElementById("friend").innerHTML = ""
		return;
	}
	
	t = "<table class='friend'>";
	t += "<tr><td>Your name:</td><td><input size='10' id='friend_from'/></td></tr>"
	t += "<tr><td>Friend's name:</td><td><input size='10' id='friend_name'/></td></tr>";
	t += "<tr><td>Friend's mail:</td><td><input size='16' id='friend_mail'/></td></tr>";
	t += "<tr valign='top'><td><button onclick='MailToFriend()' id='btnFriendSend' class='defualty'><img src='app_images/mail.gif' class='button'/>&nbsp;Send</button></td><td><div id='friendError' class='defualty'></td></tr>"
	t += "</table>";
	document.getElementById("friend").innerHTML = t;	
}

function MailToFriend()
{
	var err = ""
	
	var from = document.getElementById("friend_from").value
	if (from == "")
		err = "<b>your</b> Name<br>"
		
	var name = document.getElementById("friend_name").value
	if (name == "")
		err += "<b>friend's</b> Name<br>"

	var mail = document.getElementById("friend_mail").value
	if (mail == "")
		err += "valid <b>email</b> address<br>"

	if (err != "")
	{
		err = err.substr(0, err.length - 4)
		err = "Please Insert:<br>" + err
		document.getElementById("friendError").innerHTML = "<font color='red'>"+err+"</font>"
		return;
	}
	SendMessageToFriend(from, name, mail)
}

function SendMessageToFriend(from, name, mail)
{
	document.getElementById("btnFriendSend").disabled=true
	elem = document.getElementById("friendError");
	
	elem.innerHTML = "Please Wait...";
	url = location.href
	param = "?friend=1&from="+from+"&name="+name+"&mail="+mail+"&url="+url
	Ajax("mail.php", param, "friendError", "btnFriendSend", "friend")	
}

function GetXmlHttpObject()
{
	var xmlhttp = null;
    // Internet Explorer    
	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") }
    catch (e)
    {
		try
	    {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");        
		}
	    catch (e)
	    {
    	  	try
		    {    // Firefox, Opera 8.0+, Safari
			    xmlhttp=new XMLHttpRequest();    
			}
		    catch (e)
		    {
		        alert("Your browser does not support AJAX!");        
				return false;
			}
		}      
	}
	return 	xmlhttp;
}

function Ajax(url, param, id, btnID, divClose) 
{
	xmlhttp =  GetXmlHttpObject(); 
	url = url + param;
	xmlhttp.open("GET", url);

	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && (id != null)) 
		{
			if (id != null)
			{
				var text = xmlhttp.responseText;
				document.getElementById(id).innerHTML = text;
			}
			if (btnID != null)
			{
				if (divClose)
				{
					document.getElementById(btnID).innerHTML = "Close"
					document.getElementById(btnID).onclick = function(){document.getElementById(divClose).innerHTML=""}
				}
				document.getElementById(btnID).disabled = false;
			}
//			document.getElementById("imgSend").src = "images/maily_big.gif"
		}
	}
	xmlhttp.send(null);
}
