/* ----------------------------------------------------------------------------------------
File Name: General_Functions.js

	This file handles general functions.
 ----------------------------------------------------------------------------------------*/

var aImages = new Array('hp-submenu-dgamim','hp-submenu-traidIn','hp-submenu-mimun','hp-submenu-halafim','hp-submenu-whySubaru','hp-submenu-links');
var aImages2 = new Array('hp-submenu2-imprezaNewAge','hp-submenu2-imprezaTurbo','hp-submenu2-B4','hp-submenu2-forest','hp-submenu2-outBack');

function OverIt(El)
{
	/*if(El.id == "CarYad2" || El.id == "CompanyProfile" || El.id == "Avizar" || El.id == "Contact" || El.id == "Sale")
		hideMenu()*/
	//alert(El.id.substring(0,6))
	//if(El.id.substring(0,6) != "Subaru" || El.id.substring(0,6) != "subaru")
		//hideMenu()
	//if(El.id != "Subaru")
	{
		El.src = "../../images/" + El.id + "_Over" + ".gif";
		El.style.cursor = "hand";
	}
	/*if(El.id == "Subaru")
		fnShowSubaruMenu(El)*/
}
function OutIt(El)
{
	//if(El.id != "Subaru")
	{
		El.src = "../../images/" + El.id + "_Normal" + ".gif";
		El.style.cursor = "auto";
	}
	/*else
		fnHideSubaruMenu(El);*/
}

function OverItHomePage(El)
{
	/*if(El.id == "CarYad2" || El.id == "CompanyProfile" || El.id == "Avizar" || El.id == "Contact" || El.id == "Sale")
		hideMenu()*/
	//alert(El.id.substring(0,6))
	//if(El.id.substring(0,6) != "Subaru" || El.id.substring(0,6) != "subaru")
		//hideMenu()
	//if(El.id != "Subaru")
	{
		El.src = "images/" + El.id + "_Over" + ".gif";
		El.style.cursor = "hand";
	}
	/*if(El.id == "Subaru")
		fnShowSubaruMenu(El)*/
}
function OutItHomePage(El)
{
	//if(El.id != "Subaru")
	{
		El.src = "images/" + El.id + "_Normal" + ".gif";
		El.style.cursor = "auto";
	}
	/*else
		fnHideSubaruMenu(El);*/
}
//---------- SUBARU MENU FUNCTIONS -----------------
function fnShowSubaruMenu(El)
{
	document.all.divSubaruMenu.style.display = "block";
}

function fnHideSubaruMenu(El)
{
	if(window.event.srcElement.id != "subaru_menu_open_1")
	{
		document.all.divSubaruMenu.style.display = "none";
		document.all.divSubaruSubMenu.style.display = "none";
	}
}
function fnShowSubaruSubMenu(El)
{
	document.all.divSubaruSubMenu.style.display = "block";
}

function fnHideSubaruSubMenu(El)
{
	/*if(window.event.toElement.id.indexOf("subaru_submenu_open_") == -1)
	{
		document.all.divSubaruSubMenu.style.display = "none";
		if(!window.event.toElement.id || window.event.toElement.id == "")
		{
			document.all.divSubaruMenu.style.display = "none";
			document.all("Subaru").src = "../../images/" + document.all("Subaru").id + "_Normal" + ".gif";
			document.all("Subaru").style.cursor = "auto";
		}
		OutIt(document.all("subaru_menu_open_1"));
	}	*/
}

// --------- MENU FUNCTIONS ---------
function OverItMenu(El)
{
	El.src = "Images/" + El.id + "_Over" + ".gif";
	El.style.cursor = "hand";
}
function OutItMenu(El)
{
	El.src = "Images/" + El.id + "_Normal" + ".gif";
	El.style.cursor = "auto";
}
function fnShowSubMenu(El)
{
	document.all.divSubmenu.state = "on";
	
	for(var i=0; i<aImages.length; i++)
	{	
		if(document.all[aImages[i]])
		{
			document.all[aImages[i]].disabled = false;
			document.all[aImages[i]].src = "Images/" + document.all[aImages[i]].id + "_Normal" + ".gif";
		}
	}
}

function fnHideSubMenu(El)
{
	//alert(window.event.toElement.id)
	if(window.event.toElement.id != 'hp-submenu-dgamim' && window.event.toElement.id != 'hp-submenu2-imprezaNewAge')
	//only if we didn't move to dgamim or to submenus: hide menu
	{
		OutItMenu(El)
		document.all.divSubmenu.state = "off";
		for(var i=0; i<aImages.length; i++)
		{	
			if(document.all[aImages[i]])
			{
				document.all[aImages[i]].disabled = true;
				document.all[aImages[i]].src = "Images/" + document.all[aImages[i]].id + ".gif";
			}
		}
	}
}

