function OpenDirectory(id){
	p = document.getElementById("directory"+id);
	if(p){
		p.style.display = p.style.display=='block'?'none':'block';
	}
}
function SizeCalendarFrame(h){
	theCal = document.getElementById("calendarFrameDiv");
	if(theCal){
		theCal.style.height = ((h*1)+20)+"px";
	}
}

function OpenCoupon(id){
	win=open("cms/coupon_view.php?id="+id,"coupon"+id,"width=5,height=5,resizable=no,toolbars=no,menubars=no,scrollbars=yes");win.focus();return false;
}

function SiteMasthead(theSite){
	if(!theSite){ theSite="qmix"; }

	document.write("<style media='all' type='text/css'>#header{ background: transparent url(/sites/1.1/tpls/images/headerbg-"+theSite+".jpg) no-repeat bottom; }</style>");
}

function TestCookies(title,logo){

	site="";
	if((location.href.toLowerCase()).indexOf("qmix")>-1){ site="qmix"; }
	if((location.href.toLowerCase()).indexOf("korn")>-1){ site="korn"; }
	if(site==""){ site="qmix"; } 

	if((!title || title=="") || (!logo || logo=="")){ 
		document.location.href="_site.php?s="+site;
	}
}

function ListenLiveLink(live_link,path){
	document.write('<a href="'+live_link+'" title="Listen Live Now" target="_blank"><img src="'+path+'images/listen_now-blank.gif" alt="Listen Live Now" /></a>');
}

function SiteBrand(param,val,path){
	switch (param){
		case "site_title" : 
			//document.write('<title>'+site_title+'</title>');
			break;
		case "logo" : 
			document.write('<img src="'+path+'images/'+logo+'" alt="'+site_title+'" id="logo" />');
			break;
	}
}

function SiteTagline(site_title){

	site = "";
	if((location.href.toLowerCase()).indexOf("qmix")>-1){ site="qmix"; }
	if((location.href.toLowerCase()).indexOf("korn")>-1){ site="korn"; }
	if(site==""){ site=Get_Cookie("site"); } 

	arr = site_title.split("-");

	if(arr[1]){
		document.write(arr[1]);
	}else{
		document.write(arr[0]);
	}
	
	if(site=="korn"){
		tl = document.getElementById("tagline");
		if(tl){
			tl.style.paddingLeft = "120px";
		}
	}
}




function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			cookie_value = cookie_value.replace(/\+/g," ");
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}	