
 /****************************************************************************\
 # Creation date :-> 16-04-2008 [dd-mm-yyyy]                                  #
 # Last update   :-> 10-02-2010 [dd-mm-yyyy]                                  #
 #                                                                            #
 # Author        :-> Antonio Magdic  <antonio@eburza.hr>                      #
 \****************************************************************************/

function UserDelete(uid) {
	var is_confirmed = confirm(DeleteMemberConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "user_delete";
		document.myForm.user_id.value = uid;
		document.myForm.submit();
	}
} // end of the 'UserDelete()' function

function UserEdit(uid) {
	document.myForm.action = "index.php?menu=1000&action=10";
	document.myForm._action_.value = "user_edit";
	document.myForm.user_id.value = uid;
	document.myForm.submit();
} // end of the 'UserEdit()' function

function UserActivate(uid) {
	document.myForm.action = "index.php?menu=1000&action=15";
	document.myForm._action_.value = "user_activate";
	document.myForm.user_id.value = uid;
	document.myForm.submit();
} // end of the 'UserActivate()' function

function SignOnDelete(pid) {
	var is_confirmed = confirm(DeleteMemberConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "signon_delete";
		document.myForm.prijava_id.value = pid;
		document.myForm.submit();
	}
} // end of the 'SignOnDelete()' function

function SignOnEdit(pid) {
	document.myForm.action = "index.php?menu=1000&action=146";
	document.myForm._action_.value = "signon_edit";
	document.myForm.prijava_id.value = pid;
	document.myForm.submit();
} // end of the 'SignOnEdit()' function

function DVUDelete(uid) {
	var is_confirmed = confirm(DVUDeleteMemberConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "dvu_delete";
		document.myForm.dvu_id.value = uid;
		document.myForm.submit();
	}
} // end of the 'DVUDelete()' function

function ProposeDelete(uid) {
	var is_confirmed = confirm(DeleteMemberConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "propose_delete_admin";
		document.myForm.prijedlog_id.value = uid;
		document.myForm.submit();
	}
} // end of the 'ProposeDelete()' function

function ProposePrijedlog(pid) {
	document.myForm.action = "index.php?menu=1000&action=119";
	document.myForm._action_.value = "propose_prijedlog_admin";
	document.myForm.prijedlog_id.value = pid;
	document.myForm.submit();
} // end of the 'ProposePrijedlog()' function

function NewsEdit(nid) {
	document.myForm.action = "index.php?menu=1000&action=76";
	document.myForm._action_.value = "news_edit";
	document.myForm.news_id.value = nid;
	document.myForm.submit();
} // end of the 'NewsEdit()' function

function NewsDelete(nid) {
	var is_confirmed = confirm(NewsDeleteConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "news_delete";
		document.myForm.news_id.value = nid;
		document.myForm.submit();
	}
} // end of the 'NewsDelete()' function

function SvjedocenjeEdit(sid) {
	document.myForm.action = "index.php?menu=1000&action=162";
	document.myForm._action_.value = "svjedocenje_edit";
	document.myForm.svjedocenje_id.value = sid;
	document.myForm.submit();
} // end of the 'SvjedocenjeEdit()' function

function SvjedocenjeDelete(sid) {
	var is_confirmed = confirm(SvjedocenjeDeleteConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "svjedocenje_delete";
		document.myForm.svjedocenje_id.value = sid;
		document.myForm.submit();
	}
} // end of the 'SvjedocenjeDelete()' function

function ReportEdit(rid) {
	document.myForm.action = "index.php?menu=1000&action=172";
	document.myForm._action_.value = "report_edit";
	document.myForm.report_id.value = rid;
	document.myForm.submit();
} // end of the 'ReportEdit()' function

function ReportDelete(rid) {
	var is_confirmed = confirm(DeleteReportConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "report_delete";
		document.myForm.report_id.value = rid;
		document.myForm.submit();
	}
} // end of the 'ReportDelete()' function

function EventEdit(eid) {
	document.myForm.action = "index.php?menu=1000&action=182";
	document.myForm._action_.value = "event_edit";
	document.myForm.event_id.value = eid;
	document.myForm.submit();
} // end of the 'EventEdit()' function

function EventDelete(eid) {
	var is_confirmed = confirm(DeleteEventConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "event_delete";
		document.myForm.event_id.value = eid;
		document.myForm.submit();
	}
} // end of the 'EventDelete()' function

function DonationEdit(eid) {
	document.myForm.action = "index.php?menu=1000&action=402";
	document.myForm._action_.value = "donation_edit";
	document.myForm.donation_id.value = eid;
	document.myForm.submit();
} // end of the 'DonationtEdit()' function

