/*

*/

var lastActiveSwpbs = null;
var lastActiveSwpbsLabel = null;
var lastFastPtr = null;
var lastFastBlock = null;
var fslider = null;
var Form = null;


function scrollWinTop() {
	$('html, body').animate({ scrollTop: $("#ancor").offset().top}, 700);
}
function formPostProcess(name, data) {
	if (name == "connector.form.employee.applicationform")
		formPostProcess_employee_appication_form(data);
}

function formPostProcess_employee_appication_form(data) {
	var xmlDoc = null;
	if (jQuery.browser.msie) {
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  
    	xmlDoc.loadXML(data);
	} else {
		var parser = new DOMParser();
		xmlDoc = parser.parseFromString(data, "text/xml");
	}
	var rootNode = xmlDoc.getElementsByTagName("result")[0];

	var item = xmlDoc.getElementsByTagName("item");
	var i = 0;
	while(item[i]) {
		var parent = item[i].attributes[0].value;
		var comment = item[i].firstChild.nodeValue;
		var obj = document.createElement("div");
		obj.appendChild(document.createTextNode(comment));
		
		var wr = document.createElement("div");
		wr.appendChild(obj);
		document.getElementById(parent).appendChild(wr);
		wr.className = "formback_comment";
		
		i++;
	}
}
function init0() {
	Form = new CowberryForm(); 

	initUICallbacks(0);
	var s = document.getElementById("fSlideContainer");
	if (!s) return;
	fslider = new W2SlideProcess();
	fslider.setScrollSize(150);
	fslider.setScrollStep(20);
	fslider.onStep = function(v) { s.scrollLeft =v; }	


}

function init1() {
	initUICallbacks(1);
}

function initUICallbacks(m) {

	var cRss = document.getElementById('cRSSLink');
	if (cRss) {
		cRss.child = document.getElementById('cRSSWindow');
		cRss.onclick = function() { return processPopup(this); }
	}
	
	var cRssClose = document.getElementById('cRSSClose');
	if (cRssClose) {
		cRssClose.child = document.getElementById('cRSSWindow');
		cRssClose.onclick = function() { return processPopup(this); }
	}

	if (m == 0) {
		var cVacancy = document.getElementById('cVacancy');
		if (cVacancy) {
			cVacancy.onclick = function() { return processItemSelect(this); }
			processItemSelect(document.getElementById('cVacancy'));
		}
		
		var cProjects = document.getElementById('cProjects');
		if (cProjects)
			cProjects.onclick = function() { return processItemSelect(this); }
			
		var cIdeas = document.getElementById('cIdeas');
		if (cIdeas)
			cIdeas.onclick = function() { return processItemSelect(this); }

	}
}

function processPopup(ptr) {
		if (ptr.child.style.visibility == 'visible') {
			ptr.child.style.visibility = 'hidden';
		} else {
			ptr.child.style.visibility = 'visible';
		}
		return false;
}
function swpp(ptr) {
		if (ptr.style.visibility == 'visible') {
			ptr.style.visibility = 'hidden';
		} else {
			ptr.style.visibility = 'visible';
		}
		return false;
}
function swpb(ptr) {
		if (ptr.style.display == 'block') {
			ptr.style.display = 'none';
		} else {
			ptr.style.display = 'block';
		}
		return false;
}

function swpbs(ptr, c) {
		if (lastActiveSwpbs)
			lastActiveSwpbs.style.display = 'none';
		
		if (lastActiveSwpbsLabel)
			lastActiveSwpbsLabel.innerHTML = '';
			
		if (ptr.style.display == 'block') {
			ptr.style.display = 'none';
			return false;
		}

		if (ptr.style.display == 'none') {
			ptr.style.display = 'block';
			c.innerHTML = "&nbsp;&rarr;";
			lastActiveSwpbsLabel = c;
			lastActiveSwpbs = ptr;
		}
		return false;
}

function processItemSelect(ptr) {
	if (lastFastPtr) {
		//alert(lastFastPtr.arrPtr);
		lastFastPtr.className = 'inlRef';
		lastFastPtr.parentNode.removeChild(lastFastPtr.parentNode.arrPtr);
	}

	var da = document.createElement("span");
	da.innerHTML='&darr;&nbsp;';
	ptr.appendChild(da);
	ptr.arrPtr = da;

	lastFastPtr = ptr.childNodes[0];
	lastFastPtr.className = "selected";

	var ref = null;
	ptr.id == 'cVacancy' ? ref = document.getElementById('lVacancy'): null;
	ptr.id == 'cProjects' ? ref = document.getElementById('lProjects'): null;
	ptr.id == 'cIdeas' ? ref = document.getElementById('lIdeas'): null;
	
	if (!ref)
		return;
	
	if (lastFastBlock)
		lastFastBlock.style.display = 'none';
	
	lastFastBlock = ref;
	ref.style.display = 'block';
		
	return false;
}