//Ger fokus på inskickat id.
function setfocus(objectid) 
{
	if(document.getElementById(objectid)) 
	{
		document.getElementById(objectid).focus(); 
	}
}
function hideDiv(id)
{
	if(document.getElementById(id)) 
	{
	   document.getElementById(id).style.display = 'none'
	}
}
function showDiv(id)
{
	if(document.getElementById(id)) 
	{
	   document.getElementById(id).style.display = 'block';
	}
}

/*** En CrossOver getobject by Id funktion.***/
function returnObjById( id ) 
{ 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id]; 
    return returnVar; 
} 

/*** Change backgroundclass on hover.***/
function trBgChange(me)
{
	if(me.className == "trBg")
	{
		me.className="trBgHover";
	}else
	{
		me.className="trBg";
	}
	
}


/*** Span Hide/Show function.***/
var activeSpan = 0;
function changeSpan(idName)
{	
	if (activeSpan != 0)
	{
		if (activeSpan == idName)
		{
			document.getElementById(idName).style.display = "none";
			activeSpan = 0;
		}
		else
		{
			document.getElementById(activeSpan).style.display = "none";		
			document.getElementById(idName).style.display = ""; 			
			activeSpan = idName
		}
	}
	else
	{
		document.getElementById(idName).style.display = ""; 					
		activeSpan = idName
	}	
}

	
function showSpan(idName)
{	
	if(document.getElementById(idName))
	{
		document.getElementById(idName).style.display = "";
		activeSpan = idName
	}
}

/*** General popup-funktion ***/
function openPopupWindow(strUrl, strWindowName, paramWidth, paramHeight, paramScrollbars, paramresizable) {
	var objNewWin;
	var strWindowFeatures;
	strWindowFeatures = 'width='+paramWidth+',height='+paramHeight+',scrollbars='+paramScrollbars+',resizable='+paramresizable+',status=0,toolbar=0,menubar=0,location=0,directories=no'
	objNewWin = window.open(strUrl, strWindowName, strWindowFeatures);
	if (objNewWin != null) {
		objNewWin.focus();
	}
}

/*** Popup for Tip A Friend ***/
function openTipAFriend(strUrl) {
	var strUrl='/shop/shopfunctions/tipAFriend.asp?strUrl='+strUrl;
	openPopupWindow(strUrl, 'Specter_Tip_a_friend', 376, 320, 0, 0)
}

/*** Popup for printer-friendly version ***/
function openPrintable(strUrl) {
	var strUrl=strUrl;
	var strWindowName = 'Specter_webshop_printable';
	var strWindowFeatures = 'width=630,height=600,scrollbars=1,resizable=1,status=1,toolbar=1,menubar=1,location=0';
	var objNewWin = window.open(strUrl, strWindowName, strWindowFeatures);
	objNewWin.focus();
}



/*** popup med fino som matas in. ***/
function openInfoPopupWindow(strUrl, infoText, strWindowName, paramWidth, paramHeight) {
	var objInfoWin;
	var strWindowFeatures;
	var leftVal, topVal;
    leftVal = (screen.width - paramWidth) / 2;
	topVal = (screen.height - paramHeight) / 2;
    
	strWindowFeatures = 'width='+ paramWidth +',height='+ paramHeight +',left='+ leftVal +',top='+ topVal +',scrollbars=1,resizable=YES,status=0,toolbar=0,menubar=0,location=0,directories=no';
	objInfoWin = window.open(strUrl,strWindowName, strWindowFeatures);
	if (objInfoWin != null) {
		objInfoWin.focus();

		if (strUrl == ""){
		    html = '<html>';
		    html += '<head>';
		    html += '<title>'+ strWindowName +'</title>';
		    html += '<link href="shop_css/shop_style.css" rel="stylesheet" type="text/css">';
		    html += '<link href="../style.css" rel="stylesheet" type="text/css">';
		    html += '</head>';
		    html += '<body topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">';
		    html += '<table width="100%" height="100%" border=0><tr><td width="100%" height="100%"><br>'+ infoText +'</td></tr>';
		    html += '<tr><td><a href="#" onClick="javascript:window.close();"><br>Close window</a><br><br></td></tr></table>';
		    html += '</body>';
		    html += '</html>';
		    
		    objInfoWin.document.write(html);
		  	}

	}
}

/*** Popup for view a picture ***/
function viewPicture(filename) 
{
    var myImage = new Image();
    myImage.src=filename;
    properties='height=10,width=10,top=170,left=250, scrollbars=1,resizable=YES';
    var imgWindow = window.open('','',properties);
    
    html = '<html>';
    html += '<head>';
    html += '<title>IMG</title>';
    html += '</head>';
    html += '<body topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">';
    html += '<table width="100%" height="100%" border=1><tr><td width="100%" height="100%" valign="middle" align="center" title="'+ trans_click_to_close_window +'" onClick="javascript:window.close();" ><font class=textBold><img src="'+ myImage.src +'" onLoad="resizeTo(document.bild.width+60,document.bild.height+100);" name="bild"></td></tr></table>';
    html += '</body>';
    html += '</html>';
    
    imgWindow.document.write(html);
}



//Visa/Dölj lager
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
	if ((obj=MM_findObj(args[i]))!=null) 
	{ 
		v=args[i+2];
	    if (obj.style) 
		{ 
			obj=obj.style; 
			v=(v=='show')?'visible':(v='hide')?'hidden':v; 
		}    
		obj.visibility=v; 
	}
}

function MM_findObj(n, d) { //v4.0
  	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 && document.getElementById) x=document.getElementById(n); 
		return x;
}


function showCalendar(calendarName) 
{
	// Detect if the browser is IE or not.
	// If it is not IE, we assume that the browser is NS.
	var IE = document.all?true:false
	
	// If NS -- that is, !IE -- then set up for mouse capture
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	
	// Set-up to use getMouseXY function onMouseMove  Om man vill att den ska följa med musen
	//	document.onmousemove = getMouseXY;
	
	// Temporary variables to hold mouse x-y pos.s
	var tempX = 0
	var tempY = 0
	
	// Main function to retrieve mouse x-y pos.s

	if (IE)
	{ // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} 
	else 
	{  // grab the x-y pos.s if browser is NS
    	tempX = e.pageX
		tempY = e.pageY
  	}  
	// catch possible negative values in NS4
	if (tempX < 0)
	{
		tempX = 0
	}
	if (tempY < 0)
	{
		tempY = 0
	}  
	// show the position values in the form named Show
	// in the text fields named MouseX and MouseY
	document.getElementById(calendarName).style.left = tempX - 92
	document.getElementById(calendarName).style.top = tempY - 54
	
	MM_showHideLayers(calendarName,'','show')

	return true
}

