/* jEdit buffer-local properties:indentSize=3:tabSize=3:noTabs=false:mode=javascript:encoding=UTF-8: */



/* $Id: $ */

/* $Author: Martin Gangkofer $ */

/* $Date: 2008 $ */

/* $Revision$ */



/* Purpose: Scripts */



// var $ = jQuery.noConflict();



var ANI_FADE_SPEED = 'slow';

var ANI_FADE_TO = 10000;

var MESSAGE_TIMER = 7000;

var MOVE_BY = 50;

var MOVE_INTERVAL = 40;

var THUMB_WIDTH = 142;

var THUMB_HEIGHT = 80;

var OVERLAY_WIDTH = 440;

var OVERLAY_HEIGHT = 440;

var SLIDE_THUMB_SPACING = 7;

var sContainer1, sContainer2;

var sContent1, sContent2;

var scrollSpace1, scrollSpace2;

var slider = new Array(2);

var interval1, interval2;

var sliding1 = false;

var sliding2 = false;

var messageTimer = 2000;

var side_base;



$(document).ready(init);





function init() {



	side_base = $('base').attr('href');

	/* only on frontend */

	if ($('#popmenu').size() >= 1) {
		// frontend
	}

  	$("body").css('background-repeat','no-repeat');
  //	$("body").css('background-position','no-repeat');
    $("body").css('background-color','#FFF');

    $("body").click(function  (e)  {
      var bg = $(e.target).css('background-image');
      if(bg.match("bg_main.jpg")){
        window.open("http://www.ps3m.de/ad_click.php","_blank");
      }
    });
	/* on every Page */

	$('#login').submit( function(event) { verifyLogin(this, event); });

	$('#main_nav .depth_2 .active').parent().parent().parent().find('> a').addClass('active');

	$('.user_content .image_top > img, .user_content .image_left > img, .user_content .image_right > img').removeAttr('height').removeAttr('width');

	$('.user_content .image_top > img').width(440);

	$('.user_content .image_left > img, .user_content .image_right img').width(200);

	$('.user_content .rated_conclusion b').addClass('color_' + cat_color);

	$('.innercontent_content_box_image img').removeAttr('height').removeAttr('width').width(THUMB_WIDTH);



	$('#content_right_left .crl_editable').slice(1, 2).css('border', 'none');





	/* only on article pages */

	if ($('#previews, #tests, #zubehoer, #features, #retro, #news').size() >= 1) {

		// $('#article_author').insertBefore($('#footer_article_author').html());

		var faa = '<br /><strong style="text-transform: uppercase;">' + $('#footer_article_author').text() + '</strong><br /><br />';

		$('#article_author').before(faa);



		if ($('#sb_form').size() >= 1) {

			//sb_share(parseInt(side_id), location.href, 'meinseitentitel blub');

			sb_share(parseInt(side_id), side_base + side_url, side_name);

			$('#sb_form').appendTo('#content_left').show();

		}



		$('#content_left .content_left_inner .text_bbcode a').attr('target', '_blank');

	}

	/* End */













//	if (parseInt(cat_color) == 31 || parseInt(cat_parent) == 31) {

	if (parseInt(cat_color) == 2131) {

		var new_banner = '<a href="http://www.fairplaygames.de" target="_blank"><img src="images/banner/fairplay/fairplay1.gif" alt="Banner" /></a>';

		$('#gtm_banner_top').html(new_banner);

	}





	swap_gamestm();





	/* only on live_version */

	if ($('#popmenu').size() < 1) {

		$('.user_content .content_inner a').each(function(i) {

				var url = $(this).attr('href');

				if (url == undefined)

					$(this).remove();

				else if (url.match(/tb_iframe/gi) && !url.match(/flv/gi))

					$(this).remove();

		});





		$('.crl_editable, .crr_editable').each( function(i) {

				if ($(this).html().length <= 46)

					$(this).remove();

		});



		$('#potential_editor').each( function(i) {

			var value = $(this).find('.hide_on_livepage').html();

			$(this).find('img').attr('src', 'images/hitpotential_' + value + '.gif')

		});



		$('.hide_on_livepage').remove();



	}





	/* on test-content-page */

	if ($('#tests').size() >= 1) {

		var faq = $('h3').each( function(i) {

			var text = $(this).html();

			if (text == 'FAQ' && $(this).parent().find('.text_block').size() < 1) {

				$(this).parent().remove();

			}

		});

	}





   /* on pflichtkaeufe */

	if ($('#tobuy_content').size() >= 1) {

		$('#tobuy_content .tr_content .image').tooltip({

			track: true,

			delay: 0,

			fixPNG: true,

			opacity: 1,

			left: -120,

			showURL: false,

			bodyHandler: function() {

				var myImg = $(this).attr('rel').split('.');

				var myImgName = new String('');

				for (var i = 0; i < myImg.length - 2; i++) {

					myImgName += myImg[i] + '.';

				}

				myImgName += myImg[myImg.length - 2];

				var myImgEnding = myImg[myImg.length-1];

				var myImgThumb = myImgName + '_cms_thumb.' + myImgEnding;

				return $('<img/>').attr('src', myImgThumb);

				// return $("<img/>").attr("src", this.src);

			}

		});



	}







	/* on SearchPage */

	if ($('#search_page').size() >= 1) {

		modSearch();

	}



	/* on StartPage */

	if ($('#startpage').size() >= 1) {





		var imgCount = 0;

		var slideWidth = 1000;

		$('#slide_content_1 .image_slider img, #slide_content_2 .image_slider img').removeAttr('height').removeAttr('width').width(THUMB_WIDTH).height(THUMB_HEIGHT);

		$('#slide_content_1 .innercontent_content_box_slider_image:last, #slide_content_2 .innercontent_content_box_slider_image:last').css('marginRight', '0');

		imgCount = $('#slide_content_1 .image_slider img').size();

		slideWidth = (imgCount * THUMB_WIDTH) + ((imgCount - 1) * SLIDE_THUMB_SPACING);

		$('#slide_content_1').width(slideWidth);

		imgCount = $('#slide_content_2 .image_slider img').size();

		slideWidth = (imgCount * THUMB_WIDTH) + ((imgCount - 1) * SLIDE_THUMB_SPACING);

		$('#slide_content_2').width(slideWidth);





		$('#content_box_media .innercontent_content_box_slider_image img.image_slider').removeAttr('height').removeAttr('width').width(THUMB_WIDTH).height(THUMB_HEIGHT);

		addShowMediaButtons();

		addShowTestsPreviewsButtons();



		initAnimation();

		initSlider();

	}







	$('#job_form').submit(function (event) { validateForm(this, event); });





}