function fnSubmenuDivState(El)
{ 
	if(window.event.toElement.id != "hp-menu-subaru" &&
		window.event.toElement.id != "hp-submenu-dgamim" &&
		window.event.toElement.id != "hp-submenu-traidIn" &&
		window.event.toElement.id != "hp-submenu-mimun" &&
		window.event.toElement.id != "hp-submenu-halafim" &&
		window.event.toElement.id != "hp-submenu-whySubaru" &&
		window.event.toElement.id != "hp-submenu-links" && 
		El.state == 'on' &&
		
		window.event.toElement.id != "hp-submenu-dgamim" &&
		window.event.toElement.id != "hp-submenu2-imprezaNewAge" &&
		window.event.toElement.id != "hp-submenu2-imprezaTurbo" &&
		window.event.toElement.id != "hp-submenu2-B4" &&
		window.event.toElement.id != "hp-submenu2-forest" &&
		window.event.toElement.id != "hp-submenu2-outBack")
		{
			OutItMenu(document.all("hp-menu-subaru"))//un-highlight subaru
			fnHideSubMenu(El)
			fnHideSubMenu2(El)
		}
		else
			fnHideSubMenu2(document.all.divSubmenu2)	
}

// SUBMENU --- 2 --- FUNCTIONS
function fnShowSubMenu2(El)
{
	document.all.divSubmenu2.state = "on";
	
	for(var i=0; i<aImages2.length; i++)
	{	
		if(document.all[aImages2[i]])
		{
			document.all[aImages2[i]].disabled = false;
			document.all[aImages2[i]].src = "Images/" + document.all[aImages2[i]].id + "_Normal" + ".gif";
		}
	}
}

function fnHideSubMenu2(El)
{
	if(window.event.toElement.id != 'hp-submenu2-imprezaNewAge')//only if we didn't move to submenus: hide menu
	{
		document.all.divSubmenu2.state = "off";
		
		if((window.event.toElement.id == "hp-submenu-traidIn" ||
		window.event.toElement.id == "hp-submenu-mimun" ||
		window.event.toElement.id == "hp-submenu-halafim" ||
		window.event.toElement.id == "hp-submenu-whySubaru" ||
		window.event.toElement.id == "hp-submenu-links") && document.all.divSubmenu.state == 'on')//un-highlight dgamim
			OutItMenu(document.all("hp-submenu-dgamim"))
		
		for(var i=0; i<aImages2.length; i++)
		{	
			if(document.all[aImages2[i]])
			{
				document.all[aImages2[i]].disabled = true;
				document.all[aImages2[i]].src = "Images/" + document.all[aImages2[i]].id + ".gif";
			}
		}
	}
}

function fnSubmenuDivState2(El)
{
	if(window.event.toElement.id != "hp-submenu-dgamim" &&
		window.event.toElement.id != "hp-submenu2-imprezaNewAge" &&
		window.event.toElement.id != "hp-submenu2-imprezaTurbo" &&
		window.event.toElement.id != "hp-submenu2-B4" &&
		window.event.toElement.id != "hp-submenu2-forest" &&
		window.event.toElement.id != "hp-submenu2-outBack" && 
		El.state == 'on')
		{
			OutItMenu(document.all("hp-menu-subaru"))//un-highlight subaru
			OutItMenu(document.all("hp-submenu-dgamim"))//un-highlight dgamim
			fnHideSubMenu(El)
			fnHideSubMenu2(El)
		}
}


//------------------------------------------------------------------------
function fnOpenWindow(src)
{
	var oWindow = window.open("EnLargeImage.asp?src=" + src,"Strauss", 'menubar=no, resizable=no, fullscreen=no, scrollbars=no, location=no, status=no, toolbar=no, width=708, height=533, top=100, left=100')
}

function fnOpenPrintPage(printIt)
{
	var oWindow = window.open("PrintPage.asp","Print", 'menubar=no, resizable=no, fullscreen=no, scrollbars=no, location=no, status=no, toolbar=no, width=710, height=600, top=2000, left=2000')
}

function fnPrintPage(printIt)
{
	//document.write(window.opener.document.all.divMain.innerHTML)
	document.all.divPrintIn.innerHTML = window.opener.document.all.divMain.innerHTML;
	window.print();
	window.close();
}

function fnValidateForm()
{
	var msg = "";
	
	if(document.all.txtFirstName.value == "")
		//msg = "אנא מלא שם פרטי";
		msg = "Please insert first name";
	else if(document.all.txtEMail.value == "" && document.all.txtPhone.value == "")
		//msg = "אנא מלא מספר טלפון או כתובת דואר אלקטרונית";
		msg = "Please insert phone number or email address";
		
	if(msg != "")
	{
		alert(msg)
		return false;
	}
	return true;
}

function hideMenu()
{
	//document.all.divSubaruMenu.style.display = 'none'
}
