allowchange = 1

function gotodvd(v)
{
  with(v)
  {
    document.location = id[id.selectedIndex].value
  }

  return false;
}

function changevote(v)
{
  if (allowchange == 0)
  {
	return
  }

  for (i = 1; i <= 5; i++)
  {
    fr = document.getElementById("vote_" + i)

	src = ""

	if (v == ((i - 1) * 2) + 1)
	{
		src = "-half.gif"
	}
	else if (v < (i * 2))
	{
		src = "-faded.gif"
	}
	else
	{
		src = ".gif"
	}

    fr.src = "images/icons/star" + src
  }
}

function changevote2(v)
{
  if (allowchange == 0)
  {
	return
  }

  for (i = 1; i <= 5; i++)
  {
    fr = document.getElementById("vote_" + i)

	src = ""

	if (v == ((i - 1) * 2) + 1)
	{
		src = "-half2.gif"
	}
	else if (v < (i * 2))
	{
		src = "-faded2.gif"
	}
	else
	{
		src = "2.gif"
	}

    fr.src = "images/icons/star" + src
  }
}



function dovote(v, id, type)
{
  if (allowchange == 0)
  {
     return
  }

  if (window.XMLHttpRequest)
  {
    // If IE7, Mozilla, Safari, etc: Use native object
    var http = new XMLHttpRequest()
  }
  else
  {
     if (window.ActiveXObject)
     {
        // ...otherwise, use the ActiveX control for IE5.x and IE6
        var http = new ActiveXObject("Microsoft.XMLHTTP");
     }
  }


  var url = "vote.php"
  var params = "contentgroup=" +id+ "&vote=" + v + "&type=" + type + "&ajax=1"

  http.open("GET", url+"?"+params, true);
  http.onreadystatechange = function() 
  {
     	if(http.readyState == 4 && http.status == 200) 
        {
		  if (http.responseText == "done")
		  {
		    alert("Thank you for rating this update.");
			changevote(v)
		    allowchange= 0
        }
		  else
		  {
			alert("There was an error recording your vote.  Please try again later");
          	  }
	}
  }

  http.send(null);
}


function domodelvote(v, id)
{
  if (allowchange == 0)
  {
     return
  }

  if (window.XMLHttpRequest)
  {
    // If IE7, Mozilla, Safari, etc: Use native object
    var http = new XMLHttpRequest()
  }
  else
  {
     if (window.ActiveXObject)
     {
        // ...otherwise, use the ActiveX control for IE5.x and IE6
        var http = new ActiveXObject("Microsoft.XMLHTTP");
     }
  }


  var url = "vote.php"
  var params = "set=" +id+ "&vote=" + v + "&ajax=1"

  http.open("GET", url+"?"+params, true);
  http.onreadystatechange = function() 
  {
     	if(http.readyState == 4 && http.status == 200) 
        {
		  if (http.responseText == "done")
		  {
		    alert("Thank you for rating this model.");
			changevote2(v)
		    allowchange= 0
        }
		  else
		  {
			alert("There was an error recording your vote.  Please try again later");
          	  }
	}
  }

  http.send(null);
}

function jsgallery(cg, id, fid, settype, mt)
{
  var url = "image.php?cg=" + cg + "&type=" + settype + "&id=" + fid 
  if (mt != "")
  {
     url = url + "&mt=" + mt
  }
  url = url + "#id=" + id
  document.location = url
  return false
}

function retPicarr(picarr, id)
{
  for(i = 0; i < picarr.length; i++)
  {
    if (picarr[i][0] == id)
    {
	   return picarr[i]
    }
  }
}


function getPlayer(gid) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[gid];
	} else {
		return document[gid];
	}
};

function playerReady(obj) 
{
    setTimeout("playerReady2()", 100);
}


function cPlayer(prr)
{
	pvv = 0;

	if (prr.length == 0)
	{
		return;
	}

    pa = retPicarr(prr, id)

    imgg = pa[1]
    wdth = parseInt(pa[2])
    hdth = parseInt(pa[3]) + 15

	barwidth= 150

	if (picarr.length == 1)
	{
		barwidth = 0
	}

	var s1 = new SWFObject("mediaplayer.swf","playerID",wdth+barwidth, hdth,"8");
	s1.addParam("allowfullscreen","true");
	s1.addParam("allowscriptaccess","always");
	s1.addVariable("autostart","false");
	s1.addVariable("smoothing","true");
	s1.addVariable("width",wdth+barwidth);
	s1.addVariable("height",hdth);

	if (barwidth != 0)
	{
		s1.addVariable("playsize",barwidth);
		s1.addVariable("playlist","right");
	    s1.addVariable("thumbsinplaylist","true")
	    s1.addVariable("repeat", "true");
		s1.addVariable("shuffle","false");
	}

	//s1.addVariable("streamscript","stream.php");

 	s1.write("mediabox");


  if (document.getElementById("sharevideourl") != undefined)
  { 
    spu = pa
    document.getElementById("sharevideourl").href = "share.php?id=" + spu[0] + "&type=" + spu[4] + "&mt=" + spu[5]
  }

}







