//Stylesheet selector
// !! FIX PATHS !!
var browName = (navigator.appName);
if (browName=='Microsoft Internet Explorer') {
	document.write("<link rel='STYLESHEET' type='text/css' href='http://www.blinddater.se/css/blinddater_ie.css'>");
} else if (browName=='Netscape') { 
	document.write("<link rel='STYLESHEET' type='text/css' href='http://www.blinddater.se/css/blinddater_ns.css'>");
} else {
	document.write("<link rel='STYLESHEET' type='text/css' href='http://www.blinddater.se/css/blinddater_ie.css'>");
}
/*var browName = (navigator.appName);
if (browName=='Microsoft Internet Explorer') {
    document.write("<link rel='STYLESHEET' type='text/css' href='http://www.blinddater.se/css/blinddater_ie.css'>");
} else if (browName=='Netscape') {
    document.write("<link rel='STYLESHEET' type='text/css' href='http://www.blinddater.se/css/blinddater_ns.css'>");
} else {
    document.write("<link rel='STYLESHEET' type='text/css' href='http://www.blinddater.se/css/blinddater_ie.css'>");
}*/




function doAction(actionMethod, actionParams) {
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var movie = InternetExplorer ? top.statusframe.Statusbar : top.statusframe.document.Statusbar;
    movie.SetVariable('_root.actionMethod', actionMethod);
    movie.SetVariable('_root.actionParams', actionParams);
    movie.TGotoLabel('/', 'doAction');
}






function MM_openBrWindow(theURL,winName,features) { 
	window.open(theURL,winName,features).focus();
}

function win_open(url, win_name, width, height, feat ) {

	if ( feat != "" && feat != null )
		features = feat + ",width=" + width + ",height=" + height;
	else
		features = "toolbar=no,location=no,directories=no,status=no,menubar=no,alwaysRaised=yes,resizable=no,scrollbars=yes,width=" + width + ",height=" + height;
	eval("var " +win_name+ "= window.open('" +url+ "','" +win_name+ "','" +features+ "');");
	/*if(document.all){
		eval(win_name + ".moveTo((screen.width-" +width+ ")/2,(screen.height-" +height+ ")/2);");
	}*/
	eval(win_name +".focus()");	// Leif 2002-04-15
}

function win_open_profile(url, win_name, width, height, feat ) {
	
/*obs jonas 2004-0116  har kopierat för att få profile sidorna att funka */

	if ( feat != "" && feat != null )
		features = feat + ",width=" + width + ",height=" + height;
	else
		features = "toolbar=no,location=no,directories=no,status=no,menubar=no,alwaysRaised=yes,resizable=no,scrollbars=yes,width=" + width + ",height=" + height;
	eval("var " +win_name+ "= window.open('" +url+ "','" +win_name+ "','" +features+ "');");
	if(document.all){
		eval(win_name + ".moveTo((screen.width-" +width+ ")/2,(screen.height-" +height+ ")/2);");
	}
	eval(win_name +".focus()");	// Leif 2002-04-15
}
/*hit*/

	/*var mainWindowName  = "applet_frame";
	var root = self;

	while(root.opener && (root.opener.name != "center" || root.opener.name != "appletAction")){
		root = root.opener;
	}
	
	if(root.parent&&root.name!="center"){
		while(root.name!="center" && root.name != "appletAction"){
			if(root.parent){
				root = root.parent;	
			}
		}
	}
	if (root.name == "center")
	{               
                //root=root.parent.frames.statusframe.frames.applet_frame;              
                root=root.parent.frames.statusframe.frames[1];  
        }       
        else    
        {               
                //root=root.parent.applet_frame;                
                root=root.parent.frames[1];     
        }


	
	if ( feat != "" && feat != null )
		features = feat + ",width=" + width + ",height=" + height;
	else
		features = "toolbar=no,location=no,directories=no,status=no,menubar=no,alwaysRaised=yes,resizable=no,scrollbars=yes,width=" + width + ",height=" + height;
	eval("var " +win_name+ "= root.window.open('" +url+ "','" +win_name+ "','" +features+ "');");
	if(document.all){
		eval(win_name + ".moveTo((screen.width-" +width+ ")/2,(screen.height-" +height+ ")/2);");
	}
	eval(win_name +".focus()");	// Leif 2002-04-15
}*/

function geo_reload(select_obj, geo_name, script) {

	select_value = select_obj.options[select_obj.selectedIndex].value
	window.self.location= script + '?' + geo_name + "=" + select_value;

}

function vote() {
	
	//Get selected radio button and produce string->popupwindow.
	var radio_obj = document.poll.answer_id;
		
	for (var i = 0; i < radio_obj.length; i++) {
		if (radio_obj[i].checked) {
			var answer_id =  radio_obj[i].value;
		}
	}
	if(answer_id) {
		win_open('poll-blowup.jsp?do=vote&answer_id=' + answer_id,'poll_win','350','250');
	} else {
		alert('_BDLANG_V1_ID_SELECT-OPTION-1_');
	}
	
}
	
//Button controllers:
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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];}}
}

function MM_findObj(n, d) { //v3.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// leif -020124-

var Imgs = new Array();       // used for storing images.. imagine that. -Leif 
var menuTexts = new Array(); // used for storing confirm texts..
var altTexts = new Array(); // used for storing alt texts for images.. and yes this is dirty i know :P

function LH_preloadImages() {
	var d = document;
	if (d.images) {
		a = LH_preloadImages.arguments;
		for (i=0;i<a.length;i++) {
			Imgs[i] = new Image;
			Imgs[i].src = a[i];
		}
	}
}

function LH_swapImage(img) {
	var d = eval("document."+img);
	var s = d.src;
	var j = 1;
	if ( s.indexOf(img+j, -5) > 0)
		j=2;
	for (i=0;i<Imgs.length;i++) {
		is = Imgs[i].src;
		if ( is.indexOf(img+j, -5) > 0 )
			d.src = is;
	}
}

function confirmNswap(str) {
	var d = eval("document."+str);	
	var s = d.src;
	var text;
	if ( s.indexOf(str+1, -5) > 0 ) {
		text = menuTexts[str+1];
		atext = altTexts[str+2];
	}
	else {
		text = menuTexts[str+2];
		atext = altTexts[str+1];
	}

	if ( confirm(text) ) {
			d.alt = atext;
			LH_swapImage(str);
		return true;
	}	
	return false;
}
