
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}

function showUploadBox(){
	if(navigator.family =="nn4") {eval(document.uploadBox.visibility="show");}
	else if(navigator.family =="ie4"){uploadBox.style.visibility="visible";}
	else if(navigator.family =="gecko") {document.getElementById("uploadBox").style.visibility="visible";}
	else {document.getElementById("uploadBox").style.visibility="visible";}
}

function hideUploadBox(){
	if(navigator.family =="nn4") {eval(document.uploadBox.visibility="hide");}
	else if(navigator.family =="ie4"){uploadBox.style.visibility="hidden";}
	else if(navigator.family =="gecko") {document.getElementById("uploadBox").style.visibility="hidden";}
	else {document.getElementById("uploadBox").style.visibility="hidden";}
}

function setDeliverDate(year, month, day){
	yearPop = document.forms[0].elements.year;
	yearLength=yearPop.length;
	
	for(var j = 0; j < yearLength; j++){
		if(yearPop.options[j].text == year){
			yearPop.selectedIndex=j;
		}
	}
	
	monthPop = document.forms[0].elements.month;
	monthLength=monthPop.length;
	for(var j = 0; j < monthLength; j++){
		if(monthPop.options[j].text == month){
			monthPop.selectedIndex=j;
		}
	}
	
	dayPop = document.forms[0].elements.day;
	dayLength=dayPop.length;
	for(var j = 0; j < dayLength; j++){
		if(dayPop.options[j].text == day){
			dayPop.selectedIndex=j;
		}
	}
}

function adminShowUsers(){
	document.forms[0].searchFor.value = "*";
	document.forms[0].submit();
}

function adminNewUser(session){
	document.location = "adminUsersNewUser.php?session="+session+"";
}

function openWindow(x,y,namn,url){
	if (y > screen.height) {
		y = screen.height - 100;
	}

	window.open(url,namn,"scrollbars=yes,resizable=yes,width="+x+",height="+y+",left=50,top=50");
}

function chooseAdvertiser(){
	if(document.forms[0].advertiserPop[document.forms[0].advertiserPop.selectedIndex].value != ""){
		document.forms[0].advertiser.value = document.forms[0].advertiserPop[document.forms[0].advertiserPop.selectedIndex].value;
	}
}

function sortCol1(){
	document.forms[0].sortBy.value = document.forms[0].colContent1[document.forms[0].colContent1.selectedIndex].value;
	document.forms[0].submit();
}
function sortCol2(){
	document.forms[0].sortBy.value = document.forms[0].colContent2[document.forms[0].colContent2.selectedIndex].value;
	document.forms[0].submit();
}
function sortCol3(){
	document.forms[0].sortBy.value = document.forms[0].colContent3[document.forms[0].colContent3.selectedIndex].value;
	document.forms[0].submit();
}
function reReverseSort(value){
	document.forms[0].sort.value = value;
}

function adminEraseCheckedUsers(text){
	var erase = confirm(text);
	if(erase){
		document.forms[1].action.value = "eraseMarkedUsers";
		document.forms[1].submit();
	}
}

function adminMailCheckedUsers(text){
	var erase = confirm(text);
	if(erase){
		document.forms[1].action.value = "sendMail";
		document.forms[1].submit();
	}
}

function adminEraseAcess(){
	document.forms[0].action.value = "erase";
	document.forms[0].submit();
}


function proofSortCol3(){
	document.forms[0].sortBy.value = "created";
	document.forms[0].submit();
}
function proofSortCol4(){
	document.forms[0].sortBy.value = "accepted";
	document.forms[0].submit();
}
function proofSortCol5(){
	document.forms[0].sortBy.value = "updated";
	document.forms[0].submit();
}
function proofSortCol6(){
	document.forms[0].sortBy.value = "status";
	document.forms[0].submit();
}
function proofReReverseSort(value){
	document.forms[0].sort.value = value;
}

function charCountLimiter(source, max_length, action, message){
	if(document.getElementById(source).value.length > max_length){
		if(action != "warn"){
			document.getElementById(source).value = document.getElementById(source).value.substring(0, max_length);
		}
			document.getElementById(source+"_error").innerHTML = message;
	}else{
		document.getElementById(source+"_error").innerHTML = "";
	}
	document.getElementById(source+"_count").innerHTML = document.getElementById(source).value.length;
}
