var felements = new Array();
var flcount = 1;
var preloadnavimg = new Array();
  
  
function loadFlashElements(){
  for (x in felements) {
    swfobject.embedSWF(felements[x][0], felements[x][1], felements[x][2], felements[x][3], "9.0.115", false, felements[x][4], felements[x][5], felements[x][6]);
  }
}



function ajaxFrame(){
  $('.aframe').each(function(n){
    $(this).text('');
    uni = Math.floor(Math.random()*121);
    $.get($(this).attr('src'),{'uni':uni,'frameid':$(this).attr('id')},function (data, textStatus) {
      var queryString = this.url.replace(/^[^\?]+\??/,'');			
			var params = tb_parseQuery( queryString );
      $('#'+params.frameid).append(data);
      // data could be xmlDoc, jsonObj, html, text, etc...
      //this; // the options for this ajax request
    });
  });  
}


function addGradients(elements){
  $(elements).gradient({
    from:'F9EFEC',
    to:'ffffff',
    length:55
  });
}

function loadNav(){
  $('#nav li a').each(function(n){
    var idval = $(this).attr('id');
    var altval = $(this).text();
    $(this).attr('title',altval);
    preloadnavimg[idval] = new Image();
    preloadnavimg[idval].id = idval;
    preloadnavimg[idval].alt= altval;
    preloadnavimg[idval].onload = function(){
      this.onload = null;
      var imgstr = "<img src='../images/nav_"+this.id+".gif' alt='"+this.alt+"'>";
      var aid = '#nav li a#'+this.id;
      $(aid).text('');
      $(imgstr).appendTo(aid);
    }
    preloadnavimg[idval].src = '../images/nav_'+idval+'.gif';  
  });
}

function titliseImageLinks(){
  $("a").each(function() {
    var $title = $("img", this).attr("alt");
    if($title != "" && $title != "undefined"){
      $(this).attr("title", $title);
    }
  }); 
}

function setSignupLinks(){
  $('.signup').each(function(){
    $(this).attr('href','https://secure.gunzblazing.com/signup/signup.php?s=53');
    $(this).attr('target', '_top');
    $(this).click(function(){top.frame.exit=false;});
    $(this).attr('class','signup-fixed');
  });
}

function fixVideoLinks(){
  $('.videoLinks').each(function(n){
    var textArray = $(this).text().split(',');
      var vid = textArray[0];
      var title = $(this).attr('title');
      var type =  $(this).attr('alt');
      var fsize = "";
      var dsize = "";
      switch(type){
        case 'h.264_1800_normal':
           var fsize = "wh1800";
           var dsize = "-1800";
           break;
        case 'h.264_1800_wide':
           var fsize = "wh1800ws2";
           var dsize = "-1800";
           break;
        case 'h.264_1800_wide_HD':
           var fsize = "wh1800ws2hd";
           var dsize = "-1800";
           break;
        default: 
           break;      
      }
      $(this).text('');
      $(this).removeAttr('title');
      $(this).removeAttr('alt');
      if(fsize != ""){
        switch(textArray[1]){
          case 'home':
            $(this).append('<a href="/tour/play.php?type=flv&path=' + vid + '/1800/'+fsize+'?TB_iframe=true&height=600&width=1100" title="'+title+'" class="thickbox">Stream Video</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/tour/play.php?type=dl&path=trailers/' + vid + dsize+'">Download Video</a>');
            break;
          case 'section':
            $(this).append('<a href="/tour/play.php?type=flv&path=' + vid + '/1800/'+fsize+'&TB_iframe=true&height=600&width=1100" title="'+title+'" class="thickbox"><img src="/images/flashplay_tb.png" border=0 title="Stream Video: '+title+'" alt="Stream Video: '+title+'"></a><img src="/images/spacer.gif" height=1 width=20><a href="/tour/play.php?type=dl&path=trailers/' + vid + dsize+'"><img src="/images/download_tb.png" border=0 alt="Download WMV" title="Download WMV"></a>');
            break;
          case 'gallery':
            $(this).append('<a href="/tour/play.php?type=flv&path=' + vid + '/1800/'+fsize+'&TB_iframe=true&height=600&width=1100" title="'+title+'" class="thickbox"><img src="/images/flashplay_tb.png" border=0 title="Stream Video: '+title+'" alt="Stream Video: '+title+'"></a><img src="/images/spacer.gif" height=1 width=20><a href="/tour/play.php?type=dl&path=trailers/' + vid + dsize+'"><img src="/images/download_tb.png" border=0 alt="Download WMV" title="Download WMV"></a>');
            break;
          default:
            $(this).append('<a href="/tour/play.php?type=flv&path=' + vid + '/1800/'+fsize+'?TB_iframe=true&height=600&width=1100" title="'+title+'" class="thickbox">Stream Video</a><br><a href="/tour/play.php?type=dl&path=trailers/' + vid + dsize+'">Download Video</a>');
            break;
        }
      }else{
      
      }
	  $(this).attr('class','videoLinks-fixed');
  });  
}






function openSub() 
{
	
	wWidth = 800; wHeight = 600;
	
	wHPos = (screen.width / 2) - (wWidth / 2);
	wVPos = (screen.height / 2) - (wHeight / 2) - 50;
	
	if (document.all) {
	oWin = self.open("/subscribe/","nvSMP","width="+wWidth+",height="+wHeight+",location=no,top="+wVPos+",left="+wHPos+",personalbar=no,menubar=no,scrollbars=no,status=no,toolbar=no")
	oWin.focus()
	} else {
		oWin = self.open("/subscribe/","nvSMP","width="+wWidth+",height="+wHeight+",location=no,screenY="+wVPos+",screenX="+wHPos+",personalbar=no,menubar=no,scrollbars=no,status=no,toolbar=no")
		oWin.focus()
	}
	
}


function openApp() 
{
	
	wWidth = 800; wHeight = 600;
	
	wHPos = (screen.width / 2) - (wWidth / 2);
	wVPos = (screen.height / 2) - (wHeight / 2) - 50;
	
	if (document.all) {
	oWin = self.open("/feedback/","nvSMP","width="+wWidth+",height="+wHeight+",location=no,top="+wVPos+",left="+wHPos+",personalbar=no,menubar=no,scrollbars=yes,status=no,toolbar=no")
	oWin.focus()
	} else {
		oWin = self.open("/feedback/","nvSMP","width="+wWidth+",height="+wHeight+",location=no,screenY="+wVPos+",screenX="+wHPos+",personalbar=no,menubar=no,scrollbars=yes,status=no,toolbar=no")
		oWin.focus()
	}
	
}

function openChat() 
{
	
	wWidth = 800; wHeight = 515;
	
	wHPos = (screen.width / 2) - (wWidth / 2);
	wVPos = (screen.height / 2) - (wHeight / 2) - 50;
	
	if (document.all) {
	oWin = self.open("cams/","nvSMP","width="+wWidth+",height="+wHeight+",location=no,top="+wVPos+",left="+wHPos+",personalbar=no,menubar=no,scrollbars=no,status=no,toolbar=no")
	oWin.focus()
	} else {
		oWin = self.open("cams/","nvSMP","width="+wWidth+",height="+wHeight+",location=no,screenY="+wVPos+",screenX="+wHPos+",personalbar=no,menubar=no,scrollbars=no,status=no,toolbar=no")
		oWin.focus()
	}
	
}