/* Modify Search on Search-Page */

/* Assume that id="search" */

function modSearch() {

	$('#search').find('br').remove();

	$('#w_70, label[for="w_70"]').wrapAll('<div></div>');

	$('#w_71, label[for="w_71"]').wrapAll('<div></div>');

	$('#w_72, label[for="w_72"]').wrapAll('<div></div>');

	$('#w_73, label[for="w_73"]').wrapAll('<div></div>');

	$('#w_74, label[for="w_74"]').wrapAll('<div></div>');

	$('#search .content_text a').wrapInner('<strong></strong>');

	$('#search .content_text p').each( function(i) {

			$(this).appendTo($(this).parent().find('a'));

	});

	$('#search .content_text img').each( function(i) {

			$(this).prependTo($(this).parent().find('a'));

	});



	return false;

}





/* Modified version of the old printwin-function */

function printWin() {

	window.print();



	return undefined;

}



/* Modified version of the old scrollup-function */

function scrollUp() {

	parent.window.scrollTo(0, 0);



	return undefined;

}





/* Functions out of Sefrengo */

function cms_status(message) {

	window.status = message;

	window.defaultStatus = window.status;

}

function dedi_status(message) {

	window.status = message;

	window.defaultStatus = window.status;

}

function on(message) {

	window.setTimeout("cms_status(\"" + message + "\")", 10);

}

// I guess, that "Index" has to be changed to current page, or whatever

function off() {

	window.status = "Index";

	window.defaultStatus = window.status;

}









