var curArt = 1;

function loadCss(page,params) {
        $("head").append("<link>");
    css = $("head").children(":last");
    css.attr({
      rel:  "stylesheet",
      type: "text/css",
      href: "/inc/modules/"+page+"/style.php?" + params
    });
    
}
function selectSmall(artnum) {
    $("#small1").removeClass("selected");
    $("#small2").removeClass("selected");
    $("#small3").removeClass("selected");
    $("#small4").removeClass("selected");

    $("#small" + artnum).addClass("selected");

}
function slideArts(artnum) {
 var   moveToPx = ((artnum - 1) * 278) * -1 ;
 selectSmall(artnum);
 
 $('#artsSlider .titleDetails').fadeOut(500);
 $('#artsSlider .blackBg').animate({opacity:0},'500');
 $('#artsSlider').animate({
    top: moveToPx + 'px'
  }, {
    duration: 1000,

    complete: function() {
        //alert('completed');
        curArt = artnum;
        $('#artsSlider .blackBg').animate({opacity:0.6},'500');
        $('#artsSlider .titleDetails').fadeIn(500);
 
    }
  });
}

function slideArtsNext() {
    if (curArt == 4) curArt = 1; else curArt += 1;
    slideArts(curArt);
}

function initMenus() {
    var img = new Image();
    $(img).attr('src','/images/menu/1on.png');
    $(img).attr('src','/images/menu/2on.png');
    $(img).attr('src','/images/menu/3on.png');
    $(img).attr('src','/images/menu/4on.png');
    $(img).attr('src','/images/menu/5on.png');
    $(img).attr('src','/images/menu/6on.png');
    $(img).attr('src','/images/menu/7on.png');
    $(img).attr('src','/images/menu/8on.png');
    $(img).attr('src','/images/menu/9on.png');
    $(img).attr('src','/images/menu/10on.png');

    $(img).attr('src','/images/media_menu/1off.png');
    $(img).attr('src','/images/media_menu/2.png');
    $(img).attr('src','/images/media_menu/3.png');
    $(img).attr('src','/images/media_menu/4.png');

    $(img).attr('src','/images/ajaxOpts/opt1off.png');
    $(img).attr('src','/images/ajaxOpts/opt2off.png');
    $(img).attr('src','/images/ajaxOpts/opt3off.png');
    $(img).attr('src','/images/ajaxOpts/opt4off.png');
    $(img).attr('src','/images/ajaxOpts/opt5off.png');

    $(img).attr('src','/images/ajaxOpts/opt1on.png');
    $(img).attr('src','/images/ajaxOpts/opt2on.png');
    $(img).attr('src','/images/ajaxOpts/opt3on.png');
    $(img).attr('src','/images/ajaxOpts/opt4on.png');
    $(img).attr('src','/images/ajaxOpts/opt5on.png');

}

function hoverMenuOn(num) {
        $("#menuItem"+num+"  img").attr('src','/images/menu/'+ num + 'on.png');
}
function hoverMenuOff(num) {
        $("#menuItem"+num+"  img").attr('src','/images/menu/'+ num + '.png');
}
$(document).ready(function() {
             window.fbAsyncInit = function() {
        FB.init({appId: '291164260926411', status: true, cookie: true,
                 xfbml: true});
      };
      (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
          '//connect.facebook.net/ar_AR/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());
var screenWidth = screen.width;
if (screenWidth < 1150) $(".pageDiv").css('float','right');
//if (screenWidth < 1350) $(".navigation").css('display','none');
//setTimeout("loadBanners()",2000);

});

function loadOpts(curtab,type) {
    var counter = 1;
    $("#ajaxButtons .ajaxButton").each(function(){
        $(this).find("img").attr("src","/images/ajaxOpts/opt"+counter+"on.png");
        counter++;
    });
    $(curtab).find("img").attr("src","/images/ajaxOpts/opt"+type+"off.png");

     var url = "/?mod=ajax&todo=ajaxOpts";
    $.ajax({
    url: url,
    type: 'POST',
    cache: false,
    data: 'type=' + type,
    success: function(result){
        $("#optsCont").html(result);
    }
    });
}

function make_home() {
		event.preventDefault(); // prevent the anchor tag from sending the user off to the link
		var url = location.href;
                document.setHomePage(url);
}

function make_fav() {
    		var url = location.href;
		var title = document.title;

		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}


}

