
function resize_logo( pic )
{
	var MAX_LOGO_WIDTH = 540;
	var MAX_LOGO_HEIGHT = 400;
	
	var width_height_ratio = 0;
	
	var logo_height = pic.height;
	var logo_width = pic.width;
	
	// resize the image if its over the max limits.
	while ( logo_width > MAX_LOGO_WIDTH || logo_height > MAX_LOGO_HEIGHT )
	{
		width_height_ratio = logo_height / logo_width;
	
		if ( logo_height > logo_width )
		{
			if ( logo_height != MAX_LOGO_HEIGHT )
			{
				logo_height = MAX_LOGO_HEIGHT;
				logo_width = Math.round( logo_height / width_height_ratio );
			} else {			
				logo_width = MAX_LOGO_WIDTH;
				logo_height = Math.round( logo_width * width_height_ratio );
			}
		}
		else
		{
			if ( logo_width != MAX_LOGO_WIDTH )
			{
				logo_width = MAX_LOGO_WIDTH;
				logo_height = Math.round( logo_width * width_height_ratio );
			} else {				
				logo_height = MAX_LOGO_HEIGHT;
				logo_width = Math.round( logo_height / width_height_ratio );
			}
		}
	}
	
	pic.height = logo_height;
	pic.width = logo_width;
}


	function javascriptEnabled ()
	{
	  	if ( document.getElementById('verify_wins_1') )
		{
		  	for (var i = 1; i <= numBlocks; i++)
		  	{
		  		document.getElementById('verify_wins_' + i).style.display = 'block';
		  		document.getElementById('verif_wins_noJS_' + i).style.display = 'none';
		  	}
		}
	}

    function popUp( ladder_id, team_id, strikes ) {
	  var a = (screen.width - 500) / 2;
      var b = (screen.height - 350) / 2;
      window.open('http://socomarena.com/strikes_details.php?ladder=ladder_'+ladder_id + '&teamid='+team_id + '&strike'+strikes + '=yes', '_details', 'width=400,height=250,toolbar=0,statusbar=0,scrollbars=0,menubar=0,left='+a+',top='+b);
    }
    
    
    function StrikesStats( ladder_id, team_id, strikes ) {
	  var a = (screen.width - 500) / 2;
      var b = (screen.height - 350) / 2;
      window.open('http://socomarena.com/strikes_details.php?ladder=ladder_'+ladder_id + '&teamid='+team_id + '&strike'+strikes + '=yes', '_details', 'width=400,height=250,toolbar=0,statusbar=0,scrollbars=0,menubar=0,left='+a+',top='+b);
    }
    
    
    function Challenge( id, login, session ) {
	  var a = (screen.width - 600) / 2;
      var b = (screen.height - 600) / 2;
      var schedulerWin = window.open('http://socomarena.com/scheduler.php?PHPSESSID='+ session + '&chall_id='+id + '&loginid2='+ login, '_details', 'width=600,height=500,toolbar=0,statusbar=0,scrollbars=0,menubar=0,left='+a+',top='+b);
      schedulerWin.focus ();
    }
    
    
    function showAllMatches( id, session ){
	  var x = (screen.width - 600) / 2;
      var y = (screen.height - 600) / 2;
      var statsWindow = window.open('http://socomarena.com/stats_matches.php?PHPSESSID='+ session +'&id='+id, '_details', 'width=590,height=500,toolbar=0,statusbar=0,scrollbars=1,menubar=0,left='+x+',top='+y);
      statsWindow.focus ();
    }
    
    
    function ResendEmail( id, matchID, timestamp, session )
    {
      	var mess = "Are you sure you want to resend the verification email?";
		
      	var result = confirm(mess);
      	
      	if ( result == false )
      		return;
      
	  	var a = (screen.width - 500) / 2;
      	var b = (screen.height - 350) / 2;
      	var resendEmail = window.open('http://socomarena.com/verify_win.php?PHPSESSID='+ session +'&teamid='+id + '&matchid='+ matchID + '&c='+ timestamp + '&action=resend', '_email', 'width=400,height=250,toolbar=0,statusbar=0,scrollbars=0,menubar=0,left='+a+',top='+b);
      	resendEmail.focus ();
    }
    
    
    function ConfirmWin( id, matchID, timestamp, session )
    {
      	var mess = "By clicking OK you confirm the match has taken place.  If you do not recall playing the team please contact staff";
      		mess += " with the match ID, reportering teams ID and name, then decline the match.\n\n If your team is found taking";
			mess += " part in a fake win scam, the staff will delete both teams taking part and ban all IP's involved from the site.";
			mess += "\n\nDo you confirm this match has taken place?";
		
      	var result = confirm(mess);
      	
      	if ( result == false )
      		return;
      
	  	var a = (screen.width - 700) / 2;
      	var b = (screen.height - 650) / 2;
      	var winVerify = window.open('http://socomarena.com/verify_win.php?PHPSESSID='+ session +'&teamid='+id + '&matchid='+ matchID + '&c='+ timestamp + '&action=confirm', '_confirm', 'width=800,height=650,toolbar=0,statusbar=0,scrollbars=0,menubar=0,left='+a+',top='+b);
      	winVerify.focus ();
    }
    
    
    function DeclineWin( id, matchID, timestamp, session )
    {
      	var mess = "When you decline a match, the match will be removed\n forever and cannot be brought back.";
      		mess += "\n\nAre you sure you want to permenantly remove the match?";
		
      	var result = confirm(mess);
      	
      	if ( result == false )
      		return;
      
	  	var a = (screen.width - 500) / 2;
      	var b = (screen.height - 350) / 2;
      	var winVerify = window.open('http://socomarena.com/verify_win.php?PHPSESSID='+ session +'&teamid='+id + '&matchid='+ matchID + '&c='+ timestamp + '&action=decline', '_decline', 'width=400,height=250,toolbar=0,statusbar=0,scrollbars=0,menubar=0,left='+a+',top='+b);
      	winVerify.focus ();
    }
    
    
    function King( id ) {
	  var a = (screen.width - 400) / 2;
      var b = (screen.height - 300) / 2;
      window.open('http://socomarena.com/king.php?ladder='+id, '_details', 'width=450,height=350,toolbar=0,statusbar=0,scrollbars=0,menubar=0,left='+a+',top='+b);
    }
    
    

	