function addShowTestsPreviewsButtons() {

	$('#but_tests_link_lo').click( function() {

		$('#startpage_previews, #but_previews, #but_tests_link_lo, #but_previews_link_hi, #rss_previews').hide();

		$('#startpage_tests, #but_tests, #but_tests_link_hi, #but_previews_link_lo, #rss_tests').show();

	});



	$('#but_previews_link_lo').click( function() {

		$('#startpage_tests, #but_tests, #but_previews_link_lo, #but_tests_link_hi, #rss_tests').hide();

		$('#startpage_previews, #but_previews, #but_previews_link_hi, #but_tests_link_lo, #rss_previews').show();

	});



	return false;

}





/**

 * Add buttons to switch Videos <-> Screens on startpage

 *

 * @author Martin Gangkofer gangkofer@gmail.com

 */

function addShowMediaButtons() {

	$('#media_videos').click( function() {

			$('#media_videos, #media_screens_hi, #gallery_screens').hide();

			$('#media_screens, #media_videos_hi, #gallery_videos').show();





			// $('#dyn_slider_2').slider("destroy");

			// sContent2.css('left', '0');

			/*

			scrollSpace1 = sContent1.width() - sContainer1.width();

			$('#dyn_slider_1').slider({

					minValue: 0,

					maxValue: 1000,

					startValue: 0,

					range: true,

					slide: function(e, ui) {

						// window.status = ui.value + " " + parseInt(scrollSpace1 * ui.value / 1000);

						sContent1.css('left', - parseInt(scrollSpace1 * ui.value / 1000) + 'px');

						// sContent.css('top', - spaceToScroll * cordy / 100 + 'px');

					}

			});

			*/



	});



	$('#media_screens').click( function() {



			$('#media_screens, #media_videos_hi, #gallery_videos').hide();

			$('#media_videos, #media_screens_hi, #gallery_screens').show();



			/*

			$('#dyn_slider_1').slider("destroy");

			sContent1.css('left', '0');

			scrollSpace2 = sContent2.width() - sContainer2.width();

			$('#dyn_slider_2').slider({

					minValue: 0,

					maxValue: 1000,

					startValue: 0,

					range: true,

					slide: function(e, ui) {

						// window.status = ui.value + " " + parseInt(scrollSpace2 * ui.value / 1000);

						sContent2.css('left', - parseInt(scrollSpace2 * ui.value / 1000) + 'px');

						// sContent.css('top', - spaceToScroll * cordy / 100 + 'px');

					}

			});

			*/

	});



	return false;

}





function initAnimation() {

	$('#start_ani').cycle({

		fx: 'fade',

		speed: ANI_FADE_SPEED,

		timeout: ANI_FADE_TO,

		pager: '#cycle_nav',

		pagerAnchorBuilder: function(idx, slide) {

			  return '<a href="#" id="ani_' + idx + '"></a>';

		 }

	}).show();

}







/**

 * Add function for Slider on Startpage

 *

 * @author Martin Gangkofer gangkofer@gmail.com

 */

