// JavaScript Document


// mini ajax URL, PARAM, ELEMENT, METHOD if(c){cb(c);}

function b(l,d,u,c){
	try{
		r = new XMLHttpRequest()
	} catch(e){
	try {
		r = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		 r = new ActiveXObject('Microsoft.XMLHTTP'); }
	}

	if(r){
	r.onreadystatechange = function() {
		if (r.readyState == 4 && r.status == 200) document.getElementById(u).innerHTML = r.responseText;
		if(c){cb(c);}
		
	}
		r.open('POST', l, true);
		r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		r.send(d);
	}
}


function cb(callbackString) {
	if(callbackString.indexOf('(')==-1) { callbackString = callbackString + '()'; }
	try{ eval(callbackString) }catch(e){ }
}

function gEBI(name){
	return document.getElementById(name);
}

function val(elid){
	return gEBI(elid).value;
}


var hideContact = function(){ gEBI("contact").style.height="1px"; gEBI("contactFinished").style.display = "none"; }
var finish = function(){  gEBI("contact").style.height="80px";gEBI("contactInner").style.display = "none"; gEBI("contactFinished").style.display = "block";  setTimeout ('hideContact()', 2500); }

var int = function(){
	var contactbox = gEBI("contact");
	var contactInner = gEBI("contactInner");
	gEBI("contactBtn").onclick = function(){
		if(parseFloat(contactbox.style.height) < 10){
			contactbox.style.height = "280px";
			contactInner.style.display = "";
			
		} else {
			contactbox.style.height = "1px";
			contactInner.style.display = "none";
		}
	}
	
	gEBI("contact-cancel").onclick = function(){
			contactbox.style.height = "1px";
			contactInner.style.display = "none";
	}

	gEBI("contact-send").onclick = function(){
			var name = val("contact-name")
			var email = val("contact-email")
			var comment = val("contact-comment");
			if(name != '' && email != '' && comment != ''){
				b("http://sellerbyte.net/ajax/contact.php","n="+name+"&e="+email+"&c="+comment+"","loader", "finish()");
			}
			//contactbox.style.height = "1px";
			//contactInner.style.display = "none";
	}


	

}


window.attachEvent ? window.attachEvent("onload", int) : window.onload=int;


