function PopupBild(sida,namn,bredd,hojd) {
	window.open(sida,namn,'width='+bredd+',height='+hojd+',location=no,menubar=no,directories=no,scrollbars=yes,resizable=yes,status=no')
	/*
	if(window.showModalDialog){
		hojd = parseInt(hojd) + 36
		bredd = parseInt(bredd) + 10
		window.showModalDialog(sida, namn,'dialogHeight:'+hojd+'px;dialogWidth:'+bredd+'px; center:yes; resizable:no; status:no; help:no; edge:sunken'); 
	}
	else{
	}
	*/
}
//--> 

			function getXpos(obj) {
				positionX = obj.offsetLeft;
				osp = obj.offsetParent;
		  		while (osp != null) {
		  			positionX += osp.offsetLeft;
		  			osp = osp.offsetParent;
		  		}
				return positionX;
			}

			function getYpos(obj) {
				positionY = obj.offsetTop;
				osp = obj.offsetParent;
		  		while (osp != null) {
		  			positionY += osp.offsetTop;
		  			osp = osp.offsetParent;
		  		}
				return positionY;
			}




function CheckAllInForm_Catches(){
	for (var i=0;i<document.frmCatches.elements.length;i++){
		var e = document.frmCatches.elements[i];
		if (e.type=='checkbox'){
			e.checked=true;
		}
	}
}
function CheckAllInForm(iForm){
	obj=document.getElementById(iForm);
	for (var i=0;i<obj.elements.length;i++){
		var e = obj.elements[i];
		if (e.type=='checkbox'){
			e.checked=true;
		}
	}
}

function CountClick(iCT,iID) {
	var http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
            // See note below about this line
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        //alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = function() { CountClickAlert(http_request); };
    http_request.open('GET', '../clickcounter2.asp?CT=' + iCT + '&ID=' + iID, true);
    http_request.send(null);
}
function CountClickAlert(http_request) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			response_str=http_request.responseText;
			//xxx.innerHTML=response_str;
			try{
				CounterDiv.innerHTML=response_str;
			}
			catch(err){
				//txt="Fel på sidan som fångades upp av try/catch.\n\n"
				//txt+="err.description: " + err.description + "\n\n"
				//alert(txt)
			}
		}
		else{
			//alert('There was a problem with the request.');
		}
	}
}
function CheckUploadCatchPic(){
	iAlert='';
	filetype = document.myFormUpload.thefile.value.substring(document.myFormUpload.thefile.value.length-4);
	filetype = filetype.toLowerCase();
	if (filetype.length==0){
		iAlert=iAlert+'Klicka på bläddra för att välja en fil!\n'
	}
	else if((filetype != '.jpg')){
		iAlert=iAlert+'Den fil som laddas upp skall vara av formatet JPG!\n'
	}	
	Epost = document.myFormUpload.Epost.value;
	if(!CheckEmail(Epost)){
		iAlert=iAlert+'Epost är felaktig!\n'
	}

	Beskrivning = trim(document.myFormUpload.Beskrivning.value);
	if(Beskrivning.length==0){
		iAlert=iAlert+'Beskrivning saknas!\n'
	}
	if (iAlert.length>0){
		alert(iAlert);
		return false;
	}
	else{
		return true;
	}
}

function CheckEmail(i){
	//alert()
	i = trim(i);
	if ((i.indexOf('@') < 0)||(i.indexOf('.')) < 0||(i.length < 8)){
		return false;
	}
	else{
		return true;
	}
}
function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

var HideMeny = 0;
function TimeoutMeny()
{
	if(HideMeny>0)
	{
		Meny.style.display='none';
		HideMeny--;
		setTimeout("TimeoutMeny()",50);
	}
	else
	{
		Meny.style.display='';
	}
}
function MoveMenu()
{
	var fromtop;
	obj=document.getElementById("Meny");
	if(document.body.scrollTop>90)
	{
		fromtop=1
	}
	else
	{
		fromtop=90-document.body.scrollTop
	}
	if(document.body.scrollTop<getYpos(BottomDiv)-300)
	{
		obj.style.top=fromtop+document.body.scrollTop;
	}
	HideMeny = 20;
	TimeoutMeny();
}

function SelectBoxFill_ShowDiv(formname,selectboxname,ajaxurl)
{
	obj=document.getElementById(selectboxname);
	if(obj.selectedIndex==1)
	{
		SelectBoxFill_Div.style.top = getYpos(obj) + 7 + 'px';
		SelectBoxFill_Div.style.left = getXpos(obj) + 7 + 'px';
		SelectBoxFill_Div.style.display = '';
		SelectBoxFill_Lista.innerHTML = 'laddar...';
		makeRequestToDiv(ajaxurl + 'obj=' + formname + '.' + selectboxname, SelectBoxFill_Lista);
		obj.selectedIndex=0;
	}
	else if(obj.selectedIndex==2)
	{
		obj.options[0] = new Option('', '', false, false);
		obj.selectedIndex=0;
	}
}
function SelectBoxFill_FillSelectbox(iID,iValue,obj)
{
	obj.options[0] = new Option(iValue, iID, false, false);
	obj.selectedIndex=0;
	SelectBoxFill_Div.style.display = 'none';
}
function SetSelectboxByOption(selectboxname,iStr){
	//sätter selectbox (obj) efter vad som står i den (iStr) som option!
	obj=document.getElementById(selectboxname);
	//obj=selectboxname;
	for(i=0;i<obj.length;i++){
		if(obj.options[i].text==iStr){
			obj.selectedIndex=i;
			break;
		}
	}
}

function SetSelectboxByValue(selectboxname,iStr){
	//sätter selectbox (obj) efter vad som står i den (iStr) som value!
	//obj=document.getElementById(selectboxname);
	obj=selectboxname;
	for(i=0;i<obj.length;i++){
		if(obj.options[i].value==iStr){
			obj.selectedIndex=i;
			break;
		}
	}
}






