function changeRub(url1,url2)
{
	if(url1!=undefined && url1!='' && url1!=null && document.getElementById('main')!=undefined)
		document.getElementById('main').setAttribute("src",url1,"false");
	if(url2!=undefined && url2!='' && url1!=null && document.getElementById('shows')!=undefined)
		document.getElementById('shows').setAttribute("src",url2,"false");
}
function changeTitre(img1,img2, topFrame)
{
	var doc = document;
	if(topFrame!=undefined && topFrame!=null && topFrame=='true')
		doc = top.window.parent.document;	
	
	if(img1!=undefined && img1!='' && img1!=null && doc.getElementById('img_titre')!=undefined)
		doc.getElementById('img_titre').setAttribute("src",img1,"false");
	if(img2!=undefined && img2!='' && img2!=null && doc.getElementById('img_titre2')!=undefined)
		doc.getElementById('img_titre2').setAttribute("src",img2,"false");
}
/*
permet de modifier l'url d'une frame via n'importe qu'elle autre autre frame

num = num de la frame prend 3 valeur
	0 = la page en général
	1 = la frame des news 
	2 = la frame des shows

url = adresse de la page à charger

*/
function changeFrame(num,url)
{
	var listFrame = top.window.parent.frames;
	if(listFrame==undefined || listFrame==null)
	{
		alert("Can't read object [frames]");
		return false;
	}
	if(num==0)
		top.window.document.location.href=url;
	else if(num > 0 && num <= listFrame.length)
	{
		f = listFrame[num - 1];
		f.location.href = url;
	}		
	else
	{
		alert("Can't find frame["+num+"]");
		return false;	
	}
	return true;
}

/*
format1 = format de départ
format2 = format à afficher

les format sont donnés sous les symboles
DD
MM
YYYY
*/
function convertDate(ch,format1,format2)
{
	var val = '';
	if(ch==undefined || ch==null || ch=='')
		return;
	if(format1==undefined | format1==null || format1=='')
		return;
	if(format2==undefined | format2==null || format2=='')
		return;
	val = ch.value;
	if(val=='' || val==null || val.length!=format1.length)
		return;
		
	var f1 = format1.toUpperCase();
	var f2 = format2.toUpperCase();
		
	var result = f2;
	var posD = f1.indexOf("DD");
	var posM = f1.indexOf("MM");
	var posY = f1.indexOf("YYYY");
	
	if(posD==-1 || posM==-1 || posY==-1)
		return;
	var day = val.substring(posD,posD+2);
	var month = val.substring(posM,posM+2);
	var year = val.substring(posY,posY+4);
	
	result = result.replace("DD",day);
	result = result.replace("MM",month);
	result = result.replace("YYYY",year);	
	ch.value = result;
}

function getValue(ch)
{
	var result = '';
	if(ch==null || ch==undefined)
		return;
	if(ch.type=='text' || ch.type=='hidden' || ch.type=='textarea' ||ch.type=='file' ||ch.type=='password')
		result = ch.value;
	else if(ch.type=='checkbox' && ch.checked==true)
		result = ch.value;
	else if(ch.type=='radio')
	{
		for(j=0; j<ch.length; j++)
		{
			if(ch[j].checked==true)
			{
				result = ch[j].value;	
				break;
			}
				
		}
	}
	else if(ch.type=='select-one' && ch.options.length > 0)
		result = ch.options[ch.selectedIndex].value;
	else if(ch.type=='select-multiple' && ch.options.length > 0)
	{
		var tmp = new Array();
		for(i=0; i<ch.options.length; i++)
		{
			if(ch.options[i].selected==true)
				tmp[tmp.length] = ch.options[i].value;			
		}
		if(tmp.length > 0)
			result = tmp;
	}
	return result;
}

function setValue(ch,val)
{
	var result = '';
	if(ch==null || ch==undefined)
		return;
	if(ch.type=='text' || ch.type=='hidden' || ch.type=='textarea' ||ch.type=='file' ||ch.type=='password')
		ch.value = val;
	else if(ch.type=='checkbox' || ch.type=='radio')
	{		
		for(j=0; j<ch.length; j++)
		{
			if(ch[j].value==val)
			{
				ch[j].checked = "true";	
				break;
			}
				
		}
	}
	else if((ch.type=='select-one' || ch.type=='select-multiple') && ch.options.length > 0)
	{
		for(j=0; j<ch.length; j++)
		{
			if(ch[j].value==val)
			{
				ch[j].selected = "true";	
				break;
			}
				
		}
	}
}

