$.fn.splitUp=function(splitBy,wrapper){
    $all= $(this).find('>*');
    var fragment=Math.ceil($all.length/splitBy);
    for (i=0;i<fragment;i++)
        $all.slice(splitBy*i,splitBy*(i+1)).wrapAll(wrapper);
    return $(this);
}

var timeout = 0;
function alert_new(message, href, tout)
{
    tout = tout ? tout : 3000;
    href = href ? href : "";
    var el = $("#info_message");
    el.html(message);

    var left = $(window).width() / 2 - el.innerWidth() / 2;
    el.css("left", left);

    el.fadeIn("fast");

    clearTimeout(timeout);
    timeout = setTimeout(function()
            {
                el.fadeOut("normal", function()
                {
                    el.html('')
                    if (href != "")
                    {
                        window.location.href = href;
                    }
                })
            }, tout);
}

function log(text, type)
{
	$.post("/wp-content/plugins/cmiform/log_ajax.php",
		{
			message: text, 
			type: type
		},
		function(data) 
		{
			return;
		}, "json");  
}

function opacity_hacks(){
	if($('.input-file label input').lenght>0){
		$('.input-file label input').css('opacity','0');
	}
	
	if($('.input_file .button_add input').length>0){
		$('.input_file .button_add input').css({'opacity':'0','-moz-opacity': '0', 'filter':'progid:DXImageTransform.Microsoft.Alpha(opacity=0)'});
	}
	
	if($('.info_message').length>0){
		$('.info_message').css({'-moz-border-radius':'3px','-webkit-border-radius':'3px','opacity':'0.8','filter':'alpha(opacity=80)'});
	}
	
	if($('.selectedTxt').length>0){
		$('.selectedTxt').css('zoom','1');
	}
}

$(document).ready(function() {
	opacity_hacks();
	
	if($('#userPassword').length>0){
		$('#userPassword').attr('autocomplete','off');
	}
	
	if($('#userPassword_retyped').length>0){
		$('#userPassword_retyped').attr('autocomplete','off');
	}
	
    $('.slider_portofolio').splitUp(2,'<dl>').cycle({
        fx:'scrollHorz',
        next: '#down',
        prev: '#up',
        timeout:0
    });
   
    $(".faq > h3").click(function () {
        $(this).parent().children('div.faq_content').slideToggle(400);
    });
	
	if($('.slider_portofolio').length>0 && ($.browser.msie && $.browser.version<9)){
		$('.slider_portofolio span.bg').css('filter','progid:DXImageTransform.Microsoft.Alpha(opacity=100)');
		$('.slider_portofolio span.bg').css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader()');
		$('.slider_portofolio span.bg img').each(function(index) {
			$(this).css('filter','progid:DXImageTransform.Microsoft.Alpha(opacity=100');
		});
 	}
});

$(window).load(function() {
	var newListSelected_zindex=9900;
	var newListSelected_newList_zindex=9800;
	var newListSelected_selectedTxt_zindex=9700;

	
	$('.bar_content .newListSelected').each(function(index) {
		$(this).css('z-index',newListSelected_zindex);
		$(this).children('.newList').css('z-index',newListSelected_newList_zindex);
		$(this).children('.selectedTxt').css('z-index',newListSelected_selectedTxt_zindex);
		
		newListSelected_zindex=newListSelected_zindex-1000;
		newListSelected_newList_zindex=newListSelected_newList_zindex-1000;
		newListSelected_selectedTxt_zindex=newListSelected_selectedTxt_zindex-1000;
	});
	
	if($('#prj_list ul.newList').length>0){
		$('#prj_list ul.newList').css("overflow-y","auto")
	}
});