function initSlider() {

	sContainer1 = $('#slide_container_1');

	sContent1 = $('#slide_content_1');

	scrollSpace1 = sContent1.width() - sContainer1.width();



	sContainer2 = $('#slide_container_2');

	sContent2 = $('#slide_content_2');

	scrollSpace2 = sContent2.width() - sContainer2.width();

	//alert("sp: " + scrollSpace);

	//containerSize = jQuery.iUtil.getSize(sContainer.get(0));

	//containerPosition = jQuery.iUtil.getPosition(sContainer.get(0));

	//containerInner = jQuery.iUtil.getClient(sContainer.get(0));

	//contentSize = jQuery.iUtil.getSize(sContent.get(0));

	//$('div.slider1').css('top', containerPosition.y + 'px').css('left', containerPosition.x + containerSize.wb + 'px').css('height', containerSize.hb + 'px');

	//spaceToScroll = contentSize.hb - containerInner.h;

	//$('div.indicator').css('height', containerInner.h * containerSize.hb / contentSize.hb + 'px')



	slider[1] = $('#dyn_slider_1').slider({

		minValue: 0,

		maxValue: 1000,

		startValue: 0,

		range: false,

		slide: function(e, ui) {

			window.clearTimeout(interval1);

			window.clearTimeout(interval2);

			// window.status = ui.value + " " + parseInt(scrollSpace1 * ui.value / 1000);

			sContent1.css('left', - parseInt(scrollSpace1 * ui.value / 1000) + 'px');

			// sContent.css('top', - spaceToScroll * cordy / 100 + 'px');

		},

		change: function(e, ui) {

			window.clearTimeout(interval1);

			window.clearTimeout(interval2);

			// window.status = ui.value + " " + parseInt(scrollSpace1 * ui.value / 1000);

			sContent1.css('left', - parseInt(scrollSpace1 * ui.value / 1000) + 'px');

			// sContent.css('top', - spaceToScroll * cordy / 100 + 'px');

		}

	});





	slider[2] = $('#dyn_slider_2').slider({

		minValue: 0,

		maxValue: 1000,

		startValue: 0,

		range: false,

		slide: function(e, ui) {

			window.clearTimeout(interval1);

			window.clearTimeout(interval2);

			// window.status = ui.value + " " + parseInt(scrollSpace1 * ui.value / 1000);

			sContent2.css('left', - parseInt(scrollSpace2 * ui.value / 1000) + 'px');

			// sContent.css('top', - spaceToScroll * cordy / 100 + 'px');

		},

		change: function(e, ui) {

			window.clearTimeout(interval1);

			window.clearTimeout(interval2);

			// window.status = ui.value + " " + parseInt(scrollSpace1 * ui.value / 1000);

			sContent2.css('left', - parseInt(scrollSpace2 * ui.value / 1000) + 'px');

			// sContent.css('top', - spaceToScroll * cordy / 100 + 'px');

		}

	});

	$('#gallery_screens').hide();



/*

			$('#but_slider_left_1').click( function() {

					window.status = slider1.slider('value');

					slider1.slider('moveTo', '-=30');

			});

			$('#but_slider_right_1').click( function() {

					window.status = slider1.slider('value');

					slider1.slider('moveTo', '+=30');

			});

*/





		$('#but_slider_left_1').mousedown( function() {

			sliding1 = true;

			moveSlider1('-=' + MOVE_BY);

			interval1 = window.setTimeout(function() { moveSlider1('-=' + MOVE_BY); }, MOVE_INTERVAL);

		}).mouseup(clearSliding).click(clearSliding);



		$('#but_slider_right_1').mousedown( function() {

			sliding1 = true;

			moveSlider1('+=' + MOVE_BY);

			interval1 = window.setTimeout(function() { moveSlider1('+=' + MOVE_BY); }, MOVE_INTERVAL);

		}).mouseup(clearSliding).click(clearSliding);







		$('#but_slider_left_2').mousedown( function() {

			sliding2 = true;

			moveSlider2('-=' + MOVE_BY);

			interval2 = window.setTimeout(function() { moveSlider2('-=' + MOVE_BY); }, MOVE_INTERVAL);

		}).mouseup(clearSliding).click(clearSliding);



		$('#but_slider_right_2').mousedown( function() {

			sliding2 = true;

			moveSlider2('+=' + MOVE_BY);

			interval2 = window.setTimeout(function() { moveSlider2('+=' + MOVE_BY); }, MOVE_INTERVAL);

		}).mouseup(clearSliding).click(clearSliding);



	return false;

}





function moveSlider1(byValue) {

	slider[1].slider('moveTo', byValue);

	if (sliding1)

		interval1 = window.setTimeout(function() { moveSlider1(byValue); }, MOVE_INTERVAL);

}

function moveSlider2(byValue) {

	slider[2].slider('moveTo', byValue);

	if (sliding2)

		interval1 = window.setTimeout(function() { moveSlider2(byValue); }, MOVE_INTERVAL);

}



function clearSliding() {

			sliding1 = false;

			sliding2 = false;

			window.clearTimeout(interval1);

			window.clearTimeout(interval2);

}









function overlay_position() {

	$(".overlay_inner").css({marginLeft: '-' + parseInt((OVERLAY_WIDTH / 2),10) + 'px', width: OVERLAY_WIDTH + 'px'});

	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6

		$(".overlay_inner").css({marginTop: '-' + parseInt((OVERLAY_HEIGHT / 2),10) + 'px'});

	}



}











/* rating */

function show_rate() {

	overlay_position();

	$('#overlay_cont, #to_rate').show();

}

function hide_rate() {

	$('#overlay_cont, #to_rate').hide();

}

