// JavaScript Document

function request_content( url, request, responseHandler ){


	var postIt = new Object();
	
	postIt.ajax = true;
	postIt.lang = window.currentLanguage;
	
	postIt.what = request;
	HTTP.post( url, postIt, responseHandler, content_error );
	
}

function update_content( content, source ){
	//alert( content );
	
	var page = document.getElementById( "innerPart" );

	if( page && content  ){
		
		content = execute_scripts( content );
		//clear_animation();
		//window.currentAnimation = animate( page, 100, 5, FadeOut, show_content, content );
		
		page.innerHTML = "";
		page.innerHTML = content;
	}
	
	
}

function show_content( container, content ){
		container.innerHTML = "";
		container.innerHTML = content;
		
		animate( container, 50, 5, FadeIn, clear_animation );
}

function clear_animation(){

	clearInterval( window.currentAnimation  );
	window.currentAnimation = null;
	
}


function content_error(){
	alert( "Error Loading" );	
}

window.alertColor = "#7D8900";
window.standardColor = "#E6E6E6";

function get_field( fieldId ){
	var field = document.getElementById( fieldId );
	
	if( field ){
		if( field.value ){
			return field.value;	
		}else{
			return "";	
		};
	} 
	
	return "";
}

function mark_field( fieldId ){
	
	var field = document.getElementById( fieldId );
	
	if( field ){
		field.style.borderColor = window.alertColor;
		field.style.borderStyle = "solid";
		field.focus();
	} 
	
	return;
}

function unmark_field( fieldId ){
	
	var field = document.getElementById( fieldId );
	
	if( field ){
		field.style.borderColor = window.standardColor;
		field.style.borderStyle = "none";
	}
	
	return;
}

function send_form(){
	
	var status = document.getElementById( "sendResultBox" );
	
	if( status ){
		status.innerHTML = "";
	}
	
	var postIt = new Object();
	
	if( postIt.fullName = get_field( "fullName" ) ){
		unmark_field( "fullName" );	
	} else {
		mark_field( "fullName" );
		return;
	}

	if( postIt.eMail = get_field( "eMail" ) ){
		unmark_field( "eMail" );	
	} else {
		mark_field( "eMail" );
		return;
	}
	
	postIt.phone = get_field("phone");
	postIt.company = get_field("company");
	postIt.jobTitle = get_field("jobTitle");
	postIt.remarks = get_field("remarks");

var date=new Date();

	postIt.sid = date.getFullYear() - date.getMonth();
	

	HTTP.post( "Engine/ntSendMail.php", postIt, send_result, content_error );
	

	
}

function clear_field( fieldId ){
	var field = document.getElementById( fieldId );
	
	if( field ){
		field.value = "";
	}
	
	return;
}

function send_result( content, source ){
	
	var status = document.getElementById( "sendResultBox" );
	
	if( status ){
		if( content == "success" ){
			status.innerHTML = "נשלח !";
			clear_field( "fullName" );
			clear_field( "eMail" );
			clear_field( "phone" );
			clear_field( "company" );
			clear_field( "jobTitle" );
			clear_field( "remarks" );
		} else {
			status.innerHTML = "לא נשלח !";		
		}
	}
}
