/* menu hover states and Drop down submenu */

function menuOver(Imgid, submenuId){

	var menuImg = document.getElementById(Imgid);

	menuImg.src = menuImg.src.replace('_off', '_on');

	menuImg.src = menuImg.src.replace('_active', '_on');

	if (submenuId) {

	var subMenu = document.getElementById(submenuId);

	subMenu.style.display='block';

	}

}

function menuOut(Imgid, submenuId){

	var menuImg = document.getElementById(Imgid);

	if(menuImg.className == "activeMenu") {

	menuImg.src = menuImg.src.replace('_on', '_active');

	}

	menuImg.src = menuImg.src.replace('_on', '_off');

	if (submenuId) {

	var subMenu = document.getElementById(submenuId);

	subMenu.style.display='none';

	}

}

/* switching carousel tabs on home page */

function switchCarouselTabs(element){

    var prefix = element.id.split('_')[0];

    var contentPrefix = arguments.length == 1 ? [prefix] : arguments[1];

    var index = 1;

    while((tab = document.getElementById (prefix+'_'+(index))) != null) {

		try{

			var current = tab.id == element.id;

	        tab.className = tab.className.replace(current ? 'Off' : 'On', current ? 'On' : 'Off');

	

			var imgBtn = document.getElementById("imgbtn_"+index);

			if(imgBtn!=null){

		        imgBtn.className = current ? 'activeTab' : '';

		        imgBtn.src = imgBtn.src.replace(current ? 'off' : 'active', current ? 'active' : 'off');

			}

			for (var i = 0; i < contentPrefix.length; i++) {

	            var content =  document.getElementById(contentPrefix[i]+'_'+index+'_content');

	            content.style.display = current ? '' : 'none';

	        }

        }catch(e){}

        index++;

    }

}



/* switching tabs on the lightBox pages */

function switchLBTabs(element)

{

    var prefix = element.id.split('_')[0];

    var contentPrefix = arguments.length == 1 ? [prefix] : arguments[1];

    var index = 1;

    while((tab = document.getElementById (prefix+'_'+(index))) != null) {

		var current = tab.id == element.id;

		tab.className = tab.className.replace(current ? 'Off' : 'On', current ? 'On' : 'Off');

		for (var i = 0; i < contentPrefix.length; i++) {

            var content =  document.getElementById(contentPrefix[i]+'_'+index+'_content');

            content.style.display = current ? '' : 'none';

        }

        index++;

    }

}

/* switching Blue Tabs on the home page */

function switchBlueTabs(element)

{

    var prefix = element.id.split('_')[0];

    var index = 1;

    while(document.getElementById(prefix+'_'+index)!= null) {

    	var tab = document.getElementById(prefix+'_'+index);

		tab.className = tab.id==element.id?'blueTabOn active':'blueTabOff';

        index++;

    }

	

	$('#loadingTab').css('display','block');

    $('#contentTab').load(context+'/ajax/home/getTab.do',{tabId:element.id},function(){

    //	$('#servicesAndContent').load(context+'/ajax/home/getServicesAndContent.do',{tabId:element.id},function(){

			$('#loadingTab').css('display','none');

			

			resizeAcordeon();

		//});	

	});

}



function resizeAcordeon(){

	var totalHeight = 290;

	for(var index=1;index<=servicesArray.length;index++){

		var elem = $('#service'+index+'ID')[0];

		if(elem.scrollHeight>0){

			var heightTitle = elem.parentNode.getElementsByTagName('div')[0].scrollHeight;

			var height=totalHeight-(heightTitle*servicesArray.length)-(2*(servicesArray.length-1));

			elem.getElementsByTagName('div')[0].style.height=height+'px';

			break;

		}

	}

}



/* simple rollover states for images */

function imgOver(img) {

	if (img.className == 'activeTab') {

		img.src	= img.src.replace('_active', '_on');

	}

	else {

		img.src	= img.src.replace('_off', '_on');		

	}

}

function imgOut(img) {

	if (img.className == 'activeTab') {

		img.src	= img.src.replace('_on', '_active');

	}

	else {

		img.src	= img.src.replace('_on', '_off');

	}

}



/* simple rollover states for buttons */

function btnOver(btn){

	btn.className = btn.className.replace('Off', 'On');

}

