var JOOMLA_URL_TEMPLATE=""
var JOOMLA_URL_JS=JOOMLA_URL_TEMPLATE+"scripts";
var JQUERY_URL_MODULE=JOOMLA_URL_JS+"/moudleJQuery";
var JQUERY_URL=JQUERY_URL_MODULE+"/jquery";
var JQUERY_URL_UI=JQUERY_URL+"/ui";
var JQUERY_URL_PLUGIN=JQUERY_URL+"/plugins";
var JQUERY_URL_THEMES=JQUERY_URL+"/themes";
var JQUERY_SCRIPT=new Array();
var JQUERY_CSS=new Array();
var JQUERY_THEMES=null;
var JQUERY_URL_FLOWPLAYER=JQUERY_URL_MODULE+"/flowplayer.org";
var JQUEY_URL_HIGHSLIDE=JQUERY_URL_MODULE+"/highslide";
function addScript(url)
{
    var scriptTag=document.createElement("script");
    scriptTag.language="javascript";
    scriptTag.src=url;
    var hh = document.getElementsByTagName('head')[0];
    hh.appendChild(scriptTag);
    JQUERY_SCRIPT.push(url);
}
function addCss(url)
{
    var cssTag=document.createElement("link");
    cssTag.rel="stylesheet";
    cssTag.type="text/css";
    cssTag.href=url;
    var hh = document.getElementsByTagName('head')[0];
    hh.appendChild(cssTag);
    JQUERY_CSS.push(url);
}
/*-----Begin:Init-----*/
function Init()
{
	addScript(JOOMLA_URL_JS+"/Default.js");

}
/*-----End:Init-----*/
/*-----Begin Add JQuery Script---*/
function addScriptJQuery()
{
	addScript(JQUERY_URL+"/jquery.js");
}
function addScriptUI(name)
{
	addScript(JQUERY_URL_UI+"/ui.core.js");
	if(name!=null)
		addScript(JQUERY_URL_UI+"/"+name);
}
/*-----End Add JQuery  Script---*/

function addPlugins(name)
{
	addScript(JQUERY_URL_PLUGIN+"/"+name);
}


/*-----Begin Add JQuery  CSS Theme---*/
function addThemes(nameTemplate,name)
{
	if(nameTemplate==null)
		nameTemplate="base";
	
	JQUERY_THEMES=nameTemplate;
	addCss(JQUERY_URL_THEMES+"/"+JQUERY_THEMES+"/ui.core.css");
	if(name!=null)
		addCss(JQUERY_URL_THEMES+"/"+JQUERY_THEMES+"/"+name+".css");
}
/*-----End Add JQuery  CSS Theme---*/

/*------Begin flowplayer.org---*/
function addFlowplayer(name)
{
	addScript(JQUERY_URL_FLOWPLAYER+"/"+name);
	ConfigFlowplayer();
}
function ConfigFlowplayer()
{

	    window.account = window.account || {};
		window.account.admin = true;
		
		window.v = {
			core: JQUERY_URL_FLOWPLAYER+"/swf/flowplayer-3.1.1.swf",
			content: "flowplayer.content-3.1.0.swf",
			controls: "flowplayer.controls-3.1.1.swf",
			tube: "flowplayer.controls-tube-3.1.1.swf",
			rtmp: "flowplayer.rtmp-3.1.0.swf",
			pseudostreaming: "flowplayer.pseudostreaming-3.1.2.swf"
		};
}
function playFlowplayer(name,file)
{
	ConfigFlowplayer();  
	flowplayer(name,  {src: JQUERY_URL_FLOWPLAYER+"/swf/flowplayer-3.1.1.swf", wmode: 'opaque',autoPlay: 'true',autoBuffering: 'true'  } ,file);
}
/*------End flowplayer.org---*/

/*------Begin HighSlide---*/
function addHighSlide()
{

	addCss(JQUEY_URL_HIGHSLIDE+"/highslide.css");
	addScript(JQUEY_URL_HIGHSLIDE+"/highslide-full.js");
}
/*------End HighSlide---*/

/*---------Round--*/

function addCorner()
{
	addScript(JQUERY_URL_MODULE+"/jquery.corner.js");
} 