function loadMediaVideos(curtab,type,cat) {
    var counter = 1;
    $("#mediaTabs .tab").each(function(){
        $(this).find("img").attr("src","/images/media_menu/"+counter+"off.png");
        counter++;
    });
    $(curtab).find("img").attr("src","/images/media_menu/"+type+".png");

     var url = "/?mod=ajax&todo=mainVidsCat";
    $.ajax({
    url: url,
    type: 'POST',
    cache: false,
    data: 'cat=' + cat,
    success: function(result){
        $("#mainVids").html(result);
    }
    });
}

function showRelated(id) {
    var url = "/?mod=ajax&todo=relatedVideos";
    $.ajax({
    url: url,
    type: 'POST',
    cache: false,
    data: 'vid=' + id,
    success: function(result){
        $("#realtedVids").html(result);
    }
    });
 
}

function getComment(id) {
    if ($("#comData" + id).css("display") != "none") {
            $("#comData" + id).animate({height: 'hide'}, {duration: 500});
    }else{
    var url = "/?mod=ajax&todo=getComment";
    $.ajax({
    url: url,
    type: 'POST',
    cache: false,
    data: 'comment=' + id,
    success: function(result){
        $("#comData" + id).html(result);
        $("#comData" + id).animate({height: 'show'}, {duration: 500});
    }
    });
    }
    
}

function fbs_click() {
u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}

function fbs_share(url,title) {
u=url;t=title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}


function openPopup(url,width,height,scrollbars) {
    window.open(url,'bokrapop','toolbar=0,status=0,scrollbars='+scrollbars+',width='+width+',height=' + height);
}

function postComment(aid) {
    params = generateParms("#addcom");
    $.ajax({
        url: '/?mod=ajax&todo=postcomment',
        type: 'post',
        data: 'aid='+aid+ "&" + params,
        success: function(result) {
            $("#addcom").html(result);
        }
    });

}

function generateParms(form) {
    var str="";
    var i = 0;
    $(':input', form).each(function() {
        var type = this.type;
        if (type == 'checkbox') {
           if (this.checked) {
               if (i >0) str += "&";
                str += this.name + '=' + $(this).val();
           }
        }else{
        if (i >0) str += "&";
            str += this.name + '=' + $(this).val();
        }
        i++;
    });
return(str);
}

function loadBanners() {
    $('.IFRAMEbanner').each(function(){
        var src = $(this).attr('alt');
        $(this).attr('src',src);
        $(this).css("display","block");
    });
}

function setHP()
{

if(window.ActiveXObject && document.getElementById){
document.getElementById('hmpg').setHomePage('http://www.bokra.net');
document.location="http://www.bokra.net";

} else {
//alert('Your Browser Doesnt Support it !');
document.location="http://www.bokra.net";
}
}
if(window.ActiveXObject && document.getElementById){
document.write('<div id="hmpg" style="position:absolute;left:0px;top:0px;behavior:url(#default#homepage);"></div>');
}


function submitPetition() {
    params = generateParms("#petition");
    $.ajax({
        url: '/?mod=ajax&todo=petition',
        type: 'post',
        data: params,
        success: function(result) {
            $("#petition").html(result);
        }
    });
}

function submitPetition2() {
    params = generateParms("#petition2");
    $.ajax({
        url: '/?mod=ajax&todo=petition',
        type: 'post',
        data: params,
        success: function(result) {
            $("#petition2").html(result);
        }
    });

}

function readInc(id) {
    $.ajax({
        url: '/?mod=ajax&todo=readinc',
        type: 'post',
        data: 'id=' + id,
        success: function(result) {
        }
    });
}
