// DATE:[05.03.2006 22:36]

var NN     = (document.getElementById) ? 1 : 0;
var NN4    = (document.layers)         ? 1 : 0;
var MSIE   = (document.all)    		   ? 1 : 0;
var norm   = (NN || MSIE || NN4)       ? 1 : 0;

function initEl(){
	if(NN)       return document.getElementById(arguments[0]);
	else if(NN4) return document.layers[arguments[0]];
	else         return document.all.item(arguments[0]);
}

function divDisplayCtrl(){
	if(norm){
		elRef = initEl(arguments[0]);
		if(elRef.style.display == 'none'){
			  elRef.style.display = 'block';
		}else elRef.style.display = 'none'
	}
}

function menuAct(){	
	divDisplayCtrl(arguments[0]);	
	imgRef = document.images[arguments[0]+'arrow'];
	currSrc = imgRef.src.split("/");	
	if( currSrc[currSrc.length-1] == 'arrow_item.gif' ){
		imgRef.src = 'img/arrow_item2.gif';	
		document.cookie = arguments[0]+'=true';	
	}else{
		imgRef.src = 'img/arrow_item.gif';		
		document.cookie = arguments[0]+'=false';		
	}
}


function menuSetsOnload(){ // do in ifooter.inc
	//for example document.cookie - 'ABOUT=true; NEWS=false; DIRECTORY=true'...
	cookieWithoutWhiteSpace = trimWhiteSpace(document.cookie);
	proElNames = cookieWithoutWhiteSpace.split(';');
	for(i=0;i<proElNames.length;i++){
		//for example proElNames[i] - 'ABOUT=true'
		elName = proElNames[i].split('=');
		//for example elName['ABOUT','true'] hence if elName[1] == true then do menuAct('ABOUT')
		if(elName[1]=='true') menuAct(elName[0]);
	}
}


function allCheckboxCtrl(){
	for(i=1;i < arguments[0].elements.length;i++){
		 if(arguments[0].elements[i].type == 'checkbox') arguments[0].elements[i].checked = arguments[1];
	}
}



function submitIt(){
	document.submitIt.arguments[0].submit();
}


function NewTrColorBlink(){
	
	currEl = document.getElementById(arguments[0]);
	currTR = currEl.style;
	
	//alert(currEl.className);
	
	if(currEl.className == "offBlink"){	
		currTR.cursor = 'pointer';
		currEl.className = "onBlink";
	}else{	
		currTR.cursor = 'auto';
	 	currEl.className = "offBlink";
	}
	
}

function emailValid(){
	if (arguments[0].search(/^[\w\.\-]+@[\w\.\-]+$/) == -1) return false;
	else return true;
}

function dotDateValid(){
	if (arguments[0].search(/\d{2}\.\d{2}\.\d{4}/) == 0) return true;
	else return false;
}

function sternStringValid(){
	if (arguments[0].search(/^[\w\-]+$/) == -1) return false;
	else return true;
}

function trimWhiteSpace(){
	while(arguments[0].search(/\s/) != -1){
		arguments[0] = arguments[0].replace(/\s/,"");
	}
	return arguments[0];
}


function openCalendar(){
	if(arguments.length == 1){
		calendarHandle = wOpen("calendar.php?openerFocus="+arguments[0],"calendar",180,160);
		calendarHandle.focus();
	}else alert("openCalendar()\n\error:[ arguments.length != 1 ]");
}

function openCities(){
	if(arguments.length == 2){
		citiesHandle = wOpen("cities.php?openerFocus="+arguments[0]+"&countrySelectBox="+arguments[1]+"&targetCountryAbbr="+eval('document.'+arguments[1]+'.value'),"cities",350,450);
		citiesHandle.focus();
	}else alert("openCities()\n\error:[ arguments.length != 2 ]");
}

var fileName,wn,ww,wh;
function wOpen(fileName,wn,ww,wh){
	return window.open(fileName,wn,'toolbar=0,menubar=0,scrollbars=0,resizeble=0,width='+ww+',height='+wh+',top=100,left=100');
}