// lets load up our javascripts

$(document).ready(function() {
	ddsmoothmenu.init({
		mainmenuid: "scmMenu", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'scmMenu', //class added to menu's outer DIV
		//customtheme: ["#1c5a80", "#18374a"],
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})
});

function cngsrc(src, obj)
{
	var lbref = document.getElementById('lbref');
	var lbimg = document.getElementById('lbimg');
	var oldsrc = lbimg.src;
	
	obj.src = oldsrc;
	lbref.href = src;
	lbimg.src = src;
}

function opnWin(url, title, width, height)
{
	window.open (url,title,"width="+width+", height="+height);
}

function ajaxObject()
{
	var obj = null;
	
	if (window.XMLHttpRequest)
	{
		obj = new XMLHttpRequest;
		return obj;
	} 
	
	if (window.ActiveXObject)
	{
		obj = new ActiveXObject("Microsoft.XMLHTTP");
		return obj;
	}else
	if (window.ActiveXObject)
	{
		obj = new ActiveXObject("Microsoft.XMLHTTP") || new ActiveXObject("Msxml2.XMLHTTP");
		return obj;
	}
}

function homeContact()
{
	var name = document.getElementById('form_name').value;
	var phone = document.getElementById('form_phone').value;
	var mail = document.getElementById('form_mail').value;
	var cont = document.getElementById('form_cont').value;
	
	if (name == '' || phone == '')
	{
		document.getElementById('form_name').style.backgroundColor='#fff3f3';
		document.getElementById('form_phone').style.backgroundColor='#fff3f3';
	}
	else
	{
		var xhr = new ajaxObject();
	
		var url = "contact.php";
		var params = "do=homeSend&name="+name+"&phone="+phone+"&mail="+mail+"&content="+cont;
		xhr.open("POST", url, true);

		//Send the proper header information along with the request
		xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr.setRequestHeader("Content-length", params.length);
		xhr.setRequestHeader("Connection", "close");

		xhr.onreadystatechange = function() {//Call a function when the state changes.
			if(xhr.readyState == 4 && xhr.status == 200) {
				document.getElementById('fastCont').innerHTML = xhr.responseText;
			}
		}

		xhr.send(params);
	}
}