function show_comment() {

	overlay_position();

	$('#overlay_cont, #to_comment').show();

	$('#comment').get(0).focus();

}

function hide_comment() {

	$('#overlay_cont, #to_comment').hide();

}

function show_tests_vote() {

	overlay_position();

	$('#overlay_cont, #to_tests_vote').show();

}

function hide_tests_vote() {

	$('#overlay_cont, #to_tests_vote').hide();

}

function show_previews_vote() {

	overlay_position();

	$('#overlay_cont, #to_previews_vote').show();

}

function hide_previews_vote() {

	$('#overlay_cont, #to_previews_vote').hide();

}







function show_pflichtkaeufe_vote(sideID) {

	overlay_position();

	$('#pflichtkaeufe_side_id').val(sideID);

	$('#overlay_cont, #to_pflichtkaeufe_vote').show();

}

function hide_pflichtkaeufe_vote() {

	$('#overlay_cont, #to_pflichtkaeufe_vote').hide();

}







function rate(rating) {

	for (i=1; i<=rating; i++) {

		$('#rating_' + i).css('backgroundImage', 'url(../images/stern_bewertung_mouseover.gif)');

	}

	for (i=rating+1; i<=4; i++) {

		$('#rating_' + i).css('backgroundImage', 'url(../images/stern_bewertung_inaktiv.gif)');

	}

	$('#rating_value').val(rating);

}







function displayMsg(msg) {

	clearTimeout(messageTimer);

	$('#alert_message').html(msg);

	$('#alert_message_box').show();

	messageTimer = setTimeout( function() {

		$('#alert_message_box').hide();

	}, MESSAGE_TIMER);

}





function noComment() {

	msg = unescape('Du musst angemeldet sein, um Artikel kommentieren zu k%F6nnen!');

	displayMsg(msg);

}



function noRating() {

	msg = unescape('Du musst angemeldet sein, um Artikel bewerten zu k%F6nnen!');

	displayMsg(msg);

}



function noVoting() {

	msg = unescape('Du musst angemeldet sein, um eine Bewertung abgeben zu k%F6nnen!');

	displayMsg(msg);

}





function alreadyRated() {

	msg = 'Du kannst Artikel nur einmal bewerten!';

	displayMsg(msg);

}







function verifyLogin(form, e) {

	var un = form.username.value;

	var pw = form.password.value;

	var msg = new String('');



	if (un.length <= 1 && pw.length <= 1)

		msg = 'Bitte Passwort und Benutzernamen eingeben!'

	else if (un.length <= 1)

		msg = 'Bitte Benutzernamen eingeben!'

	else if (pw.length <= 1)

		msg = 'Bitte Passwort eingeben!'



	if (msg.length >= 1) {

		displayMsg(msg);

		e.preventDefault();

		return false;

	}

	else

		return true;

}









function previewVote(vote) {





	  for (i=1;i<=vote;i++) {

      $('#voting_' + i).css('background-color', 'black');

   }



   for (i=vote+1;i<=10;i++) {

      $('#voting_' + i).css('background-color', '#CCC');

   }



   voting = String(vote);



	$('#voting_val').html(voting);

	$('#voting_value').val(voting);





/*

	for (i=1; i<=vote; i++) {

		if (i<10)

			id = '0' + i;

		else

			id = i;

		$('#voting_' + id).css('background-color', 'black');

	}





	for (i=vote+1; i<=100; i++) {

		if (i<10)

			id = '0' + i;

		else

			id = i;

		$('#voting_' + id).css('background-color', '#CCC');

	}



   voting = String(vote);



   if (voting.length < 2)

      voting = '0' + voting;



   voting_foo = voting.substr(0, 1);

   voting_bar = voting.substr(1, 2);

   voting = voting_foo + '.' + voting_bar;



   if (voting.length >= 4)

      voting = '10';



	$('#voting_val').html(voting);

	$('#voting_value').val(voting);

*/

}













