﻿// JScript File


function forhandsgranskaBild(bildID,textfalt)
{

	if(document.all[textfalt].value != "")
	{
		// kolla så att bilden är gif eller jpg
		if(document.all[textfalt].value.indexOf(".gif") != -1 || document.all[textfalt].value.indexOf(".GIF") != -1 || document.all[textfalt].value.indexOf(".jpg") != -1 || document.all[textfalt].value.indexOf(".JPG") != -1)
		{
			document.all[bildID].src = document.all[textfalt].value;
		}

		else
		{
			document.all[bildID].src = "/_products/_images/ogiltig_bild.gif";
		}
	}
}


function popupWin(URL, width, height)
{
	window.open(URL,"spec","width="+ width +", height="+ height +", status=no, resizable=yes, left=100, top=20, scrollbars, dependent, toolbar=no");
}

function popupNamedWin(URL, winName, width, height)
{
	window.open(URL,winName,"width="+ width +", height="+ height +", status=no, resizable=yes, left=100, top=20, scrollbars, dependent, toolbar=no");
}


function deleteImage(URL)
{
	var ItemID;
	//ItemID = radioValue(document.aspnetForm.rbImageID);
	//URL = URL + "?ItemID=" + ItemID;
	if(confirm('This will permanently delete the image. Do you want to continue?')!= false) return true;
	//document.location = URL
}

function radioValue(radioButton)
{
	for (var x = 0; x <= radioButton.length-1; x++)
	{
		if (radioButton[x].checked == true) return radioButton[x].value;
	}
	return radioButton.value;
} 


function refreshPage(URL)
{
	document.location=URL;
}


function popupWinMenu(URL)
{
    window.open(URL,"spec","width=450, height=650, status=no, resizable=yes, left=100, top=20, scrollbars, dependent, toolbar=no");
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//	TinyMCE 

var image_form_win;

function fileBrowserCallBack(field_name, url, type, win) {

	image_form_win = win;

	if(type=="image")
	{
		window.open("/website_admin/admin/tinymce/valj_bild.aspx?fild_name="+ field_name +"&window_name="+ win.name +"","selectImage", "toolbar=no,scrollbars=yes,resizable=yes,width=550,height=580"); 
	}

	else
	{
		window.open("/website_admin/admin/tinymce/valj_lank.aspx?fild_name="+ field_name +"&window_name="+ win.name +"","selectImage", "toolbar=no,scrollbars=yes,resizable=yes,width=550,height=580"); 
	}
}


function getImageURLFromOther(field_name,url)
{
	image_form_win.document.forms[0].elements["src"].value = url;
}


function getURLFromOther(field_name,url)
{
	image_form_win.document.forms[0].elements["href"].value = url;
}

//	Slut TinyMCE 
