function getSubcats(cid, cvalue, multi) {
	advAJAX.get({
		url: "/subcategories.php",
		parameters : {
		  "cid" : cid,
		  "cvalue" : cvalue,
		  "multi" : multi
		},
		onLoading : function(obj) { 
		
		},
		onComplete : function(obj) { 
			
		},
		onSuccess : function(obj) { 
			var doc = document.getElementById('subcategories');
			doc.innerHTML = obj.responseText;
		},
		onError : function(obj) { alert("Error: " + obj.status); },
		"blad" : "blad"
	});
}

function getSalaries(sid, svalue) {
	advAJAX.get({
		url: "/salaries.php",
		parameters : {
		  "sid" : sid,
		  "svalue" : svalue
		},
		onLoading : function(obj) { 
		
		},
		onComplete : function(obj) { 
			
		},
		onSuccess : function(obj) { 
			var doc = document.getElementById('salaries');
			doc.innerHTML = obj.responseText;
		},
		onError : function(obj) { alert("Error: " + obj.status); },
		"blad" : "blad"
	});
}

function SubmitForm(form_id, extra_1, extra_2, extra_3, extra_4, extra_5, extra_6, extra_7, extra_8) {
	tinyMCE.triggerSave(true,true);

	advAJAX.submit(document.getElementById(form_id), {
		parameters : {
			"ajax" : 1,
			"extra_1" : extra_1 || '',
			"extra_2" : extra_2 || '',
			"extra_3" : extra_3 || '',
			"extra_4" : extra_4 || '',
			"extra_5" : extra_5 || '',
			"extra_6" : extra_6 || '',
			"extra_7" : extra_7 || '',
			"extra_8" : extra_8 || ''
		},
		onInitialization : function(obj) {
			RestoreFormFieldsBorder(form_id);
			//document.getElementById("submitBtn").value = "Wait...";
		},
		onComplete : function() {
			//document.getElementById("submitBtn").value = "Save";
		},
		onSuccess : function(obj) {
			var doc = document.getElementById('info_container');
			var doc_inner = document.getElementById('info_container_inner');
			if (obj.responseText) {
				var xmlDoc = loadXMLString(obj.responseText);
				var root = xmlDoc.getElementsByTagName("ajax")[0];
				var url = xmlDoc.getElementsByTagName("url")[0];
				var message = '';
				if (root) {
					for (var iNode = 0; iNode < root.childNodes.length; iNode++) {
						var node = root.childNodes.item(iNode);
						
						var item_id = node.nodeName;
						
						var type = '';
						if (node.attributes.getNamedItem("type"))
							type = node.attributes.getNamedItem("type").nodeValue;
						
						var msg = ''
						if (node.attributes.getNamedItem("msg"))
							msg = node.attributes.getNamedItem("msg").nodeValue;
						
						
						if (type == "error") {
							var item = document.getElementById(item_id);
							if (item) {
								//item.style.border = '2px solid #FF0000';
								item.style.backgroundColor = '#FFAFB4';
							}
						}
						
						message = message + msg;
						if (iNode < root.childNodes.length - 1)
							message += "<br/>";
					}
				}
				else if (url) {
					document.location.href = url.attributes.getNamedItem("ref").nodeValue;
				}
				else
					message = obj.responseText;
				
				if (message != '') {
					doc_inner.innerHTML = message;
					doc.style.display = 'block';
					scroll(0,0);
				}
			}
		},
		onError : function(obj) {
			alert("Connection cannot be established. Please try again later.");
		}
	});
}

function RestoreFormFieldsBorder(form_name)
{
	form = document.getElementById(form_name);
	
	for (var iNode = 0; iNode < form.elements.length; iNode++) {
		var node = form.elements[iNode];
		if (node.type != "submit" && node.type != "button") {
			//node.style.border = '0px solid #FF0000';
			node.style.backgroundColor = '#E8E8E8';
		}
	}
}

function getAds(side) {
	advAJAX.get({
		url: "/google_ads.php",
		parameters : {
		  "side" : side
		},
		onLoading : function(obj) { 
		
		},
		onComplete : function(obj) { 
			
		},
		onSuccess : function(obj) { 
			var doc = document.getElementById('baner_'+side);
			doc.innerHTML = obj.responseText;
			//doc.innerHTML = 'ads';
		},
		onError : function(obj) { alert("Error: " + obj.status); },
		"blad" : "blad"
	});
}

function loadAds() {
	getAds('left');
}

/*function SubmitForm(form_id, value) {
	document.getElementById('job_type_send').value = value;
	LoadValidateForm('addForm');
}*/