$(document).ready(function(){
    $('.ceebox').ceebox({
        htmlGallery: false
    });
});

$(window).resize(function() { reSize(); });

function submitUpload(url, uid)
{
    document.getElementById("uploadFormTable").style.display = 'none';
    document.uploaderForm.action = url;
    document.uploaderForm.submit();
    document.getElementById("progress").innerHTML = "Locating upload request...";
    beginFrameRefresh(uid);
}
function beginFrameRefresh(uid) { setTimeout('refreshProgress('+uid+')', 50); }
function refreshProgress(uid)
{
    var date = new Date();
    $("#progress").load('api/ext_widgetFactory.php?type=progressbar&uid='+uid+'&unique='+date.getTime());
    setTimeout('refreshProgress('+uid+')', 200);
}
function setReviewState(obj)
{
    var num = obj.innerHTML;
    document.getElementById("ratingHidden").value = num;
    var rView = obj.parentNode.parentNode;
    
    if (num == 1) { rView.className = "rating onestar"; }
    if (num == 2) { rView.className = "rating twostar"; }
    if (num == 3) { rView.className = "rating threestar"; }
    if (num == 4) { rView.className = "rating fourstar"; }
    if (num == 5) { rView.className = "rating fivestar"; }
}

function getMemberID(v)
{
	$.get('api/ext_widgetFactory.php?type=getMID&member=' + v, function(data) {
		if (data == '0') {
			document.getElementById("rAuthorName").style.backgroundColor = "#ffcccc";
			document.getElementById("rAuthorID").value = v;
		}
		else
		{
			document.getElementById("rAuthorName").style.backgroundColor = "#98FB98";
			document.getElementById("rAuthorID").value = data;
		}
	});
}

function reSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if (myWidth < 1025)
  {
      var cont = document.getElementsByClassName('ssImg', document.getElementById('screenshots'));
      for (var z=0; z<cont.length; z++)
      {
        cont[z].style.width = "320px";
        cont[z].style.height = "175px";
        document.getElementsByClassName('gameTitle')[0].style.width = "340px"
        document.getElementById('mainContainer').style.width = "340px"
      }
  }
  else
  {
    var cont = document.getElementsByClassName('ssImg', document.getElementById('screenshots'));
      for (var z=0; z<cont.length; z++)
      {
        cont[z].style.width = "640px";
        cont[z].style.height = "350px";
      }
      document.getElementsByClassName('gameTitle')[0].style.width = "680px";
      document.getElementById('mainContainer').style.width = "680px";
      document.getElementById('screenshots').style.height = "200px";
  }
}

function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