function btnOut(btn){

	btn.className = btn.className.replace('On', 'Off');

}



/* rollover states for tab elements - changing classes */

function tabOver(tab) {

	if (tab.className.indexOf('active')==-1) {

		tab.className = tab.className.replace('Off', 'On');

	}

}

function tabOut(tab) {

	if (tab.className.indexOf('active')==-1) {

		tab.className = tab.className.replace('On', 'Off');

	}

}





/* functions for thumbnail image rollover events */

	function selectImg(index) {

		var rolloverId = "videoRollover_"+index;

		var rolloverDiv = document.getElementById(rolloverId);

		rolloverDiv.style.display = "block";

	}

	function deselectImg(index) {

		var rolloverId = "videoRollover_"+index;

		var rolloverDiv = document.getElementById(rolloverId);

		rolloverDiv.style.display = "none";

		

	}

	

/* function to hide select element (dropdown "Descargas de la Semana") - ie6 fix */

	var browser=navigator.appName;

	var b_version=navigator.appVersion;

	var version=parseFloat(b_version);

	function hideSelect(selectId) {

		if (browser == "Microsoft Internet Explorer" && version == "4") {

			var dropDownId = document.getElementById(selectId);

			dropDownId.style.visibility = "hidden";

		}

	}

	function showSelect(selectId) {

		if (browser == "Microsoft Internet Explorer" && version == "4") {

			var dropDownId = document.getElementById(selectId);

			dropDownId.style.visibility = "visible";

		}

	}

	

/* Open the lightbox */		

function openbox(boxId){

	//document.getElementById(boxId).style.display='block';

	document.getElementById('filter').style.display='block';

}	

/* Close the lightbox */		

function closebox(boxId)

{

	document.getElementById(boxId).style.display='none';

	document.getElementById('filter').style.display='none';

}



/* function to hide/show divs on Detalles del Producto LightBox */

function switchDiv(divIdClose, divIdOpen) {

	document.getElementById(divIdClose).style.display = 'none';

	document.getElementById(divIdOpen).style.display = 'block';	

}



/* collapse/expand view*/

function Holder(id, imageId) {

	this.id=id;

	this.imageId = imageId;

	this.tabsGroup = null;

	this.show = expandView;

	this.hide = collapseView;

}



function expandView() {

	with(this)

	var i;

	for(i = 0; i < this.tabsGroup.length; i++) {

	   if(this == this.tabsGroup[i]){

			var image = document.getElementById(this.imageId);

			document.getElementById(this.id).style.display = 'block';

			image.src = image.src.replace('expand', 'collapse');

			image.alt = image.alt.replace('Expand view', '');			

	   } 

	   else {

	   		this.tabsGroup[i].hide();

	   }

	}

}



function collapseView() {

	with(this)	 

	var image = document.getElementById(this.imageId);

	if(document.getElementById(this.id)!=null)

		document.getElementById(this.id).style.display = 'none';

	if(image!=null){

		image.src = image.src.replace('collapse', 'expand');

		image.alt = image.alt.replace('', 'Expand view');

	}

}



function groupTabs(tabs) {

	var i;

	for(i = 0; i < tabs.length; i++) {

		tabs[i].tabsGroup = tabs;

	}   

}

/* collapse/expand tabs group for home page */

var animadas = new Holder('animadasID', 'animadasTabImage');

var comics = new Holder('comicsID', 'comicsTabImage');

var postales = new Holder('postalesID', 'postalesTabImage');



groupTabs(new Array(animadas,comics,postales));



//var ideasvideo = new Holder('ideasvideoID', 'ideasvideoTabImage');

//var ideastv = new Holder('ideastvID', 'ideastvTabImage');

//var videoclips = new Holder('videoclipsID', 'videoclipsTabImage');



//groupTabs(new Array(ideasvideo,ideastv,videoclips));



/* collapse/expand tabs group for detalles: content type LightBox page */

var masInformacion1 = new Holder('masInformacion1ID', 'masInformacion1TabImage');

var masInformacion2 = new Holder('masInformacion2ID', 'masInformacion2TabImage');

var masInformacion3 = new Holder('masInformacion3ID', 'masInformacion3TabImage');

