/* ********************************************************
 * Argonaut 2.0 | Javascript
 * Copyright (C) Transdemica Oy / Blend Media Oy 2004
 * ******************************************************** */
 
function kuvaOn(kuvaNimi) {
	if (document.images) {
		document[kuvaNimi].src = eval(kuvaNimi + "on.src");
	}
}

function fClosing()
{
	var xmlhttp=null;
	if (window.XMLHttpRequest) 
	{
		xmlhttp=new XMLHttpRequest();
	} else {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	} 
	xmlhttp.open("POST","fClosing.aspx",false);
	xmlhttp.send(null);
}

function kuvaOff(kuvaNimi) {
	if (document.images) {
		document[kuvaNimi].src = eval(kuvaNimi + "off.src");
	}
}

// Function to open Loop Through All Assessment in own window.
function openLoopAssessmentWin() {
	var newWindow = window.open("LoopThrough.aspx","PrintAllAssessment","toolbar=no,width=760,height=510,status=no,scrollbars=yes,resizable=yes");
}
 
// Function to open tutorial in own window.
function openTutorialWin(pageToOpen) {
	var newWindow = window.open(pageToOpen,"tutorialwindow","toolbar=no,width=760,height=510,status=no,scrollbars=no,resizable=yes");
	
}

// Function to open terms in own window.
function openTermsWin() {
	var newWindow = window.open("popup.aspx?pid=17","termswindow","toolbar=no,width=450,height=450,status=no,scrollbars=yes,resizable=yes");
}

// Generic function to open popup window.
function openPopUp(pageToOpen, windowName, windowParameters) {
	var newWindow = window.open(pageToOpen,windowName,windowParameters);
	if (window.focus) { newWindow.focus(); }
}

// Confirmation alertbox for deleting something.
function Confirm() {
	if(confirm("Are you sure?")){ 
		document.admintools.hdnAnswerToConfirm.value = "YES";
	} else {
		document.admintools.hdnAnswerToConfirm.value = "NO";
	}
}

function Confirm2() {
	if(confirm("Are you sure?")){ 
		document.admintools.hdnAnswerToConfirm2.value = "YES";
	} else {
		document.admintools.hdnAnswerToConfirm2.value = "NO";
	}
}

function Confirm3() {
	if(confirm("Are you sure?")){ 
		document.admintools.hdnAnswerToConfirm3.value = "YES";
	} else {
		document.admintools.hdnAnswerToConfirm3.value = "NO";
	}
}

function ConfirmDel() {
	if(confirm("Are you sure?")){ 
		document.admintools.delAnswerToConfirm.value = "YES";
	} else {
		document.admintools.delAnswerToConfirm.value = "NO";
	}
}

function ConfirmUserDelete() {
	if(confirm("Are you sure?\nDeleting this account will lose the user's assessment results!\nTo deactivate the account, move user to 'inactive users' -group.")){ 
		document.admintools.hdnAnswerToConfirm.value = "YES";
	} else {
		document.admintools.hdnAnswerToConfirm.value = "NO";
	}
}

function ConfirmUserPerceptionDelete() {
	if(confirm("Are you sure?\nDeleting this perception will delete the user's assessment results for this perception as well!\n")){ 
		document.admintools.hdnAnswerToConfirm.value = "YES";
	} else {
		document.admintools.hdnAnswerToConfirm.value = "NO";
	}
}

function ConfirmDelete() {
	if(confirm("Are you sure?")){ 
		document.forms[0].delAnswerToConfirm.value = "YES";
	} else {
		document.forms[0].delAnswerToConfirm.value = "NO";
	}
}

function ConfirmPerceptionDelete() {
	if(confirm("Warning! Clicking OK will delete the perception from the list and all answers associated with it.")){ 
		document.forms[0].delAnswerToConfirm.value = "YES";
	} else {
		document.forms[0].delAnswerToConfirm.value = "NO";
	}
}

function ConfirmDilemmaSolutionGeneration() {
	if(confirm("Are you ready to move to the next step: Generate solutions?")){ 
		document.forms[0].ToConfirm.value = "YES";
	} else 	{
		document.forms[0].ToConfirm.value = "NO";
	}
}

function ConfirmTask(message, type) {
	if(confirm(message)){ 
		if (type == "delete") { document.forms[0].delAnswerToConfirm.value = "YES"; }
		if (type == "update") { document.forms[0].updateAnswerToConfirm.value = "YES"; }
	} else {
		if (type == "delete") { document.forms[0].delAnswerToConfirm.value = "NO"; }
		if (type == "update") { document.forms[0].updateAnswerToConfirm.value = "NO"; }
	}
}

function stripHtml(testi) {
	eval("document.forms[0]."+testi+".value = document.forms[0]."+testi+".value.replace('<', '&lt;');");
	eval("document.forms[0]."+testi+".value = document.forms[0]."+testi+".value.replace('>', '&gt;');");
}

function ConfirmSaveGroupTask(msgType) {
	var strMsg;
	
	if(msgType==2)
	{
		alert('Please Select task type');
		return false;
	}
	if(msgType==0)
		strMsg='You are creating an Other task. You will not be able to edit the task type after you have created this task. Are you sure you want to create this task?';
	if(msgType==1)
		strMsg='You are creating an Assessment task. You will not be able to edit the task type and Perception after you have created this task. Are you sure you want to create this task?';
	if(msgType==3)
		strMsg='You are creating a Use Assessment task. You will not be able to edit the task type, comparators and gap ranges after you have created this task. Are you sure you want to create this task?';
	if(msgType==4)
		strMsg='You are creating a Learn About Cultures task. You will not be able to edit the task type after you have created this task. Are you sure you want to create this task?';
	if(msgType==5)
		strMsg='You are creating a Build Your Skills task. You will not be able to edit the task type after you have created this task. Are you sure you want to create this task?';
	if(msgType==6)
		strMsg='You are creating an Exercise type task. You will not be able to edit the task type after you have created this task. Are you sure you want to create this task?';
	
	if(confirm(strMsg)){ 
		return true;
	} else {
		return false;
	}
}
