ie = (document.all) ? true:false; // IE4+
dom = ((document.getElementById) && (!ie)) ? true:false; // Mozilla

// Add listeners to the selected objects
function setEventById(id, ev, fu) 
{
	//If the browser is Mozilla
	if(dom) 
	{
		document.getElementById(id).addEventListener(ev, fu, false);
	} 
	//If the browser is Ie
	if(ie) 
	{
		document.getElementById(id).attachEvent('on' + ev, fu);
	}
}

function LogOut()
{
	document.location.href = "../Shop/LogOut.aspx";
}

function ConfirmLogOut(strMessage)
{
	if(confirm(strMessage))
	{
		LogOut();
	}
	else
	{
		return false
	}
}

function OpenCvcDialogue()
{
	window.showModalDialog("../HelpDesk/Cvc.aspx","Dialogue","dialogHeight: 260px; dialogWidth: 350px; edge: Sunken; center: Yes; help: No; resizable: No; status: No;");
}
function SetOrderVisibility(OrderId)
{
	row = document.getElementById("Order" + OrderId)
	if (row.style.display == "block")
	{
		row.style.display = "none"
	}
	else
	{
		row.style.display = "block"
	}
}

function ShowValidationSummary()
{
	//Show validation summary when button is clicked
	document.getElementById("lngValidationSummary").className = "Validator";
	if (document.getElementById("lngValidationSummary").style.display = "block")
	{
		//document.getElementById("lngValidationSummary").focus();
	}
}
function ConfirmEditLanguage(strControlId, message)
{
	if (confirm(message))
	{
		OpenEditLanguage(strControlId);
		return false;
	}
	else
	{
		return true;
	}
}
function OpenEditLanguage(strControlId)
{
	openEditLanguage(strControlId);
}
function openEditLanguage(strControlId)
{
	url = "../Tools/EditLanguage.aspx?ControlId=" + strControlId + "&EditLanguageAction=3";
	width = 700
	height = 525
	EditLanguageWindow = window.open(url,"EditLanguageWindow","resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=" + width + ",height=" + height);
	EditLanguageWindow.focus();
}

function init()
{
	/* Validation */
	if (document.getElementById("lngBtnRegisterNewCustomer"))
	{
		setEventById("lngBtnRegisterNewCustomer", "click", new Function("ShowValidationSummary();"))
	}
	if (document.getElementById("lngBtnSaveMyAccount"))
	{
		setEventById("lngBtnSaveMyAccount", "click", new Function("ShowValidationSummary();"))
	}
	if (document.getElementById("btnNextStep_1"))
	{
		setEventById("btnNextStep_1", "click", new Function("ShowValidationSummary();"))
	}
	if (document.getElementById("btnNextStep_2"))
	{
		setEventById("btnNextStep_2", "click", new Function("ShowValidationSummary();"))
	}
	if (document.getElementById("btnNextStep_2b"))
	{
		setEventById("btnNextStep_2b", "click", new Function("ShowValidationSummary();"))
	}
	if (document.getElementById("lngBtnTryAgain"))
	{
		setEventById("lngBtnTryAgain", "click", new Function("ShowValidationSummary();"))
	}
}
