//jQuery.noConflict();
/*
jQuery(document).ready(function(){
  alert('test');
});*/
var sPathTheme = "/wp-content/themes/stopdwang";
function initMasonry(){
    $('.home .boxes').masonry();
}

function initCufon(){
	Cufon.replace('.post h1, .post h2, .page h1, .page h2, .main-aside .widgettitle');
}


/* SWFObject */
function initSWFObject(){
    
    var parFlashSelectedPage = (flashSelected != null || flashSelected != '') ? flashSelected : '';

	var sHeader = "large";
	var sHeight = "530";

	if($(".header-small").length != 0){
		sHeader = "small";
		sHeight = "330";
	}
	var sLocation = sPathTheme + "/flash/header-"+sHeader+".swf";
	var header = new SWFObject(sLocation, "header-flash", "100%", sHeight+"px", "8");
	header.addVariable("page", parFlashSelectedPage);
	header.write("header"); 
	
	var sTestPath = sPathTheme + "/flash/stopdwang-test.swf";
	var test = new SWFObject(sTestPath, "stopdwang-test", "100%", "100%", "8");
	test.addVariable("sBaseUrl", "http://www.stopdwang.nl/" );
	test.addVariable("tId", "1");
	test.addParam("wmode","transparent");
	test.write("testHolder"); 
	$('#testHolder').fixedPosition();
}

function clickableSideBars(){
    $('.main-aside .advancedtext').each(
        function( intIndex ){
         
            // Bind the onclick event to simply alert the
            // iteration index value.
            var oSlugLink = $(this).find(".advancedtext-slug");
            if( oSlugLink != "" || oSlugLink != null ){
                var sSlug = oSlugLink.attr('href');
                var sTarget = oSlugLink.attr('target');

                $( this ).bind (
                    "click",
                    function(){
                        if(sTarget == '' ){
                            window.location = sSlug;
                        } else {
                            //open new window
                            //alert(sSlug + ' ' +  sTarget);
                            window.open(sSlug);
                            return false;
                        }
                        
                    }
                ).css('cursor', 'pointer');
            }
         
        }
    );

}

function showTest(){
	$('#testHolder').css('display','block');
	$('#header').css('visibility','hidden');
    $('#testHolder').fixedPosition();
}
function showTest2(){
    $('#testHolder').css('display','block');
	$('#header').css('visibility','hidden');
    //$('#testHolder').fixedPosition();
    $('#testHolder').fixedPosition({vpos:'top', hpos:'center'});
}

function hideTest(){
	$('#testHolder').css('display','none');
	$('#header').css('visibility','visible');
}


$(document).ready(function() { 
    $('.cform .sendbutton').attr("value","");
    initSWFObject();
    initCufon();
    clickableSideBars();
    //initMasonry();
    $('#testHolder').css('top',$(document).scrollTop());
});
