(function($) {
    if ($.browser.mozilla) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).css({
                    'MozUserSelect' : 'none'
                });
            });
        };
    } else if ($.browser.msie) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).bind('selectstart', function() {
                    return false;
                });
            });
        };
    } else {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).mousedown(function() {
                    return false;
                });
            });
        };
    }
})(jQuery);

$(document).ready(function(){
    //setInterval("window.clipboardData.setData('text','')",1);
    $(document).bind("contextmenu",function(e){return false;});
    $('body').click(deselect);
    $(document).mousemove(deselect);
    $(document).mouseup(deselect);

    $(document).keydown(function(event){
	if(event.keyCode==116)
	{	    
	    window.close();
	}
	//if((event.keyCode==16)||(event.keyCode==18)||(event.keyCode==65)||(event.keyCode==67)||(event.keyCode==45)||(event.keyCode==80)||(event.keyCode==81)||(event.keyCode==112))
	{	    
	    deselect();
	    return false;
	}
	return true;        
    });
    $(document).keyup(function(event){
        if(event.keyCode==44)
        {
            deselect();
            alert('Copyright @2009 Cantera Stone Source LLC');
        }
    });
    
    $('img').mousedown(function(event){return false;});    

});

$(document).focus(showme);
function showme()
{
    //alert('displaying');
    $('#absblocker').css('background-color','transparent');
    $('#absblocker').css('background-image','url(/img/blank.gif)');
    $('#absblocker').css('background-repeat','repeat');
    
};
$(document).blur(hideme);
function hideme()
{
    $('#absblocker').css('background-color','#D9C6A5');
    $('#absblocker').css('background-image','url(/img/loading.gif)');
    $('#absblocker').css('background-repeat','no-repeat');
}
function deselect()
{
	if (document.selection)
	{
		document.selection.empty();
		Copied=document.body.createTextRange();
	}
	else if (window.getSelection){window.getSelection().removeAllRanges()};
	/*if((window.clipboardData)!=null)
	    window.clipboardData.clearData();*/
            
}

function jumpto($iid)
{
    window.opener.location.href="/portfolio/view.php?id="+$iid;
    window.close();
}

function pdfpage($page)
{
    if( $('max').val()==1 )
        return false;

    $src=$('#pdf').attr('src');
    for($count=0;$src.indexOf('-'+$count)==-1;$count++)
    {}
    $src=$src.replace('-'+$count,'-'+($page-1));
    $('#pdf').attr('src',$src);
    $('.cur').removeClass('cur');
    $('.pg'+($page)).addClass('cur');
    
}