/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2002-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// See documentation for information about setting these properties 
// at www.dyn-web/com/dhtml/write-drag/documentation.html
writeDrag.writeId = "cntnt";

// required arg's: event, image path and file name (as this.href)
// important but optional arg's: width of image, height of image 
// other optional arg's: txt, layer width, offx, offy
function wrapContent(e, img, w, h, txt, wd, offx, offy) {
  var imgStr, cntnt, win, str;
  imgStr = '';
  if ( dragObj.supported && typeof document.body.innerHTML != "undefined" ) {
    cntnt = '<div class="img">' + imgStr + '</div>';
    if (txt) cntnt += '<div class="msg">' + txt + '</div>';  
    if (!wd) wd = w; 
    writeDrag.set(e, cntnt, wd, offx, offy);
  } else { // non-capable browsers will open sub window
    w = w+80 || wd || 250; h = h+80 || 250; // size
    win = window.open('', 'subwin', 'resizable,width='+w+',height='+h+',left=100,top=100');
    if (win && !win.closed) win.resizeTo(w,h); 
    str = '<html><head><title>Image Display</title></head>';
  	str += '<body style="text-align:center">';
    str += imgStr + (txt? '<p>' + txt + '</p>':"");
  	str += '</body></html>'
  	win.document.write(str);
  	win.document.close();
    if (win && !win.closed) win.focus(); 
  } 
  return false;
}
    
    
    
    
    function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
			return rslt;
		}
	}

	function changeImagesArray(array) {
		if (document.images && (preloadFlag == true)) {
			for (var i=0; i<array.length; i+=2) {
				document[array[i]].src = array[i+1];
			}
		}
	}

	function changeImages() {
		changeImagesArray(changeImages.arguments);
	}

	function toggleImages() {
		for (var i=0; i<toggleImages.arguments.length; i+=2) {
			if (selected == toggleImages.arguments[i])      changeImagesArray(toggleImages.arguments[i+1]);
		}
	}

	var selected = '';
	var preloadFlag = false;	
	
	function preloadImages() {
	  	  
		if (document.images) {
			id3___socom_arena_03_down = newImage("http://socomarena.com/layout1/images/3---socom-arena_03-down.jpg");
			id3___socom_arena_03_over = newImage("http://socomarena.com/layout1/images/3---socom-arena_03-over.jpg");
			id3___socom_arena_05_down = newImage("http://socomarena.com/layout1/images/3---socom-arena_05-down.jpg");
			id3___socom_arena_05_over = newImage("http://socomarena.com/layout1/images/3---socom-arena_05-over.jpg");
			id3___socom_arena_10_over = newImage("http://socomarena.com/layout1/images/3---socom-arena_10-over.jpg");
			id3___socom_arena_10_down = newImage("http://socomarena.com/layout1/images/3---socom-arena_10-down.jpg");
			id3___socom_arena_12_over = newImage("http://socomarena.com/layout1/images/3---socom-arena_12-over.jpg");
			id3___socom_arena_12_down = newImage("http://socomarena.com/layout1/images/3---socom-arena_12-down.jpg");
			preloadFlag = true;
		}
	}

    nereidFadeObjects = new Object();
    nereidFadeTimers = new Object();

    function nereidFade(object, destOp, rate, delta)
	{
    	if (!document.all)
    		return
        if (object != "[object]"){  //do this so I can take a string too
            setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
            return;
        }

        clearTimeout(nereidFadeTimers[object.sourceIndex]);

        diff = destOp-object.filters.alpha.opacity;
        direction = 1;
        if (object.filters.alpha.opacity > destOp){
            direction = -1;
        }
        delta=Math.min(direction*diff,delta);
        object.filters.alpha.opacity+=direction*delta;

        if (object.filters.alpha.opacity != destOp){
            nereidFadeObjects[object.sourceIndex]=object;
            nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
        }
    }


	
	function check() 
	{ 
	  var no_warn = document.getElementById('no_warnings');  
	  var glitch = document.getElementById('glitching');  
	  var ringer = document.getElementById('ringers_used');  
	  var abuse = document.getElementById('abuse'); 
	  var other = document.getElementById('other_warnings'); 
	
	  if (no_warn.checked)  
	  {  
	       glitch.checked = false; 
	       glitch.disabled = true; 
	       ringer.checked = false; 
	       ringer.disabled = true; 
	       abuse.checked = false; 
	       abuse.disabled = true; 
	       other.value = ''; 
	       other.disabled = true; 
	  }else{ 
	       glitch.disabled = false; 
	       ringer.disabled = false; 
	       abuse.disabled = false; 
	       other.disabled = false; 
	  } 
	}