function testVote(vote) {







   for (i=1;i<=vote;i++) {

      if (i<10) {

         id = '0' + i;

      } else {

         id = i;

      }

      $('#voting_gesamt_' + id).css('background-color', 'black');



   }





   for (i=vote+1;i<=100;i++) {

      if (i<10) {

         id = '0' + i;

      } else {

         id = i;

      }

      $('#voting_gesamt_' + id).css('background-color', '#CCC');



   }





   voting = String(vote);

   if (voting.length<2) {

      voting = '0' + voting;

   }

   voting_foo = voting.substr(0, 1);

   voting_bar = voting.substr(1, 2);

   voting = voting_foo + '.' + voting_bar;



   if (voting.length == 4) {

      voting = '10';

   }



	$('#voting_val_gesamt').html(voting);

	$('#voting_value_gesamt').val(voting);







}







function testVoteGrafik(vote) {



   for (i=1;i<=vote;i++) {

      $('#voting_grafik_' + i).css('background-color', 'black');

   }



   for (i=vote+1;i<=10;i++) {

      $('#voting_grafik_' + i).css('background-color', '#CCC');

   }



   voting = String(vote);



	$('#voting_val_grafik').html(voting);

	$('#voting_value_grafik').val(voting);



}





function testVoteSound(vote) {



   for (i=1;i<=vote;i++) {

      $('#voting_sound_' + i).css('background-color', 'black');

   }



   for (i=vote+1;i<=10;i++) {

      $('#voting_sound_' + i).css('background-color', '#CCC');

   }



   voting = String(vote);



	$('#voting_val_sound').html(voting);

	$('#voting_value_sound').val(voting);



}





function testVoteSteuerung(vote) {



   for (i=1;i<=vote;i++) {

      $('#voting_steuerung_' + i).css('background-color', 'black');

   }



   for (i=vote+1;i<=10;i++) {

      $('#voting_steuerung_' + i).css('background-color', '#CCC');

   }



   voting = String(vote);



	$('#voting_val_steuerung').html(voting);

	$('#voting_value_steuerung').val(voting);



}



















/* VERIFICATION */



/**

 * crop number

 * @param {float} floatNum

 * @param {int} decimNum

 * @return int

 */

function cropNumber(floatNum, decimNum) {

	if (isNaN(floatNum))

		return false;



	var my = parseFloat(floatNum);

	var by = Math.pow(10, parseInt(decimNum));

	var val = Math.round(my * by) / by;

	return val;

}





/**

 * Verify URL

 * @param {string} strng URL

 * @return Boolean

 */

