// JavaScript Document
var currProfileID = 0;

function fSendProfile() {
	if (xhrSent) {
		alert(xhrSentAlertMessage);
	} else {
		disableCloseButton(true);
		dojo.xhrPost({
			url: '/ajax/profile/send.asp',
			handleAs: "json",
			load: fXhrCallBack,
			error: fXhrError,
			form: "frmSendProfile",
			timeout: 5000
		});
		xhrSent = true;
	}		
}
function fShowSendProfile(iProfileID) {
	currProfileID = iProfileID;
	getDialog('sendProfileDialog'); 
}
function fCheckSendProfile() {
	var checkRulez = {
		"fields": [
			{"id": "txtSenderName", "required": true, "type": "text", "minlength": 1, "message": "Naam verzender"},
			{"id": "txtSenderEmail", "required": true, "type": "email", "message": "Email verzender"},
			{"id": "email", "required": true, "type": "text", "minlength": 10, "message": "Verzend naar"}
		],
		"messageBefore": "Om het profiel door te kunnen sturen moeten eerst alle onderstaande velden juist worden ingevuld!",
		"messageAfter" : "",
		"title": "Niet alle velden zijn juist ingevuld!"
	};
			  
	var result = fCheckForm(checkRulez);
	fXhrCheckHTML(result);
	if (result.status != "ok"){
		showDialog(result.response.id, result);
	} else {
		//$("frmSendProfile_ProfileID").value = currProfileID;
		getDialog('waitDialog', 'callstackAfter=fSendProfile|250');
		DisablePopVars();
	}
}

function fCheckSendSingleProfile() {
	var checkRulez = {
		"fields": [
			{"id": "txtSenderName", "required": true, "type": "text", "minlength": 1, "message": "Jouw eigen naam"},			
			{"id": "email", "required": true, "type": "email", "minlength": 10, "message": "Verzend naar"}
		],
		"messageBefore": "Om het profiel door te kunnen sturen moeten eerst alle onderstaande velden juist worden ingevuld!",
		"messageAfter" : "",
		"title": "Niet alle velden zijn juist ingevuld!"
	};
			  
	var result = fCheckForm(checkRulez);
	fXhrCheckHTML(result);
	if (result.status != "ok"){
		showDialog(result.response.id, result);
	} else {
		//$("frmSendProfile_ProfileID").value = currProfileID;
		getDialog('waitDialog', 'callstackAfter=fSendProfile|250');
		DisablePopVars();
	}
}

//Report section
function fReportProfile() {
	if (xhrSent) {
		alert(xhrSentAlertMessage);
	} else {
		disableCloseButton(true);
		dojo.xhrPost({
			url: '/ajax/photo/report.asp',
			handleAs: "json",
			load: fXhrCallBack,
			error: fXhrError,
			form: "frmReport",
			timeout: 5000
		});
		xhrSent = true;
	}		
}

function fCheckReportProfile() {
	var checkRulez = {
		"fields": [			
			{"id": "emailreporter", "required": true, "type": "email", "message": "Jouw email adres"},
			{"id": "namereporter", "required": true, "type": "text", "message": "Jouw naam"},
			{"id": "reason", "required": true, "type": "text", "minlength": 10, "message": "Reden"}			
		],
		"messageBefore": "Om deze foto te kunnen rapporteren moeten eerst alle onderstaande velden juist worden ingevuld!",
		"messageAfter" : "",
		"title": "Niet alle velden zijn juist ingevuld!"
	};
			  
	var result = fCheckForm(checkRulez);
	fXhrCheckHTML(result);
	if (result.status != "ok"){
		showDialog(result.response.id, result);
	} else {
		//$("frmSendProfile_ProfileID").value = currProfileID;
		getDialog('waitDialog', 'callstackAfter=fReportProfile|250');
		DisablePopVars();
	}
}
