alldns="http://www.convertec.se/en";

function skapaflash(DivID, ObjectID, WIDTH, HEIGHT, URL)
{
  var obj = document.getElementById(DivID);
  obj.innerHTML += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' id='" + ObjectID + "' width='" + WIDTH + "' height='" + HEIGHT + "' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='" + URL + "' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#282828' /><embed src='" + URL + "' quality='high' wmode='transparent' bgcolor='#282828' width='" + WIDTH + "' height='" + HEIGHT + "' swLiveConnect='true' id='" + ObjectID + "' name='" + ObjectID + "' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
}


function popen(mypage)
{
props=window.open(alldns + '/openedit.php?edit=' + mypage, 'editpage', 'toolbars=0, scrollbars=1, location=0, statusbars=1, menubars=0, resizable=0, width=1000, height=700 left = 100, top = 100');
}


function editimg(edit, mypage)
{
props=window.open(alldns + '/editimg.php?edit=' + edit + '&page=' + mypage, 'editpage', 'toolbars=0, scrollbars=1, location=0, statusbars=1, menubars=0, resizable=0, width=650, height=680 left = 100, top = 100');
}

function metaMove()
{
	
    while (document.meta.ord.selectedIndex != -1)
    {
        if (document.meta.ord.selectedIndex != -1)
		{
		document.meta.script.value += document.meta.ord.options[document.meta.ord.selectedIndex].value + ", ";
        document.meta.ord.options[document.meta.ord.selectedIndex].selected = false;
		}
    }
    
}


//notice fältet
function mark(what)
{
if (what == "speedd")
{
document.all.newTxt.scrollAmount = 3;
document.all.newTxt.style.color='gray';
}
else if (what == "speedu")
{
document.all.newTxt.scrollAmount = 6;
document.all.newTxt.style.color='';
}
else if (what == "stop")
{
document.all.newTxt.stop();
}
else if (what == "start")
{
document.all.newTxt.start();
}
}

//skapa en tab i textboxen
function UseTab(obj) {
   var tabKeyCode = 9;
   if (event.keyCode == tabKeyCode && event.srcElement == obj) {
      obj.selection = document.selection.createRange();
      obj.selection.text = String.fromCharCode(tabKeyCode);
      event.returnValue = false;
   }
}

function update(name){
page = eval("document.form." + name + ".options[document.form." + name + ".selectedIndex].value");
location.href=page + "&lnamn=" + document.form.namn.value;
}

//sätter bredd o höjd per rad för produkterna
function setprops(name)
{
//tar emot clips value
clip = eval("document.vanstermeny." + name + ".options[document.vanstermeny." + name + ".selectedIndex].value");

var nr = name.indexOf("ip",1);
var nummer = name.substring(nr + 2,name.length);
var pheight = "propheight" + nummer;
var pwidth = "propwidth" + nummer;

//sätter höjd och bredd
if (clip == 1)
{
eval("document.vanstermeny." + pheight + ".value = 0;");
eval("document.vanstermeny." + pwidth + ".value = 510;");
}
else if (clip == 2)
{
eval("document.vanstermeny." + pheight + ".value = 0;");
eval("document.vanstermeny." + pwidth + ".value = 240;");
}
else if (clip == 3)
{
eval("document.vanstermeny." + pheight + ".value = 0;");
eval("document.vanstermeny." + pwidth + ".value = 150;");
}

}

function sredigerapic(obj)
{
document.getElementById(obj).style.visibility = "visible";
}

function hredigerapic(obj)
{
document.getElementById(obj).style.visibility = "hidden";
}


//gör så att personen kan se bilden han/hon har laddat upp.
function showpic(id)
{
var hittarid = id.indexOf('src');
var len = id.length;
var newid = id.substring(hittarid + 3,len);
var previd = id.substring(0,hittarid + 3);
var what = "jpg";
var url = eval("document.vanstermeny.bildurl" + newid + ".value");
var url = url.toLowerCase();

//kollar om det är en bild personen försöker ladda upp
if (url.indexOf("jpg") != -1 || url.indexOf("gif") != -1)
{
document.all[id].style.display = "";
//document.getElementById("t" + id).style.display = "";
document.getElementById("t" + id).src = eval("document.vanstermeny.bildurl" + newid + ".value");
eval("document.vanstermeny.bildnew" + newid + ".checked=true");
}
else
{
eval("document.vanstermeny.bildurl" + newid + ".value = ''");
alert('Du kan bara ladda upp bilder!');
}

}