function validateDate(ch)
{
	/*
	DD = day
	MM = month
	YYYY = year
	HH = hour
	MN = minute
	SS = second
	MLS = milli
	*/
	
	if(ch==null || ch==undefined)
		return;
	if(ch.getAttribute('mask','false')==null || ch.getAttribute('mask','false')==undefined)
		return;
	if(getValue(ch)==null || getValue(ch)=='')
		return true;
	var mask = ch.getAttribute('mask','false').toUpperCase();
	var val = getValue(ch);
		
	if(mask.length!=val.length)
		return false;
	
	var day = -1;
	var month = -1;
	var year = -1;
	var hour = -1;
	var minute = -1;
	var second = -1;
	var milli = -1;
	
	var posDay = mask.indexOf('DD');
	var posMonth = mask.indexOf('MM');
	var posYear = mask.indexOf('YYYY');
	var posHour = mask.indexOf('HH');
	var posMinute = mask.indexOf('MN');
	var posSecond = mask.indexOf('SS');
	var posMilli = mask.indexOf('MLS');
	
	if(posYear > -1)
		year = new Number(val.substring(posYear,posYear+4));
	if(posMonth > -1)
		month = new Number(val.substring(posMonth,posMonth+2)) - 1;
	if(posDay > -1)
		day = new Number(val.substring(posDay,posDay+2));
	if(posHour > -1)
		hour = new Number(val.substring(posHour,posHour+2));
	if(posMinute > -1)
		minute = new Number(val.substring(posMinute,posMinute+2));
	if(posSecond > -1)
		second = new Number(val.substring(posSecond,posSecond+2));
	if(posMilli > -1)
		milli = new Number(val.substring(posMilli,posMilli+2));
		
	if(hour==24)
		hour = 0;
	
	var test = new Date();
	if(year > -1)
		test.setFullYear(year);
	if(month > -1)
		test.setMonth(month);
	if(day > -1)
		test.setDate(day);
	if(hour > -1)
		test.setHours(hour);
	if(minute > -1)
		test.setMinutes(minute);
	if(second > -1)
		test.setSeconds(second);
	if(milli > -1)
		test.setMilliseconds(milli);
	
	if((day > -1 && day!=test.getDate()) || isNaN(day)==true)
	{
		
		return false;
	}
	else if((month > -1 && month!=test.getMonth()) || isNaN(month)==true)
	{	
		
		return false;}
	else if((year > -1 && year!=test.getFullYear()) || isNaN(year)==true)
	{	
		
		return false;}
	else if((hour > -1 && hour!=test.getHours()) || isNaN(hour)==true)
	{	
		
		return false;}
	else if((minute > -1 && minute!=test.getMinutes()) || isNaN(minute)==true)
	{	
		
		return false;}
	else if((second > -1 && second!=test.getSeconds()) || isNaN(second)==true)
	{	
		
		return false;}
	else if((milli > -1 && milli!=test.getMilliseconds()) || isNaN(milli)==true)
	{	
		
		return false;
	}
			
	return true;
}

function openpopupnews(c){
var popurl="http://www.str8away.com/news/"+c;
winpops=window.open(popurl,"","toolbar=no, status=no, scrollbars=yes, resizable=no, width=430, height=600")
}

function openpopupdiary(c){
var popurl="http://www.str8away.com/diary/"+c;
winpops=window.open(popurl,"","toolbar=no, status=no, scrollbars=yes, resizable=no, width=430, height=600")
}

//-------------- Rlz		
		function show_rlz(object, link) {
		  if (document.getElementById) {
		    document.getElementById(object).style.display = 'inline';
		    document.getElementById(object).style.visibility = 'visible';
		    document.getElementById(link).innerHTML = '<IMG SRC=\"/images/minus.gif\"/>';
		  }
		  else if (document.layers && document.layers[object]) {
		    document.layers[object].display = 'inline';
		    document.layers[object].visibility = 'visible';
		    document.layers[link].value = '<IMG SRC=\"/images/minus.gif\"/>';
		  }
		  else if (document.all) {
		    document.all[object].style.display = 'inline';
		    document.all[object].style.visibility = 'visible';
		    document.all[link].innerHTML = '<IMG SRC=\"/images/minus.gif\"/>';
		  }
		}
		
		function hide_rlz(object, link) {
		  if (document.getElementById) {
		    document.getElementById(object).style.visibility = 'hidden';
		    document.getElementById(object).style.display = 'none';
		    document.getElementById(link).innerHTML = '<IMG SRC=\"/images/plus.gif\"/>';
		  }
		  else if (document.layers && document.layers[object]) {
		    document.layers[object].visibility = 'hidden';
		    document.layers[object].display = 'none';
		    document.layers[link].value = '<IMG SRC=\"/images/plus.gif\"/>';
		  }
		  else if (document.all) {
		    document.all[object].style.visibility = 'hidden';
		    document.all[object].style.display = 'none';
		    document.all[link].innerHTML = '<IMG SRC=\"/images/plus.gif\"/>';
		  }
		}
		function toggle_rlz(object, link) {
			if (document.getElementById) {
				if (document.getElementById(object).style.display != 'inline')
					show_rlz(object, link);
				else
					hide_rlz(object, link);
			}	
			else if (document.layers && document.layers[object]) {
				if (document.layers[object].display != 'inline')
					show_rlz(object, link);
				else
					hide_rlz(object, link);
			}
			else if (document.all) {
				if (document.all[object].style.display != 'inline')
					show_rlz(object, link);
				else
					hide_rlz(object, link);
			}
		}
		
// Preload images

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}