var masInformacion4 = new Holder('masInformacion4ID', 'masInformacion4TabImage');

var masInformacion5 = new Holder('masInformacion5ID', 'masInformacion5TabImage');

var masInformacion6 = new Holder('masInformacion6ID', 'masInformacion6TabImage');

var masInformacion7 = new Holder('masInformacion7ID', 'masInformacion7TabImage');

var masInformacion8 = new Holder('masInformacion8ID', 'masInformacion8TabImage');

var masInformacion9 = new Holder('masInformacion9ID', 'masInformacion9TabImage');

var masInformacion10 = new Holder('masInformacion10ID', 'masInformacion10TabImage');

var masInformacion11 = new Holder('masInformacion11ID', 'masInformacion11TabImage');

var masInformacion12 = new Holder('masInformacion12ID', 'masInformacion12TabImage');

var masInformacion13 = new Holder('masInformacion13ID', 'masInformacion13TabImage');

var masInformacion14 = new Holder('masInformacion14ID', 'masInformacion14TabImage');

var masInformacion15 = new Holder('masInformacion15ID', 'masInformacion15TabImage');

var masInformacion16 = new Holder('masInformacion16ID', 'masInformacion16TabImage');

var masInformacion17 = new Holder('masInformacion17ID', 'masInformacion17TabImage');

var masInformacion18 = new Holder('masInformacion18ID', 'masInformacion18TabImage');

var masInformacion19 = new Holder('masInformacion19ID', 'masInformacion19TabImage');

var masInformacion20 = new Holder('masInformacion20ID', 'masInformacion20TabImage');





groupTabs(new Array(masInformacion1,masInformacion2,masInformacion3,masInformacion4,masInformacion5,masInformacion6,masInformacion7,masInformacion8,masInformacion9,masInformacion10,masInformacion11,masInformacion12,masInformacion13,masInformacion14,masInformacion15,masInformacion16,masInformacion17,masInformacion18,masInformacion19,masInformacion20));



var configura1 = new Holder('configura1ID', 'configura1TabImage');

var configura2 = new Holder('configura2ID', 'configura2TabImage');

var configura3 = new Holder('configura3ID', 'configura3TabImage');

var configura4 = new Holder('configura4ID', 'configura4TabImage');

var configura5 = new Holder('configura5ID', 'configura5TabImage');

var configura6 = new Holder('configura6ID', 'configura6TabImage');

var configura7 = new Holder('configura7ID', 'configura7TabImage');

var configura8 = new Holder('configura8ID', 'configura8TabImage');

var configura9 = new Holder('configura9ID', 'configura9TabImage');

var configura10 = new Holder('configura10ID', 'configura10TabImage');

var configura11 = new Holder('configura11ID', 'configura11TabImage');

var configura12 = new Holder('configura12ID', 'configura12TabImage');

var configura13 = new Holder('configura13ID', 'configura13TabImage');

var configura14 = new Holder('configura14ID', 'configura14TabImage');

var configura15 = new Holder('configura15ID', 'configura15TabImage');

var configura16 = new Holder('configura16ID', 'configura16TabImage');

var configura17 = new Holder('configura17ID', 'configura17TabImage');

var configura18 = new Holder('configura18ID', 'configura18TabImage');

var configura19= new Holder('configura19ID', 'configura19TabImage');

var configura20= new Holder('configura20ID', 'configura20TabImage');



groupTabs(new Array(configura1,configura2,configura3,configura4,configura5,configura6,configura7,configura8,configura9,configura10,configura11,configura12,configura13,configura14,configura15,configura16,configura17,configura18,configura19,configura20));



var faq1 = new Holder('faq1ID', 'faq1TabImage');

var faq2 = new Holder('faq2ID', 'faq2TabImage');

var faq3 = new Holder('faq3ID', 'faq3TabImage');

var faq4 = new Holder('faq4ID', 'faq4TabImage');

var faq5 = new Holder('faq5ID', 'faq5TabImage');

var faq6 = new Holder('faq6ID', 'faq6TabImage');

var faq7 = new Holder('faq7ID', 'faq7TabImage');

var faq8 = new Holder('faq8ID', 'faq8TabImage');

var faq9 = new Holder('faq9ID', 'faq9TabImage');