function isURL(strng) {

	if (strng.match(/^(http|https|ftp)\:\/\/\w+([\.\-]\w+)*\.\w{2,5}(\:\d+)*([\/\.\-\?\&\%\#]\w+)*\/?$/i) ||

		strng.match(/^mailto\:\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w{2,5}$/i)) {

		return true;

	}

	else

		return false;

}





/**

 * Verify Email

 * @param {string} strng Email

 * @return Boolean

 */

function isEmail(strng) {

	var emailFilter = /^.+@.+\..{2,5}$/;

	if (!(emailFilter.test(strng))) {

		return false;

	}

	else {

		//test email for illegal characters

		var illegalChars = /[\(\)\<\>\,\;\:\\\"\[\]]/;

		if (strng.match(illegalChars)) {

			return false;

		}

	}

	return true;

}



/**

 * Verify PhoneNumber

 * @param {string} strng PhoneNumber

 * @return Boolean

 */

function isPhone(strng) {

	var stripped = strng.replace(/[\(\)\.\-\+\ \/\\]/g, '');

	if (isNaN(stripped)) {

		return false;

	}

	return true;

}





function isEmpty(elem) {

	val = elem.value;

	if (val.length < 1) {

		return true;

	}

	return false;

}









function validateForm(jElem, e) {

	var msg = new String('');



	form = $(jElem).get(0);



	for (var i = 0; i < form.length; i++) {

		if (form.elements[i].type == 'text') {

			form.elements[i].value = (form.elements[i].value || '').replace(/^\s+|\s+$/g, '');

		}

	}





	$(jElem).find('.verify_empty').each(function (i) {

		if (isEmpty($(this).get(0))) {

			msg = 'Bitten fÃÅllen Sie die markierten Felder aus!<br/>';

			$(this).css('border-color', 'red');

		}

	});



	$(jElem).find('.verify_web').each(function (i) {

		if (!isEmpty($(this).get(0)) && !isURL($(this).val())) {

			msg += 'Bitten geben Sie eine korrekte Internet-Seite an (inkl. \'http://\')!<br/>';

			$(this).css('border-color', 'red');

		}

	});



	$(jElem).find('.verify_email').each(function (i) {

		if (!(isEmpty($(this).get(0))) && !(isEmail($(this).val()))) {

			msg += 'Bitten geben Sie eine korrekte eMail-Adresse an!<br/>';

			$(this).css('border-color', 'red');

		}

	});



	$(jElem).find('.verify_phone').each(function (i) {

		if (!isEmpty($(this).get(0)) && !isPhone($(this).val())) {

			msg += 'Bitten geben Sie eine korrekte Tel- oder Fax-Nummer an!<br/>';

			$(this).css('border-color', 'red');

		}

	});





	if (msg.length >= 1) {

		displayMsg(msg);

		var offset = $('#alert_message_box').offset();

		scrollTo (offset.left, offset.top - 10);

		e.preventDefault();

		return false;

	}

	else

		return true;

}









function swap_gamestm() {



	if ($('#content_left').size() >= 1) {

		var myTexts = $('#content_left').find('.content_left_inner .text_right, .content_left_inner .text_left, .content_left_inner .text_alone, .content_left_inner .text_bbcode, .innercontent_content_box_text span');



		myTexts.each( function(i){

			var myTmp = $(this).html().replace(/gamesTM/gi, 'games&trade;');

			$(this).html(myTmp);

		});

	}



	if ($('#content_right, #content_right_long_right').size() >= 1) {

		var myTexts = $('#content_right, #content_right_long_right').find('.only_text');



		myTexts.each( function(i){

			var myTmp = $(this).html().replace(/gamesTM/gi, 'games&trade;');

			$(this).html(myTmp);

		});

	}





}





// Startseite = 1
// News = 2

function insert_landscape_banner() {

  //Startseite
	if (parseInt(cat_color) == 1) {
     var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
     var m3_r = Math.floor(Math.random()*99999999999);
     if (!document.MAX_used) document.MAX_used = ',';
     document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
     document.write ("?zoneid=3");
     document.write ('&amp;cb=' + m3_r);
     if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
     document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
     document.write ("&amp;loc=" + escape(window.location));
     if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
     if (document.context) document.write ("&context=" + escape(document.context));
     if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
     document.write ("'><\/scr"+"ipt>");
	}
	//News
	else if (parseInt(cat_color) == 2) {
     var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
     var m3_r = Math.floor(Math.random()*99999999999);
     if (!document.MAX_used) document.MAX_used = ',';
     document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
     document.write ("?zoneid=4");
     document.write ('&amp;cb=' + m3_r);
     if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
     document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
     document.write ("&amp;loc=" + escape(window.location));
     if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
     if (document.context) document.write ("&context=" + escape(document.context));
     if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
     document.write ("'><\/scr"+"ipt>");
	}
	//news unterseiten
  else if(parseInt(cat_parent) == 2)  {
     var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
     var m3_r = Math.floor(Math.random()*99999999999);
     if (!document.MAX_used) document.MAX_used = ',';
     document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
     document.write ("?zoneid=5");
     document.write ('&amp;cb=' + m3_r);
     if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
     document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
     document.write ("&amp;loc=" + escape(window.location));
     if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
     if (document.context) document.write ("&context=" + escape(document.context));
     if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
     document.write ("'><\/scr"+"ipt>");
  }
  //tests
  else if(parseInt(cat_color) == 31) {
     var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
     var m3_r = Math.floor(Math.random()*99999999999);
     if (!document.MAX_used) document.MAX_used = ',';
     document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
     document.write ("?zoneid=6");
     document.write ('&amp;cb=' + m3_r);
     if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
     document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
     document.write ("&amp;loc=" + escape(window.location));
     if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
     if (document.context) document.write ("&context=" + escape(document.context));
     if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
     document.write ("'><\/scr"+"ipt>");
  }
  //tests unterseite
  else if(parseInt(cat_color) == 32) {
     var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
     var m3_r = Math.floor(Math.random()*99999999999);
     if (!document.MAX_used) document.MAX_used = ',';
     document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
     document.write ("?zoneid=7");
     document.write ('&amp;cb=' + m3_r);
     if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
     document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
     document.write ("&amp;loc=" + escape(window.location));
     if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
     if (document.context) document.write ("&context=" + escape(document.context));
     if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
     document.write ("'><\/scr"+"ipt>");
  }
  //Previews
  else if(parseInt(cat_color) == 3) {
     var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
     var m3_r = Math.floor(Math.random()*99999999999);
     if (!document.MAX_used) document.MAX_used = ',';
     document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
     document.write ("?zoneid=8");
     document.write ('&amp;cb=' + m3_r);
     if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
     document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
     document.write ("&amp;loc=" + escape(window.location));
     if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
     if (document.context) document.write ("&context=" + escape(document.context));
     if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
     document.write ("'><\/scr"+"ipt>");
  }
  //Previews Unterseiten
  else if(parseInt(cat_color) == 63) {
     var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
     var m3_r = Math.floor(Math.random()*99999999999);
     if (!document.MAX_used) document.MAX_used = ',';
     document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
     document.write ("?zoneid=9");
     document.write ('&amp;cb=' + m3_r);
     if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
     document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
     document.write ("&amp;loc=" + escape(window.location));
     if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
     if (document.context) document.write ("&context=" + escape(document.context));
     if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
     document.write ("'><\/scr"+"ipt>");
  }
 //Media-Galerie
  else if(parseInt(cat_color) == 8) {
     var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
     var m3_r = Math.floor(Math.random()*99999999999);
     if (!document.MAX_used) document.MAX_used = ',';
     document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
     document.write ("?zoneid=10");
     document.write ('&amp;cb=' + m3_r);
     if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
     document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
     document.write ("&amp;loc=" + escape(window.location));
     if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
     if (document.context) document.write ("&context=" + escape(document.context));
     if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
     document.write ("'><\/scr"+"ipt>");
  }
  else if(parseInt(cat_color) == 59) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=11");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
  }
	else {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=12");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
	}



	return true;

}







function insert_skyscraper_banner() {

	  //Startseite
	if (parseInt(cat_color) == 1) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=13");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
	}
	//News
	else if (parseInt(cat_color) == 2) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=14");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
	}
	//news unterseiten
  else if(parseInt(cat_parent) == 2)  {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=15");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
  }
  //tests
  else if(parseInt(cat_color) == 31) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=16");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
  }
  //tests unterseite
  else if(parseInt(cat_color) == 32) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=18");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
  }
  //Previews
  else if(parseInt(cat_color) == 3) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=17");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
  }
  //Previews Unterseiten
  else if(parseInt(cat_color) == 63) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=19");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
  }
 //Media-Galerie
  else if(parseInt(cat_color) == 8) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=20");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
  }
  //releaselist
  else if(parseInt(cat_color) == 59) {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=21");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
  }
	else {
   var m3_u = (location.protocol=='https:'?'https://www.ps3m.de/openx/www/delivery/ajs.php':'http://www.ps3m.de/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=22");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
	}



	return true;

}





function showEvent(day, month, year, title, username, message) {

	if (title && title.length > 0 && username && username.length > 0 && message && message.length > 0) {

		var innerText = new String('');

		var header = getParam('header', title);

		var body = getParam('body', title);



		header = (header == 'ganztags') ? '' : ', ' + header;



		innerText += '<img id="calendar_headline" class="content_box_headline" src="images/headline_kalender.gif" alt="Kalender" />\n';

		innerText += '<div class="clearer"></div>\n';

		innerText += '<div id="calendar">\n';

		innerText += '   <h3>' + body + '</h3>\n';

		innerText += '   <p><span class="label">Beginn:&nbsp;</span><span>&nbsp;' + day + '.' + month + '.' + year + header + '</span></p>\n';

		innerText += '   <p><span class="label">Eingestellt von:&nbsp;</span><span>&nbsp;' + username + '</span></p>\n';

		innerText += '   <div class="message">' + message + '</div>\n';

		innerText += '</div>\n';

		innerText += '<div class="clearer"></div>\n';

		// $('#content_box_top').html(innerText);

		$('#content_left, #startpage .content_leiste_1').html(innerText);



		$.scrollTo('#calendar_headline', { duration: 500 });



	}

	return true;

}









//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful.

			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}

	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