function RenderImg(picarr, id, divv)
{
  var poss = 0;
  dv = document.getElementById(divv)

  for(i = 0; i < picarr.length; i++)
  {
    if (picarr[i][0] == id)
    {
       imgg = picarr[i][1]
	   wdth = picarr[i][2]
	   hdth = parseInt(picarr[i][3]) + 75
	   movtype = picarr[i][4]
	   movname= picarr[i][5]
       poss = i
    }
  }

  if (dv == undefined)
  {
    return true
  }
  

  noman = document.getElementById("nomansland")


  var dot = imgg.lastIndexOf("."); 
  var extt = imgg.substr(dot,imgg.length); 

  if (movtype == undefined)
  {
    movtype = ""
  }

  if (movname == undefined)
  {
    movname = ""
  }

  if ((movname.indexOf("divx") != -1) || (movname.indexOf("xvid") != -1))
  {
	hdth = hdth - 55

     dc1 = document.location + ''
     dc = dc1.substring(7, dc1.indexOf('/',7)+1)
     dc = dc1.substr(0, 7) + dc;

	 imgg = dc + imgg


	inht = ""
	inht += '<object classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616" width="'+wdth+'" height="'+hdth+'" ' 
	inht += ' codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab">'
	inht += ' <param name="custommode" value="none" />'
	inht += '  <param name="src" value="'+imgg+'" />'
	inht += '<embed type="video/divx" src="'+imgg+'" custommode="none" width="'+wdth+'" height="'+hdth+'" '
	inht += ' pluginspage="http://go.divx.com/plugin/download/">'
	inht += '</embed>'
	inht += '</object>'
	inht += '<p style="color:white;">No video? Get the DivX Web Player for <a style="text-decoration: underline;" ' 
	inht += ' href="http://download.divx.com/player/DivXWebPlayerInstaller.exe">Windows</a> or '
	inht += '<a style="text-decoration: underline;" href="http://download.divx.com/player/DivXWebPlayer.dmg">Mac</a></p>'

	dv.innerHTML = inht
  }
  else if ((extt == ".mov"))
  {

	inht = ""
	inht += '<object type="video/quicktime" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+wdth+'" height="'+hdth+'">'
	inht += ' <param name="src" value="'+imgg+'" />'
	inht += ' <param name="autostart" value="true" />'
	inht += ' <param name="controller" value="true" />'
	inht += ' <object type="video/quicktime" data="'+imgg+'" width="'+wdth+'" height="'+hdth+'">'
	inht += '  No video?  Get the quicktime player.'
	inht += ' </object>'
	inht += '</object>'

	dv.innerHTML = inht
  }
  else if ((extt == ".rm") || (extt == ".rmvb"))
  {
	 inht = ""

     dc1 = document.location + ''
     dc = dc1.substring(7, dc1.indexOf('/',7)+1)
     dc = dc1.substr(0, 7) + dc;

	 imgg = dc + imgg



	 inht += '<OBJECT ID=RVOCX CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH="'+wdth+'" HEIGHT="'+hdth+'"> '
	 inht += '<PARAM name="src" value="'+imgg+'"> '
	 inht += '<PARAM name="autostart" value="true"> '
	 inht += '<PARAM name="controls" value="imagewindow"> '
	 inht += '<PARAM name="console" value="video"> '
	 inht += '<EMBED TYPE="audio/x-pn-realaudio-plugin" SRC="'+imgg+'" WIDTH="'+wdth+'" HEIGHT="'+hdth+'" AUTOSTART="tue" CONTROLS="all" CONSOLE="video"> '
	 inht += '</EMBED> '
	 inht += '</OBJECT><br />'

	 inht += '<OBJECT ID=RVOCX CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH="'+wdth+'" HEIGHT=36>'
	 inht += '<PARAM NAME="CONTROLS" VALUE="ControlPanel">'
	 inht += '<PARAM NAME="CONSOLE" VALUE="video">'
	 inht += '<EMBED SRC="plugin.rpm" WIDTH=350 HEIGHT=36 NOJAVA=true CONTROLS=ControlPanel CONSOLE=one>'
	 inht += '</OBJECT>'




	dv.innerHTML = inht
  }
  else if (noman == undefined)
  {
    htm = '<img src="' + imgg + '" />'
    dv.innerHTML = htm
  }
  else
  {
	 inht = ""

	 //inht += "<font color='white'>" + imgg + "</font><br />";
	 inht += "<object id='mediabox' ";
	 inht += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' ";
	 inht += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' ";
	 inht += "standby='Loading Microsoft Windows Media Player components...' ";
	 inht += "type='application/x-oleobject' width='"+wdth+"' height='"+hdth+"''> ";
	 inht += "<param name='fileName' value=\""+imgg+"\"/> ";
	 inht += "<param name='animationatStart' value='true' /> ";
	 inht += "<param name='transparentatStart' value='true' /> ";
	 inht += "<param name='autoStart' value=\"true\" /> ";
	 inht += "<param name='showControls' value=\"true\" /> ";
	 inht += "<param name=\"ShowStatusBar\" value=\"true\" /> ";
	 inht += "<param name='loop' value=\"0\" /> ";
	 inht += "<embed type='application/x-mplayer2' ";
	 inht += "pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' ";
	 inht += "autostart=\"1\" ";
	 inht += "displaysize='4' ";
	 inht += "autosize='0' ";
	 inht += "bgcolor='black' ";
	 inht += "showcontrols=\"1\" "; 
	 inht += "showtracker='1' ";
	 inht += "showstatusbar='1' ";
	 inht += "showdisplay='0' ";
	 inht += "videoborder3d='0' ";
	 inht += "designtimesp='5311' ";
	 inht += "loop=\"0\" src='"+imgg+"' width='"+wdth+"' height='"+hdth+"'> ";
	 inht += "</embed>"
	 inht += "</object>"

     dv.innerHTML = inht
  }



  
  prevcss = (poss == 0) ? "nav_hid" : "nav_vis"
  nextcss = (poss == picarr.length - 1) ? "nav_hid" : "nav_vis"

  document.getElementById("gal_prevpage").className = prevcss
  document.getElementById("gal_nextpage").className = nextcss

  if (document.getElementById("sharevideourl") != undefined)
  { 
    spu = picarr[poss]
    document.getElementById("sharevideourl").href = "share.php?id=" + spu[0] + "&type=" + spu[4] + "&mt=" + spu[5]
  }

  return false

}