//visar nästa produkt personen har klickat på
function next(what,xsel)
{

if (what == "next")
{
if (xsel == "")
{
xsel = 0;
}

if (xsel+1 <= max)
{
xsel += 1;
}

}
else if (what == "prev")
{

if (xsel-1 >= 1)
{
xsel = (xsel - 1);
}
}

if (xsel == max)
{
document.all["pronast"].style.visibility = "hidden";
}
else
{
document.all["pronast"].style.visibility = "visible";
}

if (xsel <= 1)
{
document.all["proprev"].style.visibility = "hidden";
}
else
{
document.all["proprev"].style.visibility = "visible";
}

lank=document.listner.listner.value;
lanlank = lank.length;
where1 = lank.indexOf('&xpage');

if (where1 != -1)
	{
newlank = lank.substring(where1+7,lanlank);
	}
else
	{
newlank = '';
	}

pid = eval("document.nastalanklistner.lank" + xsel + ".value");
document.all['proframe'].src = "xprodukt.php?pid=" + pid + "&rand=23&xpage=" + newlank;
}


//fixar en disable funktion för nästa och foregoende funktionen
function dis(what)
{
max = document.nastalanklistner.number.value;
pathselectedid = document.all['proframe'].src;
where1 = pathselectedid.indexOf('?');
where2 = pathselectedid.indexOf('&');
len = pathselectedid.length;
selectedid = pathselectedid.substring(where1+5,where2);

for (i=1;i<=max;i++)
{
if (eval("document.nastalanklistner.lank" + i + ".value == '"+ selectedid +"'"))
{
xsel = i;
is = xsel;
}
}
next(what,xsel);
}


//gör så att personen kan redigera texten i textarean
function red(what)
{
text = document.infoform.text.value;
textlen = text.length;
if (document.selection)
{
findtext = document.selection.createRange().text;

if (text.match(findtext))
{
lenfindtext = findtext.length;
bryt1 = text.indexOf(findtext);
bryt2 = bryt1 + lenfindtext;
txt1 = text.substring(0,bryt1);
txt2 = text.substring(bryt2,textlen);
txt3 = text.substring(bryt1,bryt2);
document.infoform.text.value = txt1 + '[' + what + ']' + txt3 + '[/' + what + ']' + txt2;
}
else
{
alert('Kunde inte hitta texten i textboxen!');
}
}
}


function changesort(url)
{
window.location.href = url;
}

function showinfo(id)
{

if (document.getElementById(id).style.display == "none")
{
document.getElementById(id).style.display = '';
document.getElementById('b1' + id).style.borderBottomColor = '#ecf3ed';
document.getElementById('b2' + id).style.borderBottomColor = '#ecf3ed';
}
else
{
document.getElementById(id).style.display = 'none';
document.getElementById('b1' + id).style.borderBottomColor = 'white';
document.getElementById('b2' + id).style.borderBottomColor = 'white';
}

}

// fäller ut menyn
function foldmenu(object,img)
{

word = document.getElementById(img).src.substring(document.getElementById(img).src.length-10);

if (word == "xpoint.gif")
	{
document.getElementById(object).style.display = 'none';
document.getElementById(img).src = alldns+'/bilder/point.gif';
	}
else
	{
document.getElementById(object).style.display = '';
document.getElementById(img).src = alldns+'/bilder/xpoint.gif';
	}

}




// stänger menyn
function showproinfo(object)
{

if (document.getElementById(object).style.display == 'none')
{
document.getElementById(object).style.display = '';
}
else
{
document.getElementById(object).style.display = 'none';
}

}



function check()
{

if (document.kon.fname.value == "")
{
	alert('Var god och fyll i ditt förnamn!');
return false;
}
else if (document.kon.lname.value == "")
{
	alert('Var god och fyll i ditt efternamn!');
return false;
}
else if (document.kon.email.value.indexOf("@") == -1 || document.kon.email.value.indexOf(".") == -1) 
	{
	alert("Var god ange en giltig epostadress i fältet E-postadress!");
return false;
	}
else
{
return true;
}

}


function ask(id)
{

if (confirm('Objekten kommer att raderas!\nVill du fortsätta?'))
{
location.href= alldns + '/spara.php?page=nyheter&underpage=radera&nid=' + id;
return true;
}
else
{
return false;
}

}


function arkiv(myForm)
{
	//tar emot arkiv
code = eval("document." + myForm + ".arkivurl.options[document." + myForm + ".arkivurl.selectedIndex].value");
eval("document." + myForm + ".code.value='[" + code + "]';");
}