function attchRound(selector)
{
	if(selector==null)
		selector=".roundable";
	if(jQuery(selector).html()!=null )
	{
		var listround=jQuery(selector);
		for(var i=0;i<listround.length;i++)
		{
			var round=6;
			if(listround[i].round!=null)
				round=listround[i].round;
			//alert(round);
			DD_roundies.addRule(listround[i],6,true);
		}
		
	}
}
function addRound()
{
	DD_roundies();
}
function DD_roundies()
{
	addScript(JQUERY_URL_MODULE+"/DD_roundies_0.0.2a.js");
}
function addHAccordion()
{
	addScript(JQUERY_URL_MODULE+"/jquery.haccordion.js");
}
function addScrollPage()
{
	addScript(JQUERY_URL_MODULE+"/jScrollPane.js");
}

function addclassHover(classname)
{
    jQuery('.'+classname).mouseover(function()
    {
        jQuery(this).addClass(classname+"_hover");
    });
    jQuery('.'+classname).mouseout(function()
    {
        jQuery(this).removeClass(classname+"_hover");
    });
}
function addFocus(classname,input_focus)
{

    if( jQuery(classname)==null)
        return;
    jQuery(classname).focus(function()
    {
        jQuery(this).addClass(input_focus);
    });
    jQuery(classname).blur(function()
    {
        jQuery(this).removeClass(input_focus);
    });
}
function play(obj,idplayer)
{

	var file=jQuery(obj).attr("file");
	playFlowplayer(idplayer,file);

}
function attackUI()
{

	addclassHover("bt_cart");
	addclassHover("bt_submit");
	addclassHover("search_bt");
	jQuery("input:text").addClass("textbox");
	jQuery("textarea").addClass("textarea");
	addFocus("input:text","textbox_focus");
	addFocus("textarea","textarea_focus");
	
}


function loadimage(index)
{
		
		var a=jQuery(".roundthumb>.items>a")[index];
		jQuery('#aimgbig').attr('href',a.href);
		jQuery('.imgbig').attr('src',a.href)

		
		jQuery('#zoom').attr('href',a.href);
		jQuery(".roundthumb>.items").removeClass("active");
		jQuery( jQuery(".roundthumb>.items")[index] ).addClass("active");
		return false;

}

function attackSearch(selector)
{
 jQuery(selector).attr("defaultvalue",jQuery(selector).val());
 jQuery(selector).blur(function()
 {
  var text=jQuery(this).attr('value').replace(" ","");
  if(text=="")
  {
   var value=jQuery(this).attr('defaultvalue');
   jQuery(this).val(value);
  }
 });
 jQuery(selector).click(function()
 {
  if(jQuery(this).val()==jQuery(this).attr('defaultvalue'))
  { 
   jQuery(this).val("");
  } 
 });
}