function NextImage()
{
  nid = 0

  for(i = 0; i < picarr.length; i++)
  {
    if (picarr[i][0] == id)
    {
       nid = i
    }
  }

  if (picarr[nid+1] != undefined)
  {
	if (picarr[nid+1][1] == "#trial#")
	{
	    document.location = nourl
	    return false
	}

    id = picarr[nid+1][0]
    imgg = picarr[nid+1][1]

    noman = document.getElementById("nomansland")
    flash = document.getElementById("flashplayer")


    if (flash != null)
	{
		ply = getPlayer("playerID")
		itm = parseInt(ply.getConfig().item) + 1
		ply.sendEvent("ITEM", itm);
		ply.sendEvent("PLAY", "true");
		
	    if (document.getElementById("sharevideourl") != undefined)
	    { 
	      spu = picarr[nid+1]
	      document.getElementById("sharevideourl").href = "share.php?id=" + spu[0] + "&type=" + spu[4] + "&mt=" + spu[5]
	    }

	
		document.location = "#id=" + id

		prevcss = (nid+1 == 0) ? "nav_hid" : "nav_vis"
		nextcss = (nid+1 == picarr.length - 1) ? "nav_hid" : "nav_vis"
		
		document.getElementById("gal_prevpage").className = prevcss
		document.getElementById("gal_nextpage").className = nextcss
	}
    else if (noman != null)
	{
		document.location = "#id=" + id
		window.location.reload();
	}
	else
	{
		document.location = "#id=" + id
    	return RenderImg(picarr, id, "mediabox")
	}
  }

  return false
}

function PrevImage()
{
  nid = 0

  for(i = 0; i < picarr.length; i++)
  {
    if (picarr[i][0] == id)
    {
       nid = i
    }
  }

  if (picarr[nid-1] != undefined)
  {
	if (picarr[nid-1][1] == "#trial#")
	{
	    document.location = nourl
	    return false
	}

    id = picarr[nid-1][0]
    imgg = picarr[nid-1][1]



    noman = document.getElementById("nomansland")
    flash = document.getElementById("flashplayer")


	
    if (flash != null)
	{
		ply = getPlayer("playerID")
		itm = parseInt(ply.getConfig().item) - 1
		ply.sendEvent("ITEM", itm);
		ply.sendEvent("PLAY", "true");


	    if (document.getElementById("sharevideourl") != undefined)
	    { 
	      spu = picarr[nid-1]
	      document.getElementById("sharevideourl").href = "share.php?id=" + spu[0] + "&type=" + spu[4] + "&mt=" + spu[5]
	    }

		document.location = "#id=" + id

		prevcss = (nid-1 == 0) ? "nav_hid" : "nav_vis"
		nextcss = (nid-1 == picarr.length - 1) ? "nav_hid" : "nav_vis"
		
		document.getElementById("gal_prevpage").className = prevcss
		document.getElementById("gal_nextpage").className = nextcss
	}
    else if (noman != null)
	{
		document.location = "#id=" + id
		window.location.reload();
		return false
	}
	else
	{
		document.location = "#id=" + id
    	return RenderImg(picarr, id, "mediabox")
	}
  }

  return false
}

function playState(obj)
{
  ind = obj.index

  if (document.getElementById("sharevideourl") != undefined)
  { 
    spu = picarr[ind]
    document.getElementById("sharevideourl").href = "share.php?id=" + spu[0] + "&type=" + spu[4] + "&mt=" + spu[5]
  }

}