var faq10 = new Holder('faq10ID', 'faq10TabImage');

var faq11 = new Holder('faq11ID', 'faq11TabImage');

var faq12 = new Holder('faq12ID', 'faq12TabImage');

var faq13 = new Holder('faq13ID', 'faq13TabImage');

var faq14 = new Holder('faq14ID', 'faq14TabImage');

var faq15 = new Holder('faq15ID', 'faq15TabImage');

var faq16 = new Holder('faq16ID', 'faq16TabImage');

var faq17 = new Holder('faq17ID', 'faq17TabImage');

var faq18 = new Holder('faq18ID', 'faq18TabImage');

var faq19 = new Holder('faq19ID', 'faq19TabImage');

var faq20 = new Holder('faq20ID', 'faq20TabImage');

var faq21 = new Holder('faq21ID', 'faq21TabImage');

var faq22 = new Holder('faq22ID', 'faq22TabImage');

var faq23 = new Holder('faq23ID', 'faq23TabImage');

var faq24 = new Holder('faq24ID', 'faq24TabImage');

var faq25 = new Holder('faq25ID', 'faq25TabImage');

var faq26 = new Holder('faq26ID', 'faq26TabImage');



groupTabs(new Array(faq1,faq2,faq3,faq4,faq5,faq6,faq7,faq8,faq9,faq10,faq11,faq12,faq13,faq14,faq15,faq16,faq17,faq18,faq19,faq20,faq21,faq22,faq23,faq24,faq25,faq26));





var como1 = new Holder('como1ID', 'como1TabImage');

var como2 = new Holder('como2ID', 'como2TabImage');

var como3 = new Holder('como3ID', 'como3TabImage');

var como4 = new Holder('como4ID', 'como4TabImage');

var como5 = new Holder('como5ID', 'como5TabImage');

var como6 = new Holder('como6ID', 'como6TabImage');

var como7 = new Holder('como7ID', 'como7TabImage');

var como8 = new Holder('como8ID', 'como8TabImage');

var como9 = new Holder('como9ID', 'como9TabImage');

var como10 = new Holder('como10ID', 'como10TabImage');

var como11 = new Holder('como11ID', 'como11TabImage');

var como12 = new Holder('como12ID', 'como12TabImage');

var como13 = new Holder('como13ID', 'como13TabImage');

var como14 = new Holder('como14ID', 'como14TabImage');

var como15 = new Holder('como15ID', 'como15TabImage');

var como16 = new Holder('como16ID', 'como16TabImage');

var como17 = new Holder('como17ID', 'como17TabImage');

var como18 = new Holder('como18ID', 'como18TabImage');

var como19 = new Holder('como19ID', 'como19TabImage');

var como20 = new Holder('como20ID', 'como20TabImage');



groupTabs(new Array(como1,como2,como3,como4,como5,como6,como7,como8,como9,como10,como11,como12,como13,como14,como15,como16,como17,como18,como19,como20));





/* js to check flash version (for video page) */

	function MM_CheckFlashVersion(reqVerStr,msg){

	  with(navigator){

		var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);

		var isWin = (appVersion.toLowerCase().indexOf("win") != -1);

		if (!isIE || !isWin){  

		  var flashVer = -1;

		  if (plugins && plugins.length > 0){

			var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";

			desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;

			if (desc == "") flashVer = -1;

			else{

			  var descArr = desc.split(" ");

			  var tempArrMajor = descArr[2].split(".");

			  var verMajor = tempArrMajor[0];

			  var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");

			  var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;

			  flashVer =  parseFloat(verMajor + "." + verMinor);

			}

		  }

		  // WebTV has Flash Player 4 or lower -- too low for video

		  else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

	

		  var verArr = reqVerStr.split(",");

		  var reqVer = parseFloat(verArr[0] + "." + verArr[2]);

	  

		  if (flashVer < reqVer){

			if (confirm(msg))

			  window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";

		  }

		}

	  } 

	}

	

/* function to trucate the Artist/Title if it's too long */

function truncateStr() {

	/*

	$('.artistInfo').each(function () {

		$(this).text($(this).text().substring(0,20)+"...");				

	});

	*/

}



function showPopWin(url){

	tb_show(null,url, null)

}
