function getObj(name) {
  if (document.getElementById) {
		return document.getElementById(name).style;
	} else if (document.all) {
		return document.all[name].style;
	} else if (document.layers) {
		return document.layers[name];
	} else 
		return false;
}

function openWin(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

var changed = 0;
function saveData() {
	document.tablesform.BTNSAVEAUTO.value = 1;
	if (typeof(document.tablesform.onsubmit) == "function") { 
		document.tablesform.onsubmit();
	}
	document.tablesform.submit();

}

var tools = true;

function toggleDesc(id) {
	objCurrentOpen = document.getElementById(id+"open");
	objCurrentOpen.style.display = (objCurrentOpen.style.display=="none" ? "block" : "none");

	objCurrentLong = document.getElementById(id+"Long");
	objCurrentLong.style.display = (objCurrentLong.style.display=="none" ? "block" : "none");

	objCurrentClose = document.getElementById(id+"close");
	objCurrentClose.style.display = (objCurrentClose.style.display=="none" ? "block" : "none");
	
	objIsopen = document.getElementById("isopen_"+id);
	objIsopen.value = (objIsopen.value=="0" ? "1" : "0");
	//alert(objIsopen.value);
	//return (objCurrentClose.style.display=="block" ? true : false);
}

function obj_exists(id) {
  if (document.getElementById && document.getElementById(id)) return true
  if (document.all && document.all(id)) return true
  if (document.layers && document.layers[id]) return true
 return false
}


//new stuff

var browser = new dudiBrowser();

function dudiBrowser() {

	// is DOM
	this.DOM = document.getElementById?1:0;
	
	// is IE
	this.IE = document.all?1:0;
	
	// is NS
	this.NS = (!this.DOM && !this.IE)?1:0
	
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);

 

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 startRoller() {
	var roller,rollerW;
	// getting width
	if(browser.DOM && !browser.IE) {
		widthcontainer = document.getElementById('widthcontainer');
		rollerW = widthcontainer.offsetWidth;
	} else {
		if((roller=MM_findObj("content"))!=null){rollerW=(document.layers)?roller.clip.width:roller.offsetWidth;}else{return;}
	}
	
	P7AniMagic('content',-(rollerW + 210),0,1,20,1,0);
}

function P7AniMagic(el,x,y,a,b,c,s) { //v2.9 PVII-Project Seven Development

	

 	var xx,yy,i,g,elo=el,f="",m=false,d="",pa='px';
	
	if(document.layers||window.opera){pa='';}

 	x=parseInt(x);
	y=parseInt(y);
	
	var t='g.p7Magic=setTimeout("P7AniMagic(\''+elo+'\','; 

 	if((g=MM_findObj(el))!=null){d=(document.layers)?g:g.style;}else{return;}
	
 	if(parseInt(s)>0){eval(t+x+','+y+','+a+','+b+','+c+',0)",' + s+')');return;}

 		xx=parseInt(d.left);if(isNaN(xx)){if(g.currentStyle){xx=parseInt(g.currentStyle.left);

 	}else if(document.defaultView&&document.defaultView.getComputedStyle){

 xx=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("left"));}

 if(isNaN(xx)){xx=0;}}yy=parseInt(d.top);if(isNaN(yy)){if(g.currentStyle){yy=parseInt(g.currentStyle.top);

 }else if(document.defaultView&&document.defaultView.getComputedStyle){

 yy=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("top"));}

 if(isNaN(yy)){yy=0;}}if(c==1){x+=xx;y+=yy;m=true;c=0;}else if(c==2){m=false;

 if(g.p7Magic){clearTimeout(g.p7Magic);}}else{i=parseInt(a);if(g.p7Magic){clearTimeout(g.p7Magic);}

 
 if(xx<x){
 	xx+=i;
	m=true;
	if(xx>x){
		xx=x;
	}
 } 
 
 if(xx>x){
 	xx-=i;
	m=true;
	if(xx<x){
		xx=x;
	}
 }
 
 if(yy<y){yy+=i;m=true;if(yy>y){yy=y;}}if(yy>y){yy-=i;m=true;if(yy<y){yy=y;}}}

 if(m){
 	d.left=xx+pa;d.top=yy+pa;eval(t+x+','+y+','+a+','+b+','+c+',0)",'+b+')');
 } else {
 	if(g.p7Magic){clearTimeout(g.p7Magic);}
	d.left=210;
 	startRoller();
 }

}

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_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_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];}
}

function loadMov(sMovieUrl, iWidth, iHeight,navi,boost){

	var sReturn = "";
		
		sReturn += '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">\n';

		sReturn += '<PARAM NAME="src" VALUE="'+sMovieUrl+'">\n';

		sReturn += '<PARAM NAME="AUTOPLAY" VALUE="true">\n';

		sReturn += '<PARAM NAME="CONTROLLER" VALUE="'+navi+'">\n';
		
		if(boost)
			sReturn += '<PARAM NAME="VOLUME" VALUE="400">\n';

		sReturn += '<EMBED SRC="'+sMovieUrl+'" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'" AUTOPLAY="true" CONTROLLER="true" ##SHOW_START_BOOST##volume="400"##SHOW_END_BOOST## BGCOLOR="#000000" PLUGINSPAGE="http://www.apple.com/quicktime/download/"></EMBED>\n';

		sReturn += "</OBJECT>\n";

		document.write(sReturn);

}

// Opens a popup - <a href="http://dwarf.dk/ onclick="return setPopup(this, 300, 300)">
function setPopup(oThis, sHeight, sWidth, bResize, bScroll, bMenu, bLocation, bToolbar){
	var sUrl;
	if(typeof(oThis) == "string"){sUrl = oThis}else{sUrl=oThis.href}
	if(bResize){bResize="resizable"}else{bResize="resizable=0"}
	if(bScroll){bScroll="scrollbars"}else{bScroll="scrollbars=0"}
	if(bMenu){bMenu="menubar"}else{bMenu="menubar=0"}
	if(bLocation){bLocation="location"}else{bLocation="location=0"}
	if(bToolbar){bToolbar="toolbar"}else{bToolbar="toolbar=0"}
	var dwarfPopup = window.open(sUrl, "dwarfPopup", "width=" + sWidth + ", height=" + sHeight + ", " + bResize + ", " + bScroll + ", " + bMenu + ", " + bLocation + ", " + bToolbar + "");
	
	return false;
}

function favorite(mid,cid,divid){
	
	if($(divid).checked==true)
		type='on';
	else
		type='off';
	
	new Ajax.Request('/scripts/ajax/add_to_fav.php?mid='+mid+'&cid='+cid+'&type='+type, {asynchronous:true});
	
}