function expandMenu(selector)
{
        
        var listul=jQuery(selector+" ul ul");
        listul.addClass("submenu");
        
        for(var i=0;i<listul.length;i++)
        {
            var ul=listul[i];
            if(jQuery(ul).find("li").html()==null)
                continue;

            var a=jQuery( jQuery(ul).parent() ).find("a")[0];
            jQuery(a).addClass("submenuheader");
            jQuery(a).attr("itemid",i);
            jQuery(a).attr("expand","false");
            jQuery(a).hover(function()
            {
                var li=jQuery(this).parent();
                var ul=jQuery(li).parent();
                var ali=jQuery(ul).children("li");
                for(var j=0;j<ali.length;j++)
                {
                    if( jQuery(ali[j]).find("a").attr("itemid") !=jQuery(this).attr("itemid") )
                    {
                        //jQuery(ali[j]).children("ul").css("display","none");
                        jQuery(ali[j]).children("ul").hide("slow");

                        jQuery(ali[j]).children("a").attr("expand","false");
                        jQuery(ali[j]).children("a").removeClass("active");
                        
                    }
                }
                
                var itemid=jQuery(this).attr("itemid");
                var ul=jQuery(this).parent().find(".submenu")[0];
                if(jQuery(this).attr("expand")=="true")
                {
                   // jQuery(this).attr("expand","false");
                    //jQuery(ul).toggle("slow");
                }
                else
                {    
                    jQuery(this).attr("expand","true");
                    jQuery(ul).toggle("slow");
                    jQuery(this).addClass("active");
                }
                return true;
            });
            
        }
                
        var location=window.location.href;
        var lista=jQuery(selector+" a");
        for(var i=0;i<lista.length;i++)
        {
            var a=lista[i];
            if(jQuery(a).attr("href")==location)
            {
                a.id="current";
                var li=jQuery(a).parent();
                var lista=new Array();
            
                while(true)
                {
                    if(li[0]==null)
                        break;
                    if(li[0].tagName=="LI")
                    {
                        var aactive=li.children("a");
                        jQuery(aactive).addClass("active");
                        jQuery(aactive).attr("expand",true);
                        var ula=li.children("ul")
                        if(jQuery(ula).find("li").html()!=null)
                            li.children("ul").toggle("fast");//css("display","block");
                    }
                    li=jQuery(li).parent();
                    if(li.hasClass("scrollleft")==true)
                        break;
                }
            }
        
        }


  

}

 function expandMenuTop(selector)
{
        
        var listul=jQuery(selector+" ul ul");
        listul.addClass("submenu");
        
        for(var i=0;i<listul.length;i++)
        {
            var ul=listul[i];
            if(jQuery(ul).find("li").html()==null)
                continue;
            var li=jQuery(ul).parent();
            var a=li.find("a")[0];
            jQuery(a).addClass("submenuheader");
            jQuery(a).attr("itemid",i);
            jQuery(a).attr("expand","false");
        
            
            
            jQuery(li).hover(
            function()
            {
                var li=this;
                var ul=jQuery(li).find("ul")[0];
                var ali=jQuery(ul).children("li");
                var a=jQuery("a",li)[0];
                for(var j=0;j<ali.length;j++)
                {
                
                    if( jQuery(ali[j]).find("a").attr("itemid") !=jQuery(this).attr("itemid") )
                    {
                        jQuery(ali[j]).children("ul").hide("slow");
                        jQuery(ali[j]).children("a").attr("expand","false");
                        jQuery(ali[j]).children("a").removeClass("active");
                        
                    }
                }
                var itemid=jQuery(a).attr("itemid");
                //var ul=jQuery(this).parent().find(".submenu")[0];


                jQuery(this).attr("expand","false");
                jQuery(ul).toggle("fast");
                jQuery(a).addClass("active");

                
            },
            function()
            {
            
                var li=this;
                var ul=jQuery(li).find("ul")[0];
                var a=jQuery("a",li)[0];

                jQuery(this).attr("expand","true");
                jQuery(ul).toggle("slow");
                jQuery(a).removeClass("active");
                


            })
            jQuery(a).click(function()
            {
                return true;
            });
            
        }
                
        var location=window.location.href;
        var lista=jQuery(selector+" a");
        
        for(var i=0;i<lista.length;i++)
        {
            var a=lista[i];
            if(jQuery(a).attr("href")==location)
            {
                a.id="current";
                var li=jQuery(a).parent();
                var lista=new Array();
            
                while(true)
                {
                    
                    if(li[0].tagName==null)
                        break;
                
                    if(li[0].tagName=="LI")
                    {
                        var aactive=li.children("a");
                        jQuery(aactive).addClass("current");
                        jQuery(aactive).attr("expand",true);
                        //li.children("ul").toggle("fast");//css("display","block");
                    }
                    li=jQuery(li).parent();
                    if(li.hasClass("scrollleft")==true)
                        break;
                }
            }
        
        }


  

}


function autoHeight(selector1,selector2,selectorflash)
{
	var heightselector1=jQuery(selector1).height();
	var heightselector2=jQuery(selector2).height();
	if(selectorflash!=null)
		var heightselectorflash=jQuery(selectorflash).height();
	heightselectorflash=heightselectorflash+31;
	var maxHeight=heightselector1> heightselector2+heightselectorflash? heightselector1:heightselector2+heightselectorflash;
	jQuery(selector1).height(maxHeight);
	jQuery(selector2).height(maxHeight-heightselectorflash);
}
function autoSameHeight(classSame,selectorflash)
{ 	
	var maxheight=0;
	var maxheight=0;
	jQuery("."+classSame).each(function(){
		if(maxheight<jQuery(this).height()){
			maxheight=jQuery(this).height();
		}
	});
	jQuery("."+classSame).each(function(){
		jQuery(this).height(maxheight);
	});
}
function checkall(objthis)
{	
		if(objthis.checked==true)
		{
			jQuery(".checkboxcart").attr("checked",true);
		}
		else
			jQuery(".checkboxcart").attr("checked",false);
	
}
function attackend()
{
	jQuery("ul").each(function()
	{

		jQuery(this).find("li:last").addClass("end");
	});
}
function attacklistproduct()
{
	var items=jQuery(".listproducts .items");
	var lenght=items.length;
	if(lenght%2==0)
	{	
		//alert(lenght);
		if(lenght>=2)
			jQuery(items[lenght-2]).addClass("end");
	}
	if(lenght>=1)
		jQuery(items[lenght-1]).addClass("end");
	
}
function attackmenucenter(selector)
{	

	jQuery(selector+" ul").width(jQuery(selector+" ul").width());
	jQuery(selector+" ul").css("float","none");
	jQuery(selector+" ul").css("margin","0 auto");
}
