function insertFlash(src,w,h){document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+src+'" /><embed src="'+src+'" width="'+w+'" height="'+h+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');}
try{document.execCommand('BackgroundImageCache', false, true);}catch(e){}
function shht(id){el1 = document.getElementById(id);el2 = document.getElementById(id+'_hidden');if(el1.style.display==''){el1.style.display='none';el2.style.display='';}else{el1.style.display='';el2.style.display='none';}return false;}
function redirect(url){window.location=url;}
function newwindow(selection,w,h){l=(screen.availWidth-w)/2;t=(screen.availHeight-h)/2;window.open(selection,'_blank','height='+h+',width='+w+',scrollbars=yes,left='+l+',top='+t+',resizable=yes');return false;}
function newwindow2(selection,w,h){l=(screen.availWidth-w)/2;t=(screen.availHeight-h)/2;window.open(selection,'_blank','height='+h+',width='+w+',scrollbars=no,left='+l+',top='+t+',resizable=yes');return false;}
function replyTo(id)
{
	if(id==0)
	{
		document.getElementById('addComment').appendChild(document.getElementById('commentForm'));
		document.getElementById('commentFormTitle').innerHTML=langAddComment;
	}
	else
	{
		document.getElementById('replyTo'+id).appendChild(document.getElementById('commentForm'));
		document.getElementById('commentFormTitle').innerHTML=langReplyFor;
	}
	document.getElementById('replyTo').value=id;
}
function showVideo(url)
{
	url = '/images/player.swf?m=video&file=/userfiles/media/'+url;
	document.getElementById('video').style['display'] = 'block';
	//swfobject.embedSWF(url, "video2", "470", "352", "9.0.0", false, false, {wmode:"transparent"}, {wmode:"transparent"});
	document.getElementById('video2').innerHTML = '<object width="470" height="352"><param name="movie" value="'+url+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+url+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="470" height="352"></embed></object>';
}
function closeVideo()
{
	document.getElementById('video2').innerHTML = '';
	document.getElementById('video').style['display'] = 'none';
}

function HeaderSlider(Element) {	
    if (Element == undefined)
        return false;

    Element = $(Element);

    var AElements = Element.find('.picNode');
	if (AElements.length == 0) {
		var pics = Element.find('img');
		pics.wrap('<div class="picNode">');
	}
	AElements = Element.find('.picNode');
    var mainHeight = 0;
    for (var i = 0; i < AElements.length; i++) {
        if ($(AElements[i]).height() > mainHeight) mainHeight = $(AElements[i]).height();
    }

    Element.height(mainHeight);
	
    var mainWidth = 0;
    for (var i = 0; i < AElements.length; i++) {
        if ($(AElements[i]).width() > mainWidth) mainWidth = $(AElements[i]).width();
    }	

    Element.width(mainWidth);	
	
	var widthForMargine = Element.parent().width();
	
	function FixMargin() {
		var tWidthForMargine = Element.parent().width() - widthForMargine;
		if (tWidthForMargine < 0) tWidthForMargine = tWidthForMargine * (-1);
		if (tWidthForMargine > 40) widthForMargine = Element.parent().width();
		var s = (widthForMargine - Element.width()) / 2;
		Element.css('margin-left', s + 'px');		
	}
	
		$(window).resize(function() {
			FixMargin();
		});
	
	FixMargin();

    /*var divPictures = $(document.createElement('div'));

    AElements.clone().appendTo(divPictures);

    Element.children().detach();
    Element.append(AElements);*/

    AElements.each(function (Index, ElementThis) {
        $(ElementThis).css('position', 'absolute');
        $(ElementThis).css('top', '0');
        $(ElementThis).css('left', '0');
        $(ElementThis).attr('enumber', (Index + 1));
        $(ElementThis).attr('show', 'none');
        $(ElementThis).fadeOut(0);
    });

    AElements.first().attr('show', 'yes'); ;
    AElements.first().fadeIn(0);
    //Element.height(AElements.first().height());

    function StartSwitch() {
		if (AElements.length > 1) {
			var ShowElement = AElements.filter('.picNode[show="yes"]');
			var indexThis = parseInt(ShowElement.attr('enumber'));
			if (indexThis == AElements.length) indexThis = 1; else indexThis++;
			var hideElement = AElements.filter('.picNode[enumber="' + indexThis + '"]');

			ShowElement.attr('show', 'none');
			hideElement.attr('show', 'yes');

			Element.height(hideElement.height());
			Element.width(hideElement.width());
			FixMargin();
			hideElement.fadeIn(3000);
			ShowElement.fadeOut(3000);
		}
    }

    this.repeatGo = function () {
        stopthis = false;
        GoStep1();
    }

    this.stop = function () {
        stopthis = true;
        clearTimeout(animation);
    }
	
	this.fix = function() {
		FixMargin();
	}

    var stopthis = false;
    var animation;

    function GoStep1() {
        if (!stopthis) {
            animation = setTimeout(function () { StartSwitch(); GoStep1(); }, 9000);
        }
    }

}

function GlamourBanners(Element) {
	    if (Element == undefined)
        return false;

    Element = $(Element);

    var AElements = Element.find('.picNode');
	
	AElements.each(function(index, Element) {
		var d = 500;
		var e = $(Element);		
		var a = e.find('img').first();
		var img = a[0].nodeName.toLowerCase() == 'img' ? a : a.children().first();
		e.width(img.width());
		e.height(img.height());
		var b = $(e.find('img')[1]);
		b.css('display','none');
		e.mouseover(function() {
			b.fadeIn(d);
			a.fadeOut(d);
		});
		e.mouseleave(function() {
			a.fadeIn(d);
			b.fadeOut(d);			
		});
	});
}