function DonationDelete(eid) {
	var is_confirmed = confirm(DeleteDonationConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "donation_delete";
		document.myForm.donation_id.value = eid;
		document.myForm.submit();
	}
} // end of the 'DonationDelete()' function

function EventSubmissionEdit(pid) {
	document.myForm.action = "index.php?menu=1000&action=202";
	document.myForm._action_.value = "event_submission_edit";
	document.myForm.prijava_id.value = pid;
	document.myForm.submit();
} // end of the 'EventSubmissionEdit()' function

function EventSubmissionDelete(pid) {
	var is_confirmed = confirm(DeleteEventSubmissionConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "event_submission_delete";
		document.myForm.prijava_id.value = pid;
		document.myForm.submit();
	}
} // end of the 'EventSubmissionDelete()' function

function ConfessionEdit(eid) {
	document.myForm.action = "index.php?menu=1000&action=192";
	document.myForm._action_.value = "confession_edit";
	document.myForm.confession_id.value = eid;
	document.myForm.submit();
} // end of the 'ConfessionEdit()' function

function ConfessionDelete(eid) {
	var is_confirmed = confirm(ConfessionDeleteConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "confession_delete";
		document.myForm.confession_id.value = eid;
		document.myForm.submit();
	}
} // end of the 'ConfessionDelete()' function

function DVUEdit(uid) {
	document.myForm.action = "index.php?menu=1000&action=110";
	document.myForm._action_.value = "dvu_edit";
	document.myForm.dvu_id.value = uid;
	document.myForm.submit();
} // end of the 'DVUEdit()' function

function DVEdit(uid) {
	document.myForm.action = "index.php?menu=1000&action=142";
	document.myForm._action_.value = "dv_edit";
	document.myForm.dv_id.value = uid;
	document.myForm.submit();
} // end of the 'DVEdit()' function

function DocumentDelete(did) {
	var is_confirmed = confirm(DeleteDocConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "document_delete";
		document.myForm.document_id.value = did;
		document.myForm.submit();
	}
} // end of the 'DocumentDelete()' function

function DocumentEdit(did) {
	document.myForm.action = "index.php?menu=1000&action=65";
	document.myForm._action_.value = "document_edit";
	document.myForm.document_id.value = did;
	document.myForm.submit();
} // end of the 'DocumentEdit()' function

function DocumentGroupDelete(gid) {
	var is_confirmed = confirm(DeleteGroupConfirm);
	if(is_confirmed) {
		document.myForm.action = "include/trigger.php";
		document.myForm._action_.value = "document_group_delete";
		document.myForm.group_id.value = gid;
		document.myForm.submit();
	}
} // end of the 'DocumentGroupDelete()' function

function DocumentGroupEdit(gid) {
	document.myForm.action = "index.php?menu=1000&action=85";
	document.myForm._action_.value = "document_group_edit";
	document.myForm.group_id.value = gid;
	document.myForm.submit();
} // end of the 'DocumentGroupEdit()' function

function SendPasswordToUser(uid) {
	var is_confirmed = confirm(SendPasswdToUserConfirm);
	if(is_confirmed) {
		var SendToUser = new Ajax.Request(
			'include/activate.php', {
				method: 'post',
				parameters: 'user_id=' + uid,
				onFailure: reportError
			}
		);
	}
} // end of the 'SendPasswordToUser()' function

function GetUsersFromCountry(country, gender, user_type, selectID, dvID, adminNote, signOn) {
	var objID = 'UsersList';
	$('UserData').innerHTML = '';
	var myAjax = new Ajax.Updater({ success: objID }, 'include/users_from_country.php', {
			method: 'get',
			parameters: 'country='+country+'&gender='+gender+'&type='+user_type+'&select='+selectID+'&dv_id='+dvID+'&signon='+signOn+'&admin='+encodeURIComponent(adminNote),
			onFailure: reportError
		 }
	);
} // end of the 'GetUsersFromCountry()' function

function GetUsersData(uID, dvID) {
	var objID = 'UserData';
	var myAjax = new Ajax.Updater({ success: objID }, 'include/users_data.php', {
			method: 'get',
			parameters: 'user_id='+uID+'&dv_id='+dvID,
			onFailure: reportError
		 }
	);
} // end of the 'GetUsersData()' function

function GetEventData(evID) {
	var objID = 'EventData';
	var myAjax = new Ajax.Updater({ success: objID }, 'include/event_data.php', {
			method: 'post',
			parameters: 'event_id='+evID,
			onFailure: reportError
		 }
	);
} // end of the 'GetEventData()' function

