// JavaScript Document

function MM_flashGifReplace(swfRef,widthRef,heightRef,gifRef,bgColor,varsRef){
	if (!useRedirect) {    // if dynamic embedding is turned on
  if(hasRightVersion) {  // if we've detected an acceptable version
    var oeTags = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    + 'WIDTH="'+widthRef+'" HEIGHT="'+heightRef+'"'
    + 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
    + '<PARAM NAME="MOVIE" VALUE="'+swfRef+'">'
    + '<PARAM NAME="PLAY" VALUE="true">'
    + '<PARAM NAME="LOOP" VALUE="false">'
    + '<PARAM NAME="QUALITY" VALUE="high">'
    + '<PARAM NAME="MENU" VALUE="false">'
	+ '<PARAM NAME="BGCOLOR" VALUE="'+bgColor+'">'
	+ '<PARAM NAME="FLASHVARS" VALUE="'+varsRef+'">'
    + '<EMBED SRC="'+swfRef+'"'
    + 'WIDTH="'+widthRef+'"'
	+ 'HEIGHT="'+heightRef+'"'
    + 'PLAY="true"'
    + 'LOOP="false"'
    + 'QUALITY="high"'
    + 'MENU="false"'
	+ 'BGCOLOR="'+bgColor+'"'
	+ 'FLASHVARS="'+varsRef+'"'
    + 'TYPE="application/x-shockwave-flash"'
    + 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
    + '<\/EMBED>'
    + '<\/OBJECT>';

    document.write(oeTags);   // embed the flash movie
  } else {  // flash is too old or we can't detect the plugin
    // NOTE: height, width are required!
    var alternateContent = '<A HREF="http://www.macromedia.com/go/getflashplayer" TARGET="_blank"><IMG SRC="'+gifRef+'"></a>';
	
	document.write(alternateContent);  // insert non-flash content
  }
}
}

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_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_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 numerics (e) {
	var key;
	var keychar;
	
	if (window.event) {
		key = window.event.keyCode;
	}
	else if (e) {
		key = e.which;
	}
	else {
		return true;
	}
	
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27)) {
		return true;
	}
	else if (((".0123456789").indexOf(keychar) > -1)) {
		return true;
	}
	else {
		return false;
	}
}

function open_occasion(swf,id) {
	var prevWin = window.open("view_occasion.php?swf="+swf+"&id="+id, "prevWin", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resize=0,width=800, height=520");
}


function login() {
	if (document.loginbox.user.value!='' && document.loginbox.pass.value!='') {
		document.loginbox.submit();
	}
}

function setaction (todo) {
	if (todo != null) {
		document.getElementById('sendbsnap').a.value = todo;
		document.getElementById('sendbsnap').submit();
	}
}

function uploadimage() {
	if (document.getElementById('upload_form').upload.value != null) {
		document.getElementById('upload_form').submit();
		if (document.getElementById('error')) {
			document.getElementById('error').style.display = "none";
		}
		document.getElementById('panel_uploadform').style.display = "none";
		document.getElementById('panel_pleasewait').style.display = "block";
	}
}

function get_flick_image(img) {
	if (img) {
		document.getElementById('flickr_select').image_url.value = img;
		document.getElementById('flickr_select').submit();
		document.getElementById('flickr_panel').style.display = "none";
		document.getElementById('flickr_pleasewait').style.display = "block";
	}
}

function gen_blogthis() {
	if (document.getElementById('blogthis_form').pixels.value != null) {
		document.getElementById('blogthis_form').submit();
	}
}

function banner_finished() {
	var randomnumber=Math.floor(Math.random()*3)
	
	if (randomnumber == 0){ // Carphone Warehouse Pink Banner
		var uri = 'http://impgb.tradedoubler.com/imp/js/436053/1208920?' + new String (Math.random()).substring (2, 11);
		document.write('<sc'+'ript language="JavaScript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
	}
	
	else if (randomnumber == 1){ // Talk Talk Banner
		var uri = 'http://impgb.tradedoubler.com/imp/js/575954/1208920?' + new String (Math.random()).substring (2, 11);
		document.write('<sc'+'ript language="JavaScript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');		
	}
	
	else if (randomnumber == 2){ // Large SatNav2U Banner
		var uri = 'http://impgb.tradedoubler.com/imp/js/16162742/1208920?' + new String (Math.random()).substring (2, 11);
		document.write('<sc'+'ript language="JavaScript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');	
	}
}

function banner_display() {
	var randomnumber=Math.floor(Math.random()*3)
	
	if (randomnumber == 0){ // Dealtime 200 square
		var uri = 'http://impgb.tradedoubler.com/imp/js/795254/1208920?' + new String (Math.random()).substring (2, 11);
		document.write('<sc'+'ript language="JavaScript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
	}
	
	else if (randomnumber == 1){ // Talk Talk 250 Square
		var uri = 'http://impgb.tradedoubler.com/imp/js/617495/1208920?' + new String (Math.random()).substring (2, 11);
		document.write('<sc'+'ript language="JavaScript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');	
	}
	
	else if (randomnumber == 2){ // Play.com 250 square
		var uri = 'http://impgb.tradedoubler.com/imp/js/15771459/1208920?' + new String (Math.random()).substring (2, 11);
		document.write('<sc'+'ript language="JavaScript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
	}
}
