function getObjectX(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
	while(1)
	 {
		curleft += obj.offsetLeft;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.x)
	curleft += obj.x;
	return curleft;
}
function getObjectY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
	while(1)
	{
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.y)
	curtop += obj.y;
	return curtop;
}
function getScrollX()
{
	var scrOfX = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfX = document.documentElement.scrollLeft;
	}
	return scrOfX;
}
function getScrollY()
{
	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}
function getPageWidth()
{
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		//myWidth = document.documentElement.clientWidth;
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}
function getPageHeight()
{
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		//myHeight = document.documentElement.clientHeight;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}
//==[ Page INI ]=================================================================================================================
function iniPage()
{
	/*
	if ( parseInt(navigator.appVersion) > 3 )
	{
		if ( navigator.appName=="Netscape" )
		{
			mainX = window.innerWidth / 2;
			mainY = window.innerHeight / 2;
		}
		if ( navigator.appName.indexOf("Microsoft") != -1 )
		{
			mainX = document.body.offsetWidth / 2;
			mainY = getScrollY() + document.body.offsetHeight / 2;
		}
	}
	*/
	mainX = getPageWidth() / 2;
	mainY = getPageHeight() / 2;
	//alert( getScrollY()+" | "+getPageHeight() )
	//mainY = getScrollY() + ( getPageHeight() / 2 );
}
function disableScrolling()
{
	document.body.style.overflow = "hidden";
}
function enableScrolling()
{
	document.body.style.overflow = "visible";
}
function form_product_search_submit()
{
	document.getElementById("form_product_search").submit();
}

function object_visibilityByTagNameAndClass(object_tagName,object_className)
{
	var content_array = window.document.getElementsByTagName(object_tagName);
	//alert(content_array.length);
	for(var i=0; i < content_array.length; i++)
	{
		if( content_array[i].className == object_className )
		{
			if( content_array[i].style.visibility != "hidden" )
			{
				
				content_array[i].style.visibility = "hidden";
				//content_array[i].style.display = "none";
			}
			else
			{
				content_array[i].style.visibility = "visible";
				//content_array[i].style.display = "";
			}
		}
	}
}

function popup(popup_containerId,popup_faderId)
{
	var popup_fader = document.getElementById(popup_faderId);
	var popup_container = document.getElementById(popup_containerId);
	if( popup_fader.style.display == "none" )
	{
		popup_fader.style.display = "";
		popup_container.style.display = "";
		
		// disable scrolling
		//disableScrolling();
		object_visibilityByTagNameAndClass("div","flash_content");
		
		popup_container_width = popup_container.clientWidth;
		popup_container_height = popup_container.clientHeight;
		
		popup_container_x = mainX - (popup_container_width / 2);
		popup_container_y = mainY - (popup_container_height / 2);
		
		popup_container.style.left = popup_container_x+"px";
		popup_container.style.top = popup_container_y+"px";
		
		//alert(popup_container_x+"|"+popup_container_y);
		//alert(popup_container.style.left+"|"+popup_container.style.top);
	}
	else
	{
		popup_fader.style.display = "none";
		popup_container.style.display = "none";
		// enable scrolling
		//enableScrolling();
		object_visibilityByTagNameAndClass("div","flash_content");
	}
}
function project_image_change(image_id)
{
	//var image_title = document.getElementById(project_imageTitleId);
	var image_small = document.getElementById(project_imageSmallId_prefix+image_id);
	var image_medium = document.getElementById(project_imageMediumId);
	var image_smallPrevious = document.getElementById(project_imageSmallId_prefix+project_imageSmallPreviousId);
	
	project_images[image_id][0] = project_images[image_id][0].replace("_","'");
	project_images[image_id][0] = project_images[image_id][0].replace("__","\"");
	
	project_imageSmallCorrentId = image_id;
	//image_title.innerHTML = project_images[image_id][0];
	image_small.className = "table_project_td_image_small_selected";
	if( image_id !=  project_imageSmallPreviousId )
	{image_smallPrevious.className = "table_project_td_image_small"}
	
	//image_medium.style.backgroundImage = "url('pictures/"+project_images[image_id][2]+"')";
	image_medium.src = "pictures/"+project_images[image_id][2]+"";
	image_medium.title = project_images[image_id][0];
	image_medium.alt = project_images[image_id][0];
	project_imageSmallPreviousId = image_id;
}
function project_image_change2(operator)
{
	if( operator == "+" )
	{
		if( project_imageSmallCorrentId == project_imageMaxId )
		{
			project_imageSmallCorrentId = 0;
		}
		else
		{
			project_imageSmallCorrentId++;
		}
		project_image_change(project_imageSmallCorrentId)
	}
	else if( operator == "-" )
	{
		if( project_imageSmallCorrentId == 0 )
		{
			project_imageSmallCorrentId = project_imageMaxId;
		}
		else
		{
			project_imageSmallCorrentId--;
		}
		project_image_change(project_imageSmallCorrentId)
	}
}
function string_unique()
{
	string_date = new Date();
	string = string_date.getFullYear()+""+string_date.getMonth()+""+string_date.getDate()+""+string_date.getHours()+""+string_date.getMinutes()+""+string_date.getSeconds()+""+string_date.getTime();
	return(string);
}

var ajax_poll_vote_connection = new XHConn();
var ajax_poll_vote_requestInProcess = false;
var ajax_poll_vote_response;

var ajax_contact_send_connection = new XHConn();
var ajax_contact_send_requestInProcess = false;
var ajax_contact_send_response;

function ajax_poll_vote_sendRequest(poll_params)
{
	var poll_form_container = document.getElementById("poll_form_container");
	var poll_message_container = document.getElementById("poll_message_container");
	var poll_loader_container = document.getElementById("poll_loader_container");
	if( !ajax_poll_vote_requestInProcess )
	{
		ajax_poll_vote_requestInProcess = true;
		poll_form_container.style.display = "none";
		poll_message_container.style.display = "none";
		poll_loader_container.style.display = "block";
		document.body.style.cursor="wait";
		ajax_cache = string_unique();
		var sDataPath = "ajax_poll_submit.php";
		ajax_poll_vote_connection.connect(sDataPath, "POST", "ajaxCache="+ajax_cache+"&poll_fullname="+poll_params[0]+"&rate_site="+poll_params[1]+"&rate_sales_man="+poll_params[2]+"&rate_setups="+poll_params[3]+"&rate_client_service="+poll_params[4]+"&rate_global_service="+poll_params[5]+"&comments="+poll_params[6], ajax_poll_vote_getResponse, false);
	}
}
function ajax_poll_vote_getResponse(ajax_poll_vote_response)
{
	var poll_form_container = document.getElementById("poll_form_container");
	var poll_message_container = document.getElementById("poll_message_container");
	var poll_loader_container = document.getElementById("poll_loader_container");
	var poll_submit_status = document.getElementById("poll_submit_status");
	if(ajax_poll_vote_response.readyState == 4)
	{
		vote_response_submit_status = ajax_poll_vote_response.responseText;
		switch(vote_response_submit_status)
		{
			case("0"):
			{
				poll_form_container.style.display = "none";
				poll_message_container.style.display = "block";
				poll_loader_container.style.display = "none";
				poll_submit_status.innerHTML = poll_message_0;
				break;
			}
			case("1"):
			{
				poll_form_container.style.display = "none";
				poll_message_container.style.display = "block";
				poll_loader_container.style.display = "none";
				//poll_submit_status.innerHTML = poll_message_1;
				break;
			}
			case("2"):
			{
				poll_form_container.style.display = "none";
				poll_message_container.style.display = "block";
				poll_loader_container.style.display = "none";
				poll_submit_status.innerHTML = poll_message_2;
				break;
			}
			case("3"):
			{
				poll_form_container.style.display = "none";
				poll_message_container.style.display = "block";
				poll_loader_container.style.display = "none";
				poll_submit_status.innerHTML = poll_message_3;
				break;
			}
			case("4"):
			{
				poll_form_container.style.display = "none";
				poll_message_container.style.display = "block";
				poll_loader_container.style.display = "none";
				poll_submit_status.innerHTML = poll_message_4;
				break;
			}
			default:break;
		}
	}
	document.body.style.cursor="default";
	ajax_poll_vote_requestInProcess = false;
	return void(0);
}

function ajax_contact_send_sendRequest(contact_params)
{
	var contact_form_container = document.getElementById("contact_form_container");
	var contact_message_container = document.getElementById("contact_message_container");
	var contact_loader_container = document.getElementById("contact_loader_container");
	if( !ajax_contact_send_requestInProcess )
	{
		ajax_contact_send_requestInProcess = true;
		contact_form_container.style.display = "none";
		contact_message_container.style.display = "none";
		contact_loader_container.style.display = "block";
		document.body.style.cursor="wait";
		ajax_cache = string_unique();
		var sDataPath = "ajax_contact_submit.php";
		ajax_contact_send_connection.connect(sDataPath, "POST", "ajaxCache="+ajax_cache+"&fullname="+contact_params[0]+"&area="+contact_params[1]+"&product="+contact_params[2]+"&phone="+contact_params[3]+"&phone_prefix="+contact_params[4]+"&comments="+contact_params[5]+"&email="+encodeURI(contact_params[6]), ajax_contact_send_getResponse, false);
	}
}
function ajax_contact_send_getResponse(ajax_contact_send_response)
{
	var contact_form_container = document.getElementById("contact_form_container");
	var contact_message_container = document.getElementById("contact_message_container");
	var contact_loader_container = document.getElementById("contact_loader_container");
	
	var contact_fullname = document.getElementById("contact_fullname");
	var contact_fullname_field = document.getElementById("contact_fullname_field");
	//var contact_request_code_field = document.getElementById("contact_request_code_field");
	
	if(ajax_contact_send_response.readyState == 4)
	{
		contact_response = ajax_contact_send_response.responseText;
		if( contact_response != "false" )
		{
			contact_form_container.style.display = "none";
			contact_message_container.style.display = "block";
			contact_loader_container.style.display = "none";
			contact_fullname_field.innerHTML = contact_fullname.value;
			//contact_request_code_field.innerHTML = contact_response;
		}
		else
		{
			
		}
	}
	document.body.style.cursor="default";
	ajax_contact_send_requestInProcess = false;
	return void(0);
}

function form_poll_submit()
{
	//var poll_request_code = document.getElementById("poll_request_code");
	var poll_fullname = document.getElementById("poll_fullname");
	var poll_rate_site = document.getElementsByName("poll_rate_site");
	var poll_rate_sales_man = document.getElementsByName("poll_rate_sales_man");
	var poll_rate_setups = document.getElementsByName("poll_rate_setups");
	var poll_rate_client_service = document.getElementsByName("poll_rate_client_service");
	var poll_rate_global_service = document.getElementsByName("poll_rate_global_service");
	var poll_comments = document.getElementById("poll_comments");
	
	if ( poll_fullname.value == "" )
	{
		alert("חובה לציין שם");
		poll_fullname.focus();
		return false;
	}
	/*
	if ( poll_request_code.value.length < 9 )
	{
		alert("קוד פנייה אינו תקין - קוד פנייה מכיל 9 ספרות");
		poll_request_code.focus();
		return false;
	}
	*/
	poll_params = new Array();
	//poll_params[0] = poll_request_code.value;
	poll_params[0] = poll_fullname.value;
	
	for(var i=0; i < poll_rate_site.length; i++)
	{
		if( poll_rate_site[i].checked)
		{
			poll_params[1] = poll_rate_site[i].value;
			break;
		}
	}
	for(var i=0; i < poll_rate_sales_man.length; i++)
	{
		if( poll_rate_sales_man[i].checked)
		{
			poll_params[2] = poll_rate_sales_man[i].value;
			break;
		}
	}
	for(var i=0; i < poll_rate_setups.length; i++)
	{
		if( poll_rate_setups[i].checked)
		{
			poll_params[3] = poll_rate_setups[i].value;
			break;
		}
	}
	for(var i=0; i < poll_rate_client_service.length; i++)
	{
		if( poll_rate_client_service[i].checked)
		{
			poll_params[4] = poll_rate_client_service[i].value;
			break;
		}
	}
	for(var i=0; i < poll_rate_global_service.length; i++)
	{
		if( poll_rate_global_service[i].checked)
		{
			poll_params[5] = poll_rate_global_service[i].value;
			break;
		}
	}
	poll_params[6] = poll_comments.value;
	ajax_poll_vote_sendRequest(poll_params);
	//document.getElementById("form_poll").submit();
}
function form_contact_submit()
{
	var contact_fullname = document.getElementById("contact_fullname");
	var contact_email = document.getElementById("contact_email");
	var contact_area = document.getElementById("contact_area");
	var contact_product = document.getElementById("contact_product");
	var contact_phone = document.getElementById("contact_phone");
	var contact_phone_prefix = document.getElementById("contact_phone_prefix");
	var contact_comments = document.getElementById("contact_comments");
	if ( contact_fullname.value.length == 0 )
	{
		alert("חובה למלא שם");
		contact_fullname.focus();
		return false;
	}
	if ( contact_area.value.length == 0 )
	{
		alert("חובה לבחור אזור");
		contact_area.focus();
		return false;
	}
	/*
	if ( contact_product.value.length == 0 )
	{
		alert("חובה לבחור מוצר");
		contact_product.focus();
		return false;
	}
	*/
	if ( contact_phone.value.length == 0 )
	{
		alert("חובה למלא מס' טלפון");
		contact_phone.focus();
		return false;
	}
	if(contact_email.value.length != 0)
	{
		var regExp_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if( !regExp_email.test(contact_email.value) )
		{
			alert("מייל לא תקין");
			contact_email.focus();
			return false;
		}
		else if( contact_email.value.indexOf("@") != contact_email.value.lastIndexOf("@") )
		{
			alert("מייל לא תקין");
			contact_email.focus();
			return false;
		}
		
	}
	contact_params = new Array();
	contact_params[0] = contact_fullname.value;
	contact_params[1] = contact_area.value;
	contact_params[2] = contact_product.value;
	contact_params[3] = contact_phone.value;
	contact_params[4] = contact_phone_prefix.value;
	contact_params[5] = contact_comments.value;
	contact_params[6] = contact_email.value;
	ajax_contact_send_sendRequest(contact_params);
	//document.getElementById("form_contact").submit();
}



var mainX,mainY;
iniPage();








