﻿function DisableForm(objForm){
	objForm.form.submit.style.backgroundColor='#7491A1';
	objForm.form.submit.disabled = true;
}

function EnableForm(objForm){
	objForm.form.submit.style.backgroundColor='#00802D';
	objForm.form.submit.disabled = false;
}

function getCookie( cookieName ){
	var cookieValue = null;
	var posName = document.cookie.indexOf(escape(cookieName) + '=');
	if ( posName != -1 ){
		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);
		if ( endPos != -1 ){
			cookieValue = unescape(document.cookie.substring(posValue, endPos));
		}
		else{
			cookieValue = unescape(document.cookie.substring(posValue));
		}
	}
	return cookieValue;
}

function setMapCookie(intZoom, intLat, intLng){
	var objDate = new Date();
	objDate = new Date(objDate.getTime()+1000*60*30);
	strValue1 = '_map_intZoom=' + intZoom + '; expires=' + objDate.toGMTString() + ';';
	strValue2 = '_map_intLat=' + intLat + '; expires=' + objDate.toGMTString() + ';';
	strValue3 = '_map_intLng=' + intLng + '; expires=' + objDate.toGMTString() + ';';
	document.cookie = strValue1;
	document.cookie = strValue2;
	document.cookie = strValue3;
}
	
function setCookie(cookieName, cookieValue, expires, path, domain, secure){
	document.cookie = escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; EXPIRES=' + expires.toGMTString() : '')
		+ (path ? '; PATH=' + path : '')
		+ (domain ? '; DOMAIN=' + domain : '')
		+ (secure ? '; SECURE' : '');
}
var oldid;
function toggleMenu(id){
	if(oldid && oldid != id){
		Effect.BlindUp('voucher' + oldid, { duration: 0.1 });
		var elmOldLink = document.getElementById(oldid);
		if(elmOldLink){
			elmOldLink.style.backgroundColor = '';
			elmOldLink.style.border = '';
			elmCloseBtn = document.getElementById('close' + oldid);
			if(elmCloseBtn){
				elmCloseBtn.style.display = 'none';
			}
		}
		oldid = id;
	}
	else{
		oldid = id;
	}
	Effect.SlideUpAndDown('voucher' + id, { duration: 0.3 });
}
function switchStyle(id){
	var elmDiv = document.getElementById(id);
	if(elmDiv){
		var bgcolor = elmDiv.style.backgroundColor;
		if(bgcolor != "rgb(238, 238, 238)"){
			elmDiv.style.backgroundColor = '#EEEEEE';
			elmDiv.style.border = '1px solid #00802D';
		}
		else{
			elmDiv.style.backgroundColor = '';
			elmDiv.style.border = '';
		}
		var elmCloseBtn = document.getElementById('close' + id);
		if(elmCloseBtn){
			if( elmCloseBtn.style.display == 'none' ){
				elmCloseBtn.style.display = 'block';
			}
			else{
				elmCloseBtn.style.display = 'none';
			}
		}
	}
}
function switchItemStyle(id){
	var elmDiv = document.getElementById(id);
	var elmLink = document.getElementById(id + '_link');
	if (elmDiv){
		var bgcolor = elmDiv.style.backgroundColor;
		if(bgcolor != "rgb(0, 128, 45)"){
			elmDiv.style.backgroundColor = '#00802D';
			elmLink.style.color = '#EEEEEE';
		}
		else{
			elmDiv.style.backgroundColor = '';
			elmLink.style.color = '#00802D';
		}
	}
}

function resizeWin(windowID, sizeX, sizeY, mode){
	if( mode == 'back' ){
		parent.arrWins[windowID].setSize(sizeX, sizeY);
		// parent.arrWins["<? user_infos.getId() ?>"].showCenter();
		// parent.arrWins["<? user_infos.getId() ?>"].setTitle("<div style='position: relative; top: 5px;'><? gettext('edit customer informations') ?></div>");
	}
	else{
		parent.arrWins[windowID].setSize(sizeX, sizeY);
		// parent.arrWins["<? user_infos.getId() ?>"].showCenter();
	}
}
