

var load = function(){
	$.baseurl = $('head base').attr('href');
	//console.info($('.boxmid .options a').children("[rel=shareit]").parent());
    /*ajaxLoadModuloPart(1,'software',$.getKarmaVar(),null,'software_irudiak','shot');*/
	var osName = "Unknown";
	if (navigator.appVersion.indexOf("Win")!=-1) osName="Windows";
	if (navigator.appVersion.indexOf("Mac")!=-1) osName="Mac";
	if (navigator.appVersion.indexOf("Linux")!=-1) osName="Linux";
	if (navigator.appVersion.indexOf("X11")!=-1) osName="Linux";
	/*if ($('p.os').html().indexOf(osName) >= 0) {*/
	/*alert(navigator.appVersion);*/
			
	$('a.os').find('img').each(function() {
		var os = $(this).attr('alt').toLowerCase();	
		if (os == osName.toLowerCase()) {
			$(this).attr('src',$.baseurl+'img/seragileak/download_'+os+'_on.png');
		}	
	 });
        // http://www.queness.com/post/309/create-a-digg-style-post-sharing-tool-with-jquery
    	//grab all the anchor tag with rel set to shareit
	//$('a[rel=shareit], #shareit-box').mouseenter(function() {
	$('.boxmid .options a').children("[alt=banatu]").parent().mouseenter(function() {
		//get the height, top and calculate the left value for the sharebox
		var height = $(this).height();
		var ref = $('.boxmid .options a');
		var top = ref.offset().top - 50; /* hardcode*/
		//get the left and find the center value
		var left = ref.left   + ($(this).width() /2) - ($('#shareit-box').width() / 2);

		//grab the href value and explode the bar symbol to grab the url and title
		//the content should be in this format url|title
		var value = $(this).attr('href').split('|');

		//assign the value to variables and encode it to url friendly
		var field = value[0];
		var url = encodeURIComponent(value[0]);
		var title = encodeURIComponent(value[1]);

		//assign the height for the header, so that the link is cover
		$('#shareit-header').height(height+12);

		//display the box
		$('#shareit-box').show();

		//set the position, the box should appear under the link and centered
		$('#shareit-box').css({'top':top, 'left':left});

		//assign the url to the textfield
		$('#shareit-field').val(field);

		//make the bookmark media open in new tab/window
		$('a.shareit-sm').attr('target','_blank');

		//Setup the bookmark media url and title
		$('a[rel=shareit-mail]').attr('href', 'http://mailto:?subject=' + title);
		$('a[rel=shareit-delicious]').attr('href', 'http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=' + url + '&title=' + title);
		$('a[rel=shareit-designfloat]').attr('href', 'http://www.designfloat.com/submit.php?url='  + url + '&amp;title=' + title);
		$('a[rel=shareit-digg]').attr('href', 'http://digg.com/submit?phase=2&amp;url=' + url + '&amp;title=' + title);
		$('a[rel=shareit-stumbleupon]').attr('href', 'http://www.stumbleupon.com/submit?url=' + url + '&title=' + title);
		$('a[rel=shareit-twitter]').attr('href', 'http://twitter.com/home?status=' + title + '%20-%20' + title);

	});

	//onmouse out hide the shareit box
	$('#shareit-box').mouseleave(function () {
		$('#shareit-field').val('');
		$(this).hide();
	});

	//hightlight the textfield on click event
	$('#shareit-field').click(function () {
		$(this).select();
	});
   
	$("#form_rating").rating("disable");



	var options = { 
		success: function() {
			//console.info("ok");

		}

	};



   
        $("#submit_rating").live("click",function(){

            var self = _$(this);
            var parentform = self.parents("form");
            action = self.val();
	    var options = { 
		success: function(a,b) {
			$().message('Eskerrik asko zure botoagatik');
			return false;
		}      


  			// post-submit callback 

		// other available options: 
		//url:       url         // override for form's 'action' attribute 
		//type:      type        // 'get' or 'post', override for form's 'method' attribute 
		//dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
		//clearForm: true        // clear all form fields after successful submit 
		//resetForm: true        // reset the form after successful submit 
		// $.ajax options can be used here too, for example: 
		//timeout:   3000 
	    }; 
	    parentform.ajaxSubmit(options);


           return false;
        });

	$("#captcha_code").clearInput();
	$("#username").clearInput();
	
	$("#commbox").clearInput();
	$("#emaila").clearInput();
	$("#name").clearInput();
	$("#search").clearInput();
	$("#password").DefaultValue("password");
	$("#software_comment_form").validate({
                rules: {
                        name: "required",
                        emaila: {
                                required: true,
                                email: true
                        }
                },
                messages: {
                        name: "Zure izena ipini behar duzu",
                        emaila: "Zure e-posta ipini behar duzu"
                }

        });
	$(".slider a").lightBox({
			imageLoading: $.baseurl+'css/images/lightbox-ico-loading.gif',
                        imageBtnPrev: $.baseurl+ 'css/images/lightbox-btn-prev.gif',    
                        imageBtnNext: $.baseurl+ 'css/images/lightbox-btn-next.gif',      
                        imageBtnClose: $.baseurl+ 'css/images/lightbox-btn-close.gif',      
                        imageBlank:  $.baseurl + 'css/images/lightbox-blank.gif'
				});


};


jQuery(document).ready(load);


