function stopError(){ return true; } //window.onerror=stopError;
//---------ERRORS & SNIFFING-----------------------------------------------
// browser SNIFF 
var browser,platform,firefoxversionerror,otherbrowsererror,iemacerror,tempsafarierror = false;
function browserSniff(){
	if( !document.getElementById ){ 
		alert("Your browser does not support the DHTML standard \"getElementById()\"\n please return to cumbancha with an updated browser.");
		document.location.href = "http://www.mozilla.com/";
	}//-------------------------------------------
	//alert( navigator.userAgent);
	if( navigator.userAgent.indexOf("MSIE") != -1 ){ browser = "ie"; }
	else if( navigator.userAgent.indexOf("Firefox") != -1 ){ browser = "firefox"; }
	else if( navigator.userAgent.indexOf("Safari") != -1 ){ browser = "safari"; }
	else if( navigator.userAgent.indexOf("Opera") != -1 ){ browser = "opera"; }
	else if( navigator.userAgent.indexOf("Netscape") != -1 ){ browser = "netscape"; }else{ browser = "other"; }
	if( navigator.platform.indexOf("Win") != -1 ){ platform = "windows"; }
	else if( navigator.platform.indexOf("Mac") != -1 ){ platform = "mac"; }else{ platform = "other"; }
	var version = navigator.userAgent; //analyse UserAgent string to find browser version.
	if(  browser == "safari" ||  browser == "firefox" ){ 
		version = version.split("/"); version = version[3]; 
		version = version.split("."); version = version[0];
		if( typeof version != "number" ){ version = false; }
	}else{ version = false; }//------------- compatibilty -------------------------------
	if( browser == "firefox" ){ if( version ){ firefoxversionerror = ( version < 2 )? true : false; } }
	else if( browser == "ie" && platform == "mac" ){ iemacerror = true; }
	else if( browser == "safari" && platform == "mac" && version !== false ){ if( version < 3 ){ alert("www.cumbancha.com: Versions of Safari for MAC below 3.0 may not function appropriately with flash player 9.0. Cumbancha advises that you please update your browser."); }
	}else if( browser == "netscape" && platform != "pc"  ){ alert("www.cumbancha.com: Please run Netscape in \"Windows display mode\", or use another browser."); } 
	//..........................................................................................
	if( firefoxversionerror ){ document.location.href = "webmaster/error_pages/browser_error.php?firefoxversionerror=true"; }
	if( iemacerror ){ document.location.href = "webmaster/error_pages/browser_error.php?iemacerror=true"; }
	//if( tempsafarierror ){ document.location.href = "webmaster/error_pages/browser_error.php?tempsafarierror=true"; }
	//if( !nobrowsererror && otherbrowsererror ){ document.location.href = "webmaster/error_pages/browser_error.php?otherbrowsererror=true"; }
}	browserSniff();
//------------------------------------------------------------- IE "out of memory line 56" fix 
function nullFlashLoopFunction(){  __flash_savedUnloadHandler = null; }
if( browser == "ie" ){  __flash_savedUnloadHandler = null;  window.onbeforeunload = nullFlashLoopFunction; }
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
///////////            FLASH                                                //////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------
function getEmbedTags( moviename,addr,w,h ){
	var wmodex  = ( browser == "firefox" && moviename.indexOf("submenu")!==-1 )? "window" : "transparent";
	var movie_code = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
	+'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '
	+'width="'+w+'" height="'+h+'" id="'+moviename+'">'
	+'<param name="allowScriptAccess" value="sameDomain" />'
	+'<param name="movie" value="'+addr+'?moviename='+moviename+'&browser='+browser+'" />'
	+'<param name="quality" value="high" />'
	+'<param name="scale" value="noscale" />'
	+'<param name="wmode" value="'+wmodex+'" />'
	+'<param name="bgcolor" value="#000000" />'
	+'<param name="align" value="middle" />'
	+'<embed src="'+addr+'?moviename='+moviename+'&browser='+browser+'" width="'+w+'" '
	+ 'height="'+h+'" name="'+moviename+'" allowScriptAccess="sameDomain" '
	+'quality="high" scale="noscale" wmode="'+wmodex+'" type="application/x-shockwave-flash" bgcolor="#000000" '
	+'pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle"></embed>'
	+'</object>'; return movie_code;
}//
//var topmenucode,bottommenucode,submenucode;
function loadFlashMovies(){ // get code and load baby! 
	var topmenucode = getEmbedTags("mainmenu_top","_all_pages_/head_and_menus/mainmenu.swf","650","19");
	var submenucode = getEmbedTags("submenux","_all_pages_/head_and_menus/submenu.swf","840","490");
	DOM_populateDIV("submenu1div",submenucode);
	DOM_populateDIV("mainmenudiv_top",topmenucode);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
///////////            INITIATION CODE                                               ////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
function jsOnloadCode(){ // this function makes sure that flash begins the loading process : CRITICAL!!! 
	var flashgocode = getEmbedTags( "flashgo","__phpinc/flashgo.swf","20","20" );
	DOM_populateDIV("flashgodiv",flashgocode); //actual DIV is in "head_menu.php"
} window.onload = jsOnloadCode;
//
function flashStartWebsite(){ //alert('flash says GO!'); 
	if( menusON ){ setTimeout( "loadFlashMovies();",500); } // load if mainMenu is true 
	//flashVariablesCheckedinList = new Array; // reset this variable when reloading, WHY? 
	if( onloadSection != "false" ){ //alert(onloadPagex);
		init_Loaded = false; musicStatePlaying = false;
		onloadPagex = onloadPagex? onloadPagex : "home";
		loadPage( onloadSection,onloadPagex );
	}
}//--------------------------------------------- flashMoviesCheck_in 
var flashMovieCheckedinList = new Array;
function flashMovieCheck_in( themovieID ){ //alert("checked in: '"+themovieID+"'");
	// record that this movie has checked in !!! 
	flashMovieCheckedinList[themovieID] = true; 
	// Tell website when to load
	if( themovieID == "flashGo" ){ flashStartWebsite(); /*alert("flashGo called");*/ return; } // check for init code / start website on flashGo check_in 
	// IF the variables for this movie are available, send them. 
	if( typeof(flashVariablesCheckedinList[themovieID]) == "object" ){ 
		callToFlash( themovieID, "receiveVars", flashVariablesCheckedinList[themovieID], onloadSection );// alert("vars sending to flash:: src="+onloadSection+" | moiveID="+themovieID+" | thevars= "+ flashVariablesCheckedinList[themovieID].length); //flash func must be named:  receiveVars 
		flashMovieCheckedinList[themovieID] = "vars_are_loaded";// record that the vars have been sent...
	}else{ return; }
}//--------------------------------------------- flashVariablesCheck_in 
var flashVariablesCheckedinList = new Array;
function flashVariablesCheck_in( thevars, themovieID, src_loadnow ){ //alert("these vars are checking in: "+themovieID);
	flashVariablesCheckedinList[themovieID] = thevars; // record that the vars for this movieID are loaded 
	// IF the flash movie has checked in, then send the vars to it -- 
	if( flashMovieCheckedinList[themovieID] ){
		if( flashMovieCheckedinList[themovieID] != "vars_are_loaded" ||  src_loadnow ){ //alert("these vars are checking in: "+themovieID);
			var thisSrc = ( src_loadnow != "loadnow" )? src_loadnow : onloadSection;
			callToFlash( themovieID, "receiveVars", thevars, thisSrc );  //alert("vars sending to flash:: src="+thisSrc+" | moiveID="+themovieID+" | thevars= "+thevars);
			flashMovieCheckedinList[themovieID] = "vars_are_loaded";
		}else{ return;//alert("vars for = "+themovieID+" already loaded."); // these vars are loaded.
		}
	}
}////////////////////////////////////////////////////////////////////////////////////////////////////
//---------FLASH COMMUNICATION-----------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////////
function getSWF( moviename ) { //return document.getElementById(moviename);
	if( navigator.appName.indexOf("Microsoft")!= -1 ) {
		return window[moviename]; }else{ return document[moviename];  }
}
//----------------------------CALL TO FLASH 
var mp3vars,subsubvars,intalbum,topMenu,bottomMenu,gallery,gallery_vip; var reReference = Array; var rerefnum = 0; // reref # = no zero 
function callToFlash( swffile, func, arg1, arg2, arg3 ){ //alert( swffile+" | func = "+func+" | arg1 = "+arg1+" | arg2 = "+arg2 ); 
	var swfref = getSWF( swffile ); //alert( typeof(swfref.anyFlashFunction) );
	if( !swfref || typeof(swfref.anyFlashFunction) != "function" ){  /*alert("NO SWF: \""+swffile+"\"");*/ return false; }
	else{ swfref.anyFlashFunction( func, arg1, arg2, arg3 ); return true; }
}
//-----------------------------FLASH SUBMENU 
var submenuON = false; 
function initSubmenu( idx ){ // BUG! visibility=hidden in IE: deactivates the submenu flash movie... so i had to resize its height ... 
	//DOM_setHeight( 'submenucontainerdiv',1 );
	if( idx == submenuON || idx == "OFF" ){  //alert("submenuCalled = "+idx+", mainmenu switchoff");
		if( browser == "ie" ){ DOM_setHeight( 'submenucontainerdiv',1 ); } // size down for IE.
		else{ DOM_toggleVisibility( 'submenucontainerdiv', 'hidden' ); }
		submenuON = false; 
		return;
	} //------------------------------------
	if( browser == "ie" ){ DOM_setHeight( 'submenucontainerdiv',500 ); } // size UP for IE.
	else{ DOM_toggleVisibility( 'submenucontainerdiv', 'visible' ); }
	callToFlash( 'submenux', 'callSubmenu', idx);
	submenuON = idx;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
///////////            XML LOAD NEW PAGE                                /////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
var XMLdivname,XMLurl; var req = false;
function retrieveData( url, divname ) { 
	callToFlash( 'loading_sequence', 'loadingSequence', 'start' ); // loading feedback 
	//------------------------------------------------determine state of current request if any 
	if( req && req.readyState < 4 ){  req.abort(); } //alert(req.readyState);
	//-------------------------------------------- 
	XMLdivname = divname; XMLurl = url;
	if( window.XMLHttpRequest ) { //alert(XMLurl+" -into- "+XMLdivname);// MOST browsers (&ie7) 
		req = new XMLHttpRequest();
		req.onreadystatechange = processLoad;
		try{ req.open( "GET", url, true ); }
		catch( e ){ alert( "window.XMLHttpRequest = "+e ); }
		if( req ){ req.send( null ); }else{ req.send( null ); }
	}else if( window.ActiveXObject ) { // IE 
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if( req ) {
			req.onreadystatechange = processLoad;
			req.open( "GET", url, true );
			req.send( null );
		}// if XML will not work, redirect to this page... 
	}else{ document.location.href = "webmaster/error_pages/browser_error.php?xmlerror=true"; }
}/////////////////////////////////////////////
function processLoad() { 
	if( req.readyState != 4 ){ // 1= loading 
		return;
	}//--------------------------------- 4 = Complete 
	else if (req.readyState == 4) { 
		if (req.status == 200) { //--------------------------------------------OK response 
			callToFlash( 'loading_sequence', 'loadingSequence', 'stop' );  //alert(XMLurl);// loading feedback 
			if( XMLdivname == "DOM_NewJavascript" ){ DOM_NewJavascript( req.responseText ); }
			else{ DOM_populateDIV( XMLdivname, req.responseText ); }
		}//---------------------------------------------------------------404 ERROR
		else if (req.status == 404) { // 404 response 
			alert( "404 error: document not found ("+XMLurl+")" );
		} //--------------------------------------------------------------UNKNOWN ERROR
		else { 
			//alert("Failed: "+XMLurl+" -into- "+XMLdivname);
			//alert("Network Problem: \"" + req.statusText+".\" Please refresh this site."); 
		}//-------------------------------------------------------------- check for other DIVs to load 
		loadQue( true ); 
	}
}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------MAIN & SUBSUB menu catch function
function clickFromFlashMenu( jstoeval ){ //alert(typeof req);
	//if( window.XMLHttpRequest ) { req.abort(); req = null; }// cancel load 
	//processQue = null;
	eval( jstoeval ); // process load 
}//-----------------------------------------------------------------LOAD PAGE 
var init_Loaded,playerstat,pagexLoaded = false; var artwork = 'default'; var homepageNewsBlurbs = null;
function loadPage( src, pagex, argx, remotesrc ){ //alert("loadPage(SRC) = "+src+" | Q# = "+(Q+1)+" |specific page(pagex) = "+pagex+" | init_Loaded = "+init_Loaded);// source from ROOT  //
	//-----------------------------------
	if( src.indexOf(",")!=-1 ){ //--  if address from flash (",") = main menu click (workaround because you can only send 1 var from flash) 
		var thissrc = src.split(","); thissrc =  popvars[ thissrc[0] ][ thissrc[1] ]; 
		var src = thissrc['root'] +"/"+ thissrc['src']; // root = albums | src = idan_raichel_project.
	}//
	// check for extra argument (history) and remotesrc (used for passing the address of individual news items) 
	var argx = (argx)? argx : 0; var remotesrc = (remotesrc)? remotesrc : 0;
	//--  which page? // pagex is the subsub page 
	var nopagex = pagex? false : true; //alert(pagex);
	//--  new superfoot (if: do not run general content) 
	if( pagex == "superfoot" ){ 
		loadQue( false, "retrieveData( '"+src+"/superfoot/content.php?src="+src+"&lang="+language+"&lang_a="+lang_a+"', 'custom_superfoot_right' );"); return; //convoluted shit.
	}//-- new music state //called from "processMusicState" 
	if( pagex == "newmusicstate" ){ //alert( "MUSIC PROCESS REQUEST = "+src ); 
		var titlelinksrc = ( argx != 'loadmusicnow' )? argx : false; 
		loadQue( false, "retrieveData( '__phpinc/init_newmusicstate.php?src="+src+"&lang="+language+"', 'DOM_NewJavascript' );" ); 
		musicStatePlaying = src;  if( argx == 'loadmusicnow' ){ loadQue( true ); return;  }else{  return; }
	}//-- new init pages (includes header state) 
	if( src.indexOf("albums")!=-1 ){  initpage = "init_album_page"; }else{  initpage = "init_core_page"; }
	//if( src.indexOf("core_pages")!=-1 ){  initpage = "init_core_page"; } else if( src.indexOf("albums")!=-1 ){  initpage = "init_album_page"; }
	// reload init_core_page everytime. //
	if( src != init_Loaded || src == "core_pages" ){ init_Loaded = src;  //alert('loading='+initpage);//  subsubmenu (only load if there is a submenu folder, and subsub is not already loaded) 
		loadQue( false, "retrieveData( '__phpinc/"+initpage+".php?src="+src+"&pagex="+pagex+"&lang="+language+"&playerstat=false&lang_a="+lang_a+"', 'DOM_NewJavascript' );" ); // DOM_NewJavascript does not parse HTML 
	}// setup interior query string
	var query1 = ( form_POST_to_GET != false )? "&form_POST_to_GET="+form_POST_to_GET : "";
	var query2 = ( originalCorePage != false )? "&originalCorePage="+originalCorePage : "";
	var query3 = ( original_pgx != false )? "&original_pgx="+original_pgx : "";
	//remote source
	if( decoded_news_uri != false && !remotesrc ){ remotesrc = decoded_news_uri; }
	//--- direct-link -- populate direct-link div 
	var linksrc = false;
	if( !remotesrc ){ remotesrc = 0; }
	else if( remotesrc.indexOf("news/")!=-1 ){ var templink = remotesrc.split("news/"); var temp2link = templink[1].split("/");
		var linksrc = "www.cumbancha.com/inthenews/"+temp2link.join("-")+"/";
	}else{ linksrc = ( src == "core_pages" )? "www.cumbancha.com/"+pagex : "www.cumbancha.com/"+src+"/"+pagex; }
	if( pagex!="home" && linksrc ){ DOM_populateDIV( "direct_link","<strong style='color:#990000;font-size:9px;'>DIRECT LINK:</strong> "+linksrc ); }
	//-----------------------------
	//-- new page  //-- content (reloads subcontent shell for every page in section) 
	loadQue( false, "retrieveData( '"+src+"/_subcontent_shell.php?src="+src+"&lang="+language+"&pagex="+pagex+"&lang_a="+lang_a+"&remotesrc="+remotesrc + query1 + query2 + query3 +"', 'content' );"  );
	pagexLoaded = pagex;  
	//----------------------------
	loadQue( true ); // start it off 
	//----------------------------
	// -- HISTORY ||| init backbutton (don't record change if there's an auto loading page) 
	if( argx != "history" ){ var newhistoryentry = "loadPage('"+src+"','"+pagex+"','history','"+remotesrc+"');"
		if( newhistoryentry != theHistoryxx[bbcount] ){ // do not duplicate history entries 
			if( !onloadPagex ){ callToFlash( 'backbuttonx', 'startHistoryButton', true ); } onloadPagex = false;
			theHistoryxx[++bbcount] = newhistoryentry; // record history and display button 
		}//alert("recorded history ["+bbcount+"]");
	}
	//------------//-- google analytics // "remote source" = it's a news item
	if( pageTracker ){ var ga_msg = ( remotesrc!=0 )? "cumbancha.com/"+src+"/"+remotesrc : "cumbancha.com/"+src+"/"+pagex;   pageTracker._trackPageview( ga_msg );  }// alert(ga_msg);//
}
var processQue = Array; var Q = -1; var L = -1;
function loadQue( loadnext, funccall ){ 
	if( loadnext===false ){ processQue[++Q] = funccall;  /*alert("adding to processQue = "+funccall);*/ return; }
	if( L == Q ){ L= -1; Q = -1; processQue = Array;  return;  // that was the last one... reset //alert( "Q:"+Q+"L:"+L);
	}eval( processQue[++L] );
}
//---------HISTORY-----------------------------------------------
var theHistoryxx = Array(0); var bbcount = -1;
function historyCall(){ 
	if( bbcount > -1 ){  --bbcount; eval( theHistoryxx[bbcount] ); } 
	if( bbcount === 0 ){ callToFlash( 'backbuttonx', 'startHistoryButton', false ); } // reset 
}//
/////////////////////////////////////////////////////////////////////////////////////////////////////
///////////            MUSIC STATE INIT                                       /////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
var musicStatePlaying = false; var noMusicForThisPage = false;
function processMusicState( src ){ argx = false; //alert('music initiation: '+src);
	if( !musicON ){ return; }// check if music is enabled 
	if( src.indexOf('&fromflash')!=-1 ){ src = src.split('&'); src = src[0]; argx = "loadmusicnow"; }
	// do not reload playset if not loading another album or artist page 
	if( src == musicStatePlaying || noMusicForThisPage === true ){ return; }
	// if random and no music has ever played... 
	if( noMusicForThisPage == 'random' ){ if( !musicStatePlaying ){ musicStatePlaying = 'random'; src='random'; }else{ return; } } // if randomized, leave playing... 
	// gone through, play new music! 
	loadPage( src, 'newmusicstate', argx );
}//
/////////////////////////////////////////////////////////////////////////////////////////////////////
///////////            PROCESS RAW FORM DATA                                 /////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
function postAllFormData( formxname, processingurl ){  //// retrieveData( '__phpinc/processpost_newsletter.php', 'newsletter_result_content', 'userid=00001&firstname=tim&lastname=omalley&emailaddress=tim@yuquilla.com' ); 
	var formx = document.getElementById(formxname); var fdata = "?";
	for( var f=0; f<formx.length; ++f ){
		if( formx[f].value.length==0 || formx[f].value == null ){ var valuex = "empty"; }else{ var valuex = formx[f].value; }
		fdata += formx[f].name+"="+valuex+"&"; //alert( fdata );
	}retrieveData( processingurl+fdata, 'DOM_NewJavascript' ); 
}//
/////////////////////////////////////////////////////////////////////////////////////////////////////
///////////            SIMPLE CSS DOM                                //////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
//-------- UTILITY -----------------------------------------------
function JSAlert( message ){ alert(message); }
//
function DOM_NewJavascript( scriptx ){ //alert("loadnumber this JS = "+ scriptx);
	eval( scriptx );
}
function DOM_populateDIV( id,code ){ //alert( "populating this div = "+id );
	if( document.getElementById(id) ){
		document.getElementById(id).innerHTML= code;
		if( id == "content" ){ document.getElementById('scrollingcontent').scrollTop = 0; } // scrolling fix 
	}else{ alert( "FUNC:DOM_populateDIV('"+id+"'): '"+id+"' was not found in document.getElementById" ); }
}
function DOM_toggleVisibility( id, action ){ //alert(document.getElementById(id));
	document.getElementById(id).style.visibility = action;
}
function DOM_setHeight( id,hgt ){
	document.getElementById(id).style.height = hgt;
}
function DOM_setPosition( id, x, y ){ //alert(x);
	document.getElementById(id).style.left = x;
	document.getElementById(id).style.top = y;
}
function DOM_getLeftPosition( id ){ var pos = document.getElementById(id).style.left; return parseInt(pos); }
//
function DOM_moveLeftPosition( id,tohere ){ //alert(tohere);
	document.getElementById(id).style.left = tohere; 
	return  parseInt(document.getElementById(id).style.left);
 }
 function DOM_loadBGimage( id,src ){ //alert("changing bg image | src = "+src+" DIV = "+id);
	document.getElementById(id).style.backgroundImage = 'url('+src+')';
 }
 function scrollUp(){
	document.getElementById('scrollingcontent').scrollTop = 0;
}
//---------ADMIN WINDOW-----------------------------------------------
function editCopy( addr ){
	if( !addr ){ alert("There has been an error: no file-to-edit specified!"); }
	window.open( "webmaster/wwwedit.php?file="+addr );
	//window.open( ("webmaster/wwwedit.php?file="+addr), ("editwindow"+addr), 'screenX=50, screenY=20, left=50, top=20, width=800, height=600, resizable=yes, location=no, status=yes, menubar=yes, toolbar=no, directories=no, copyhistory=no' );
}
//---------GENERIC LAUNCH WINDOW-----------------------------------------------
function launch( urlx,inst ){ window.open( urlx ); 
	if( inst == "musicoff" ){ callToFlash( 'mp3playerx', 'pausePlayer', true ); } 
	if( inst == 'sales' ){ /* record the location selected*/ }
}