function GetDVData(dvID) {
	var objID = 'DVData';
	var myAjax = new Ajax.Updater({ success: objID }, 'include/dv_data.php', {
			method: 'post',
			parameters: 'dv_id='+dvID,
			onFailure: reportError
		 }
	);
} // end of the 'GetDVData()' function

function GetUserDVTree(uID, dvID, uniqueID, showLinks) {
	var objID = 'DVTreeContainer' + uniqueID;
	var myAjax = new Ajax.Updater({ success: objID }, 'include/user_dv_tree2.php', {
			method: 'get',
			parameters: 'parent='+uID+'&dv_id='+dvID+'&showlinks='+showLinks,
			onFailure: reportError
		 }
	);
} // end of the 'GetUserDVTree()' function

function GetDVLvls(dvID, myAction, mySelect) {
	var objID = 'DVUsersList';
	var myAjax = new Ajax.Updater({ success: objID }, 'include/users_from_dv.php', {
			method: 'get',
			parameters: 'dv_id='+dvID+'&action='+myAction+'&select='+mySelect,
			onFailure: reportError
		 }
	);
} // end of the 'GetDVLvls()' function

function SubmitOnEnter(myForm, e) {
	if (!e) var e = window.event
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	
	if(code == 13) {
		myForm.submit();
	}
} // end of the 'SubmitOnEnter()' function

function CreateCookie(name, value, days) {
	if(days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
} // end of the 'CreateCookie()' function

function ReadCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
} // end of the 'ReadCookie()' function

function EraseCookie(name) {
	CreateCookie(name, "", -1);
} // end of the 'EraseCookie()' function

function reportError() {
	alert('The requested URL was not found on this server.');
} // end of the 'reportError()' function

function PrintSource(myField) {
	var mySource = $(myField).innerHTML;
	
	printWin = window.open('','printWin','location=0,menubar=0,toolbar=0,scrollbars=1,width=740');
	printWin.document.open();
	printWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	printWin.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
	printWin.document.write('<head>');
	printWin.document.write('  <title>injigo.com</title>');
	printWin.document.write('  <meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />');
	printWin.document.write('  <link rel="stylesheet" type="text/css" href="print.css" />');
	printWin.document.write('</head>');
	printWin.document.write('<body>');
	printWin.document.write(mySource);
	printWin.document.write('<div class="spacer"></div>');
	printWin.document.write('<div id="footer">&copy; 2008-2009 Injigo. All rights reserved.</div>');
	printWin.document.write('</body>');
	printWin.document.write('</html>');
	printWin.print();
	printWin.document.close();
} // end of the 'PrintSource()' function

function StarMe(rate, field, uid1, uid2) {
	var objID = 'stars_'+field+'_'+uid1+'_'+uid2;
	var myAjax = new Ajax.Updater({ success: objID }, 'include/star_me.php', {
			method: 'post',
			parameters: 'field='+field+'&uid1='+uid1+'&uid2='+uid2+'&rate='+rate,
			onFailure: reportError
		 }
	);
} // end of the 'StarMe()' function

function ShowHideBox(objID) {
	if($(objID).style.display == "none") { // show
		//$(objID).show();
		Effect.Appear(objID);
	} else { // hide
		$(objID).hide();
		Effect.Fade(objID);
	}
} // end of the 'ShowHideBox()' function

function myNoteSave(uid, dv_id, note) {
	var myAjax = new Ajax.Request('include/save_note.php', {
			method: 'post',
			parameters: 'uid='+uid+'&dv_id='+dv_id+'&note='+encodeURIComponent(note),
			onFailure: reportError
		}
	);
} // end of the 'myNoteSave()' function

function promptSearchOption(thisform, thisfield) {
	var elnum = parseInt(-1);
	var k = parseInt(-1);
	for (var j = 0; j < document.forms[thisform].elements.length; j++) {
		if (document.forms[thisform].elements[j].name == thisfield) {
			elnum = j;
			break;
		}
	}
	var myvar = "";
	var srch = "";
	var menuLength = "";
	menuLength = eval("document." + thisform + "." + thisfield + ".length");
	srch = prompt(SearchOption, "");
	if (srch) {
		srch = srch.toUpperCase();
		for (var i = 0; i < menuLength; i++) {
			myvar = eval("document." + thisform + "." + thisfield + ".options[" + i + "].text.toUpperCase()");
			if (myvar.indexOf(srch) >= 0) {
				document.forms[thisform].elements[elnum].options[i].selected = true;
				break;
			}
		}
	}
	return false;
} // end of the 'promptSearchOption()' function