//;
var loginVar='';
var lostPassVar='';
var curUrl="om/";
var loginUrl = '<input type=\"hidden\" name=\"curUrl\" value=\"http://www.studentertyckertill.se/om/\" />';

var loginShow=false;
var registrationShow=false;
var lostpassShow=false;
var changeShow=false;

var saveForLinkgageArr = new Array();
var scrolldelay;
var numOfPanelForms=0;

var loginBoxDiv='<form name="login" method="post" action="http://www.studentertyckertill.se/login">';
loginBoxDiv+='<input type=\"hidden\" name=\"curUrl\" value=\"http://www.studentertyckertill.se/om/\" />';
loginBoxDiv+='<input type=\"hidden\" name=\"failUrl\" value=\"http://www.studentertyckertill.se/om/\" />';
loginBoxDiv+='<h5>Inloggning</h5>';
loginBoxDiv+='<div class="login_subWrapper">';
loginBoxDiv+='E-post eller inloggningsnamn:<br /><input type="text" name="email" id="email" class="login_textField" />';
loginBoxDiv+='</div>';
loginBoxDiv+='<div class="login_subWrapper">';
loginBoxDiv+='Lösenord:<br /><input type="password" name="password" id="password" class="login_textField" />';
loginBoxDiv+='</div>';
loginBoxDiv+='<div class="login_subWrapper_small">';
loginBoxDiv+='<input type="submit" name="button" id="button" value="Logga in" class="login_button" />';
loginBoxDiv+='</div>';
loginBoxDiv+='<div id="login_subWrapper_small_second">';
loginBoxDiv+='<a href="#" onclick="showHideLostPassBox()">Glömt lösenordet?</a>';
loginBoxDiv+='</div>';
loginBoxDiv+='<div id="login_subWrapper_small_last">';
loginBoxDiv+='<a href="#" onclick="showHideRegistrationBox()">Registrera dig</a>';
loginBoxDiv+='</div>';
loginBoxDiv+='</form>';
loginBoxDiv+=loginVar;

var lostPassBoxDiv='<form name=\"lostPass\" method=\"post\" action=\"http://www.studentertyckertill.se/lost_password.php\">';
lostPassBoxDiv+='<h5>&Aring;terf&aring; ditt l&ouml;senord</h5>';
lostPassBoxDiv+='<input type=\"hidden\" name=\"curUrl\" value=\"http://www.studentertyckertill.se/om/\" />';
lostPassBoxDiv+='<input type=\"hidden\" name=\"failUrl\" value=\"http://www.studentertyckertill.se/om/\" />';
lostPassBoxDiv+='<div class="login_subWrapper">';
lostPassBoxDiv+='Din e-postadress:';
lostPassBoxDiv+='<br/>';
lostPassBoxDiv+='<input id="email" class="login_textField" type="text" name="email"/>';
lostPassBoxDiv+='</div>';
lostPassBoxDiv+='<div class="login_subWrapper">';
lostPassBoxDiv+='</div>';
lostPassBoxDiv+='<div class=\"login_subWrapper_small\">';
lostPassBoxDiv+='<input id="button" class="login_button" type="submit" value="Skicka" name="button"/>';
lostPassBoxDiv+='</div>';
lostPassBoxDiv+='<div id="login_subWrapper_double">';
lostPassBoxDiv+='<br />';
lostPassBoxDiv+='Skriv in e-postadressen du angav n&auml;r du blev medlem s&aring; skickas e-postmeddelande med ditt l&ouml;senord.';
lostPassBoxDiv+='</div>';
lostPassBoxDiv+='</form>';
lostPassBoxDiv+=lostPassVar;

var registrationDiv='';							 
registrationDiv+='	<form name="addUser" method="post" action="/addUser.php">';
registrationDiv+='<input type=\"hidden\" name=\"curUrl\" value=\"http://www.studentertyckertill.se/om/\" />';
registrationDiv+='<input type=\"hidden\" name=\"failUrl\" value=\"http://www.studentertyckertill.se/om/\" />';
registrationDiv+='    	 <h5>Bli medlem</h5>';
registrationDiv+='        <div id="member_subWrapper">';
registrationDiv+='            <span class="member_label">E-post:*</span><br/>';
registrationDiv+='            <input type="text" name="email" id="email" value="" class="member_textField" />';
registrationDiv+='            <br />';
registrationDiv+='            <span class="member_label">Användarnamn:*</span><br/>';
registrationDiv+='            <input type="text" name="user" id="user" value="" class="member_textField" />';
registrationDiv+='            <br />';
registrationDiv+='            <span class="member_label">Län:*</span><br/>';
registrationDiv+='            <br />';
registrationDiv+='           	<select name="location" id="location" class="member_textField" >';
registrationDiv+='                <option value="" selected="selected"></option>';
registrationDiv+='<option value="1">Blekinge</option>';registrationDiv+='<option value="2">Dalarna</option>';registrationDiv+='<option value="4">Gävleborg</option>';registrationDiv+='<option value="3">Gotland</option>';registrationDiv+='<option value="5">Halland</option>';registrationDiv+='<option value="6">Jämtland</option>';registrationDiv+='<option value="7">Jönköping</option>';registrationDiv+='<option value="8">Kalmar</option>';registrationDiv+='<option value="9">Kronoberg</option>';registrationDiv+='<option value="21">Norrbotten</option>';registrationDiv+='<option value="17">Örebro</option>';registrationDiv+='<option value="18">Östergötland</option>';registrationDiv+='<option value="10">Skåne</option>';registrationDiv+='<option value="11">Södermanland</option>';registrationDiv+='<option value="19">Stockholm</option>';registrationDiv+='<option value="20">Uppsala</option>';registrationDiv+='<option value="12">Värmland</option>';registrationDiv+='<option value="13">Västerbotten</option>';registrationDiv+='<option value="14">Västernorrland</option>';registrationDiv+='<option value="15">Västmanland</option>';registrationDiv+='<option value="16">Västra Götaland</option>';registrationDiv+='            </select>';
registrationDiv+='        </div>';
registrationDiv+='        <div id="member_subWrapper">';
registrationDiv+='            <span class="member_label">Lösenord:*</span><br/>';
registrationDiv+='            <input type="password" name="password" id="password" class="member_textField" />';
registrationDiv+='            <br />';
registrationDiv+='            <span class="member_label">Lösenord igen:*</span><br/>';
registrationDiv+='            <input type="password" name="password2" id="password2" class="member_textField" />';
registrationDiv+='            <br />';
registrationDiv+='            <span class="member_label">Födelseår:*</span><br/>';
registrationDiv+='            <br />';
registrationDiv+='            <select name="dob" id="dob" class="member_textField" >';
registrationDiv+='                <option value="" selected="selected"></option>'
registrationDiv+='                <option value="1994">1994</option>'
registrationDiv+='                <option value="1993">1993</option>'
registrationDiv+='                <option value="1992">1992</option>'
registrationDiv+='                <option value="1991">1991</option>'
registrationDiv+='                <option value="1990">1990</option>'
registrationDiv+='                <option value="1989">1989</option>'
registrationDiv+='                <option value="1988">1988</option>'
registrationDiv+='                <option value="1987">1987</option>'
registrationDiv+='                <option value="1986">1986</option>'
registrationDiv+='                <option value="1985">1985</option>'
registrationDiv+='                <option value="1984">1984</option>'
registrationDiv+='                <option value="1983">1983</option>'
registrationDiv+='                <option value="1982">1982</option>'
registrationDiv+='                <option value="1981">1981</option>'
registrationDiv+='                <option value="1980">1980</option>'
registrationDiv+='                <option value="1979">1979</option>'
registrationDiv+='                <option value="1978">1978</option>'
registrationDiv+='                <option value="1977">1977</option>'
registrationDiv+='                <option value="1976">1976</option>'
registrationDiv+='                <option value="1975">1975</option>'
registrationDiv+='                <option value="1974">1974</option>'
registrationDiv+='                <option value="1973">1973</option>'
registrationDiv+='                <option value="1972">1972</option>'
registrationDiv+='                <option value="1971">1971</option>'
registrationDiv+='                <option value="1970">1970</option>'
registrationDiv+='                <option value="1969">1969</option>'
registrationDiv+='                <option value="1968">1968</option>'
registrationDiv+='                <option value="1967">1967</option>'
registrationDiv+='                <option value="1966">1966</option>'
registrationDiv+='                <option value="1965">1965</option>'
registrationDiv+='                <option value="1964">1964</option>'
registrationDiv+='                <option value="1963">1963</option>'
registrationDiv+='                <option value="1962">1962</option>'
registrationDiv+='                <option value="1961">1961</option>'
registrationDiv+='                <option value="1960">1960</option>'
registrationDiv+='                <option value="1959">1959</option>'
registrationDiv+='                <option value="1958">1958</option>'
registrationDiv+='                <option value="1957">1957</option>'
registrationDiv+='                <option value="1956">1956</option>'
registrationDiv+='                <option value="1955">1955</option>'
registrationDiv+='                <option value="1954">1954</option>'
registrationDiv+='                <option value="1953">1953</option>'
registrationDiv+='                <option value="1952">1952</option>'
registrationDiv+='                <option value="1951">1951</option>'
registrationDiv+='                <option value="1950">1950</option>'
registrationDiv+='                <option value="1949">1949</option>'
registrationDiv+='                <option value="1948">1948</option>'
registrationDiv+='                <option value="1947">1947</option>'
registrationDiv+='                <option value="1946">1946</option>'
registrationDiv+='                <option value="1945">1945</option>'
registrationDiv+='                <option value="1944">1944</option>'
registrationDiv+='                <option value="1943">1943</option>'
registrationDiv+='                <option value="1942">1942</option>'
registrationDiv+='                <option value="1941">1941</option>'
registrationDiv+='                <option value="1940">1940</option>'
registrationDiv+='                <option value="1939">1939</option>'
registrationDiv+='                <option value="1938">1938</option>'
registrationDiv+='                <option value="1937">1937</option>'
registrationDiv+='                <option value="1936">1936</option>'
registrationDiv+='                <option value="1935">1935</option>'
registrationDiv+='                <option value="1934">1934</option>'
registrationDiv+='                <option value="1933">1933</option>'
registrationDiv+='                <option value="1932">1932</option>'
registrationDiv+='                <option value="1931">1931</option>'
registrationDiv+='                <option value="1930">1930</option>'
registrationDiv+='                <option value="1929">1929</option>'
registrationDiv+='                <option value="1928">1928</option>'
registrationDiv+='                <option value="1927">1927</option>'
registrationDiv+='                <option value="1926">1926</option>'
registrationDiv+='                <option value="1925">1925</option>'
registrationDiv+='                <option value="1924">1924</option>'
registrationDiv+='                <option value="1923">1923</option>'
registrationDiv+='                <option value="1922">1922</option>'
registrationDiv+='                <option value="1921">1921</option>'
registrationDiv+='                <option value="1920">1920</option>'
registrationDiv+='            </select>';
registrationDiv+='        </div>';
registrationDiv+='        <div id="member_subWrapper_last">';
registrationDiv+='            <span class="member_label">Kön:*</span><br/>';
registrationDiv+='            <br />';
registrationDiv+='            <label>';
registrationDiv+='            <input type="radio" name="sex" value="man" id="gender_0" />';
registrationDiv+='            Man</label>';
registrationDiv+='            <label>';
registrationDiv+='            <input type="radio" name="sex" value="woman" id="gender_1" />';
registrationDiv+='            Kvinna </label>';
registrationDiv+='            <br />';
registrationDiv+='            <br />';
registrationDiv+='            <label>';
registrationDiv+='            <input type="checkbox" name="terms" id="terms" /></lable>';
registrationDiv+='                *Jag har tagit del av och accepterar <a href="/terms.php">medlemsvillkoren</a> på StudenterTyckerTill.se<br />';
registrationDiv+='            <br />';
registrationDiv+='            <input type="submit" name="submit" id="submit" value="Registrera dig" class="member_button" />';
registrationDiv+='        </div>';
registrationDiv+='     </form>';





















function showHideLoginBox() {
	if(!loginShow) {
		if(registrationShow) {
			document.getElementById('regImgSelected').style['width'] = '0px';
			document.getElementById('regImgSelected').style['visibility'] = 'hidden';
			document.getElementById('regImgUnselected').style['width'] = 'auto';
			document.getElementById('regImgUnselected').style['visibility'] = 'visible';
			var registrationBox = document.getElementById('registrationBox');
			var oldRegistrationBox = document.getElementById('login_wrapper');
			registrationBox.removeChild(oldRegistrationBox);
			registrationShow=false;
		}
        if(lostpassShow) {
			var lostPassBox = document.getElementById('lostPassBox');
			var oldLostPassBox = document.getElementById('login_wrapper');
			lostPassBox.removeChild(oldLostPassBox);
			lostpassShow=false;
		}
        if(changeShow) {
			var chengeRegBox = document.getElementById('changeRegBox');
			var oldChangeRegBox = document.getElementById('login_wrapper');
			chengeRegBox.removeChild(oldChangeRegBox);
			changeShow=false;
		}
		document.getElementById('loginImgSelected').style['width'] = 'auto';
		document.getElementById('loginImgSelected').style['visibility'] = 'visible';
		document.getElementById('loginImgUnselected').style['width'] = '0px';
		document.getElementById('loginImgUnselected').style['visibility'] = 'hidden';
	    var loginBox = document.getElementById('loginBox');
	    var newLoginBox = document.createElement('div');
	    var divIdName = 'login_wrapper';
	    newLoginBox.setAttribute('id',divIdName);
	    newLoginBox.innerHTML = loginBoxDiv;
	    loginBox.appendChild(newLoginBox);
	    loginShow=true;
	} else {
		document.getElementById('loginImgSelected').style['width'] = '0px';
		document.getElementById('loginImgSelected').style['visibility'] = 'hidden';
		document.getElementById('loginImgUnselected').style['width'] = 'auto';
		document.getElementById('loginImgUnselected').style['visibility'] = 'visible';
		var loginBox = document.getElementById('loginBox');
		var oldLoginBox = document.getElementById('login_wrapper');
		loginBox.removeChild(oldLoginBox);
		loginShow=false;
	}
    if(lostpassShow) {
        var lostPassBox = document.getElementById('lostPassBox');
        var oldLostPassBox = document.getElementById('login_wrapper');
        lostPassBox.removeChild(oldLostPassBox);
        lostpassShow=false;
    }
}

function showHideLostPassBox() {
	if(!lostpassShow) {
		if(registrationShow) {
			document.getElementById('regImgSelected').style['width'] = '0px';
			document.getElementById('regImgSelected').style['visibility'] = 'hidden';
			document.getElementById('regImgUnselected').style['width'] = 'auto';
			document.getElementById('regImgUnselected').style['visibility'] = 'visible';
			var registrationBox = document.getElementById('registrationBox');
			var oldRegistrationBox = document.getElementById('login_wrapper');
			registrationBox.removeChild(oldRegistrationBox);
			registrationShow=false;
		}
        if(loginShow) {
			var loginBox = document.getElementById('loginBox');
			var oldLoginBox = document.getElementById('login_wrapper');
			loginBox.removeChild(oldLoginBox);
			loginShow=false;
		}
        if(changeShow) {
			var chengeRegBox = document.getElementById('changeRegBox');
			var oldChangeRegBox = document.getElementById('login_wrapper');
			chengeRegBox.removeChild(oldChangeRegBox);
			changeShow=false;
		}
		document.getElementById('loginImgSelected').style['width'] = 'auto';
		document.getElementById('loginImgSelected').style['visibility'] = 'visible';
		document.getElementById('loginImgUnselected').style['width'] = '0px';
		document.getElementById('loginImgUnselected').style['visibility'] = 'hidden';
	    var lostPassBox = document.getElementById('lostPassBox');
	    var newLostPassBox = document.createElement('div');
	    var divIdName = 'login_wrapper';
	    newLostPassBox.setAttribute('id',divIdName);
	    newLostPassBox.innerHTML = lostPassBoxDiv;
	    lostPassBox.appendChild(newLostPassBox);
	    lostpassShow=true;
	} else {
		document.getElementById('loginImgSelected').style['width'] = '0px';
		document.getElementById('loginImgSelected').style['visibility'] = 'hidden';
		document.getElementById('loginImgUnselected').style['width'] = 'auto';
		document.getElementById('loginImgUnselected').style['visibility'] = 'visible';
		var lostPassBox = document.getElementById('lostPassBox');
        var oldLostPassBox = document.getElementById('login_wrapper');
        lostPassBox.removeChild(oldLostPassBox);
        lostpassShow=false;
	}
}

function showHideRegistrationBox() {
	if(!registrationShow) {
		if(loginShow) {
			document.getElementById('loginImgSelected').style['width'] = '0px';
			document.getElementById('loginImgSelected').style['visibility'] = 'hidden';
			document.getElementById('loginImgUnselected').style['width'] = 'auto';
			document.getElementById('loginImgUnselected').style['visibility'] = 'visible';
			var loginBox = document.getElementById('loginBox');
			var oldLoginBox = document.getElementById('login_wrapper');
			loginBox.removeChild(oldLoginBox);
			loginShow=false;
		}
        if(lostpassShow) {
        	document.getElementById('loginImgSelected').style['width'] = '0px';
			document.getElementById('loginImgSelected').style['visibility'] = 'hidden';
			document.getElementById('loginImgUnselected').style['width'] = 'auto';
			document.getElementById('loginImgUnselected').style['visibility'] = 'visible';
			var lostPassBox = document.getElementById('lostPassBox');
			var oldLostPassBox = document.getElementById('login_wrapper');
			lostPassBox.removeChild(oldLostPassBox);
			lostpassShow=false;
		}
        if(changeShow) {
			var chengeRegBox = document.getElementById('changeRegBox');
			var oldChangeRegBox = document.getElementById('login_wrapper');
			chengeRegBox.removeChild(oldChangeRegBox);
			changeShow=false;
		}
		document.getElementById('regImgSelected').style['width'] = 'auto';
		document.getElementById('regImgSelected').style['visibility'] = 'visible';
		document.getElementById('regImgUnselected').style['width'] = '0px';
		document.getElementById('regImgUnselected').style['visibility'] = 'hidden';
	    var registrationBox = document.getElementById('registrationBox');
	    var newRegistrationBox = document.createElement('div');
	    var divIdName = 'login_wrapper';
   	    newRegistrationBox.setAttribute('id',divIdName);
	    newRegistrationBox.innerHTML = registrationDiv;
	    registrationBox.appendChild(newRegistrationBox);
	    registrationShow=true;
	} else {
		document.getElementById('regImgSelected').style['width'] = '0px';
		document.getElementById('regImgSelected').style['visibility'] = 'hidden';
		document.getElementById('regImgUnselected').style['width'] = 'auto';
		document.getElementById('regImgUnselected').style['visibility'] = 'visible';
		var registrationBox = document.getElementById('registrationBox');
		var oldRegistrationBox = document.getElementById('login_wrapper');
		registrationBox.removeChild(oldRegistrationBox);
		registrationShow=false;
	}
}

function popupLoginBox(reason, url) {
    //var o = testForObject('error_wrapper');	
    //if(!o) {
    	var divPos = loginBoxDiv.indexOf('<div id="error_wrapper">');
    	if(divPos>10) {
        	loginBoxDiv = loginBoxDiv.substring(0, divPos);
        }
        loginBoxDiv+='<div id="error_wrapper">';
        loginBoxDiv+=reason;
        loginBoxDiv+='</div>';
    //}
    	loginBoxDiv=loginBoxDiv.replace('name=\"curUrl\" value=\"'+curUrl, 'name=\"curUrl\" value=\"'+url);
        registrationDiv=registrationDiv.replace('name=\"curUrl\" value=\"'+curUrl, 'name=\"curUrl\" value=\"'+url);
		curUrl=url;
    
    scrolldelay = setTimeout('pageScroll()',50);
}

function setRegistationBoxToChangeBox() {
    if(loginShow) {
        document.getElementById('loginImgSelected').style['width'] = '0px';
        document.getElementById('loginImgSelected').style['visibility'] = 'hidden';
        document.getElementById('loginImgUnselected').style['width'] = 'auto';
        document.getElementById('loginImgUnselected').style['visibility'] = 'visible';
        var loginBox = document.getElementById('loginBox');
        var oldLoginBox = document.getElementById('login_wrapper');
        loginBox.removeChild(oldLoginBox);
        loginShow=false;
    }
    if(lostpassShow) {
        document.getElementById('loginImgSelected').style['width'] = '0px';
        document.getElementById('loginImgSelected').style['visibility'] = 'hidden';
        document.getElementById('loginImgUnselected').style['width'] = 'auto';
        document.getElementById('loginImgUnselected').style['visibility'] = 'visible';
        var lostPassBox = document.getElementById('lostPassBox');
        var oldLostPassBox = document.getElementById('login_wrapper');
        lostPassBox.removeChild(oldLostPassBox);
        lostpassShow=false;
    }
    if(registrationShow) {
        document.getElementById('regImgSelected').style['width'] = '0px';
        document.getElementById('regImgSelected').style['visibility'] = 'hidden';
        document.getElementById('regImgUnselected').style['width'] = 'auto';
        document.getElementById('regImgUnselected').style['visibility'] = 'visible';
        var registrationBox = document.getElementById('registrationBox');
        var oldRegistrationBox = document.getElementById('login_wrapper');
        registrationBox.removeChild(oldRegistrationBox);
        registrationShow=false;
    }
    if(changeShow) {
        var chengeRegBox = document.getElementById('changeRegBox');
        var oldChangeRegBox = document.getElementById('login_wrapper');
        chengeRegBox.removeChild(oldChangeRegBox);
        changeShow=false;
    }
    else if(!changeShow) {
        changeShow=true;
        var chengeRegBox = document.getElementById('changeRegBox');
        var newChengeRegBox = document.createElement('div');
        var divIdName = 'login_wrapper';
        newChengeRegBox.setAttribute('id',divIdName);
        newChengeRegBox.innerHTML = changeDiv;
        chengeRegBox.appendChild(newChengeRegBox);
    }	
}

function pageScroll() {
	var ScrollTop = document.body.scrollTop;
    if (ScrollTop == 0) {
        if (window.pageYOffset) ScrollTop = window.pageYOffset;
        else ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }
    //alert(ScrollTop);
    var newPos = ScrollTop;
    newPos += (0-newPos)/3;
    if(newPos<2) {
    	//alert("slut!");
    	scroll(0,0);
        clearTimeout(scrolldelay);
        if(loginShow) {
        	document.getElementById('loginImgSelected').style['width'] = '0px';
			document.getElementById('loginImgSelected').style['visibility'] = 'hidden';
			document.getElementById('loginImgUnselected').style['width'] = 'auto';
			document.getElementById('loginImgUnselected').style['visibility'] = 'visible';
			var loginBox = document.getElementById('loginBox');
			var oldLoginBox = document.getElementById('login_wrapper');
			loginBox.removeChild(oldLoginBox);
			loginShow=false;
        }
        if(registrationShow) {
        	document.getElementById('regImgSelected').style['width'] = '0px';
            document.getElementById('regImgSelected').style['visibility'] = 'hidden';
            document.getElementById('regImgUnselected').style['width'] = 'auto';
            document.getElementById('regImgUnselected').style['visibility'] = 'visible';
            var registrationBox = document.getElementById('registrationBox');
            var oldRegistrationBox = document.getElementById('login_wrapper');
            registrationBox.removeChild(oldRegistrationBox);
            registrationShow=false;
        }
        if(!loginShow&&!registrationShow) showHideLoginBox();
    } else {
    	scroll(0,newPos);
        scrolldelay = setTimeout('pageScroll()',50);
    }
}


function showReportInputBox(id, type, reportId, url) {

    divInputBox='<div class="post_bothColumns_lineOver">';
    
    divInputBox+='<form method="post" action="/postReport.php">';
    divInputBox+='<input type="hidden" name="type" value="'+type+'"/>';
    divInputBox+='<input type="hidden" name="reportId" value="'+reportId+'"/>';
    divInputBox+='<input type="hidden" name="url" value="'+url+'"/>';

    divInputBox+='<h2>Anmäl felaktigheter</h2>';
    divInputBox+='    <div class="report_leftColumn">';
    divInputBox+='    	<h4>Beskrivning:</h4>';
    divInputBox+='    </div>';
    divInputBox+='    <div class="report_rightColumn">';
    divInputBox+='    	<h4>Anmälningar görs när:</h4>';
    divInputBox+='    </div>';
    divInputBox+='    <div class="report_leftColumn">';
    divInputBox+='    	<textarea class="report_textField" rows="3" cols="" name="reason"/></textarea>';
    divInputBox+='        <div class="schoolComment_buttonWrapper">';
    divInputBox+='            <a href="javascript:display_spaces()" onclick="showReportInputBox(\''+id+'\', \''+type+'\', '+reportId+')"><img class="align_left" height="23" width="180" type="image" alt="Avbryt" src="/buttons/comment_cancel.png"/></a>';
    divInputBox+='            <input class="schoolComment_lastButton" height="23" width="180" type="image" alt="Lämna anmälan" src="/buttons/report.gif"/>';
    divInputBox+='		</div>';
    divInputBox+='    </div>';
    divInputBox+='<div class="report_rightColumn">';
    divInputBox+='    	- ihoplänkningar inte stämmer<br />';
    divInputBox+='      - uppgifter inte är korrekta<br/ >';
    divInputBox+='      - länkar inte är korrekta<br />';
    if(type=='program') divInputBox+='      - programmet inte längre är aktivt.<br />';
    if(type=='course') divInputBox+='      - kursen inte längre är aktiv.<br />';
    if(type=='lecturer') divInputBox+='      - föreläsaren inte längre är aktiv.<br />';
    divInputBox+='        <br />';
    divInputBox+='    Det går även att anmäla enskilda omdömen. Vi strävar alltid efter att behandla';
    divInputBox+='    anmälningar så fort som möjligt.</div>';
    divInputBox+='</div>';
        
    var o = testForObject('reportBoxId_'+id);	
    if(o) {
   		var registrationBox = document.getElementById(id);
		var oldRegistrationBox = document.getElementById('reportBoxId_'+id);
		registrationBox.removeChild(oldRegistrationBox);
    } else {    
        var registrationBox = document.getElementById(id);
        var newRegistrationBox = document.createElement('div');
        var divIdName = 'reportBoxId_'+id;
        newRegistrationBox.setAttribute('id',divIdName);
        newRegistrationBox.innerHTML = divInputBox;
        registrationBox.appendChild(newRegistrationBox);
    }
}








function showCommentInputBox(id, type, commentId, schoolId, postNumber, currentPage, hitsPerPage) {

    divInputBox='<form method="post" action="/postComment.php" name="commentR_'+commentId+'">';
    divInputBox+='<input type="hidden" name="type" value="'+type+'"/>';
    divInputBox+='<input type="hidden" name="postNumber" value="'+postNumber+'"/>';
    divInputBox+='<input type="hidden" name="currentPage" value="'+currentPage+'"/>';
    divInputBox+='<input type="hidden" name="hitsPerPage" value="'+hitsPerPage+'"/>';
    divInputBox+='<input type="hidden" name="commentId" value="'+commentId+'"/>';
    divInputBox+='<input type="hidden" name="schoolId" value="'+schoolId+'"/>';
    divInputBox+='<input type="hidden" name="standardPhrase" value="Du är själv ansvarig för att dina kommentarer inte bryter mot lag, förordning eller våra användarvillkor"/>';

    divInputBox+='<textarea name="comment" cols="" rows="3" class="schoolComment_textField" id="commentFieldR_'+commentId+'" onclick=  "clearTextField(document.commentR_'+commentId+'.commentFieldR_'+commentId+', \'Du är själv ansvarig för att dina kommentarer inte bryter mot lag, förordning eller våra användarvillkor\');">Du är själv ansvarig för att dina kommentarer inte bryter mot lag, förordning eller våra användarvillkor</textarea>';
    divInputBox+='<div class="schoolComment_buttonWrapper">';
    divInputBox+='<a href="javascript:display_spaces()" onclick="showCommentInputBox(\''+id+'\')"><img src="/buttons/comment_cancel.png" alt="Avbryt" width="180" height="23" class="align_left"/></a>';
    divInputBox+='<input type="image" src="/buttons/comment.png" alt="Kommentera" width="180" height="23" class="schoolComment_lastButton" />';
    divInputBox+='</div>';
    divInputBox+='</form>';
    
    var o = testForObject('commentBoxId_'+id);
    if(o) {
   		var registrationBox = document.getElementById(id);
		var oldRegistrationBox = document.getElementById('commentBoxId_'+id);
		registrationBox.removeChild(oldRegistrationBox);
    } else {    
        var registrationBox = document.getElementById(id);
        var newRegistrationBox = document.createElement('div');
        var divIdName = 'commentBoxId_'+id;
        newRegistrationBox.setAttribute('id',divIdName);
        newRegistrationBox.innerHTML = divInputBox;
        registrationBox.appendChild(newRegistrationBox);
    }
}

function showTipFriendArticleBox(header, intro, url) {


	divInputBox='<div class="friendWrapper">';
    divInputBox+='<form method="post" action="/send_to_friend.php">';
    divInputBox+='<input type="hidden" name="header" value="'+header+'"/>';
    divInputBox+='<input type="hidden" name="intro" value="'+intro+'"/>';
    divInputBox+='<input type="hidden" name="url" value="'+url+'"/>';
    divInputBox+='<input type="hidden" name="curUrl" value="'+curUrl+'"/>';
  	divInputBox+='<h4>Tipsa en kompis</h4>';
    divInputBox+='Ditt namn:<br />';
    divInputBox+='<input name="name" type="text" class="article_friendField"/>';
    divInputBox+='<br />';
    divInputBox+='Din väns e-post:<br />';
    divInputBox+='<input name="friendMail" type="text" class="article_friendField"/>';
    divInputBox+='<br />';
    divInputBox+='<br />';
    divInputBox+='<input type="image" src="/buttons/article_mail_friend.gif" width="170" height="23" alt="Skicka till kompis"  >';
    divInputBox+='</form>';
	divInputBox+='</div>';
    
    var o = testForObject('tip_friend_article_inner');
    if(o) {
   		var registrationBox = document.getElementById('tip_friend_article');
		var oldRegistrationBox = document.getElementById('tip_friend_article_inner');
		registrationBox.removeChild(oldRegistrationBox);
    } else {    
        var registrationBox = document.getElementById('tip_friend_article');
        var newRegistrationBox = document.createElement('div');
        var divIdName = 'tip_friend_article_inner';
        newRegistrationBox.setAttribute('id',divIdName);
        newRegistrationBox.innerHTML = divInputBox;
        registrationBox.appendChild(newRegistrationBox);
    }
}

function showTipFriendSchoolBox(header, intro, url) {


	divInputBox='<div class="school_friend_wrapper">';
    divInputBox+='<form method="post" action="http://www.studentertyckertill.se/send_to_friend.php">';
    divInputBox+='<input type="hidden" name="header" value="'+header+'"/>';
    divInputBox+='<input type="hidden" name="intro" value="'+intro+'"/>';
    divInputBox+='<input type="hidden" name="url" value="'+url+'"/>';
    divInputBox+='<input type="hidden" name="curUrl" value="'+curUrl+'"/>';
  	divInputBox+='<h4>Tipsa en kompis</h4>';
    divInputBox+='<div class="school_friend_column">';
    divInputBox+='Ditt namn:<br />';
    divInputBox+='<input name="name" type="text" class="school_friendField"/>';
    divInputBox+='</div>';
    divInputBox+='<div class="school_friend_column">';
    divInputBox+='Din väns e-post:<br />';
    divInputBox+='<input name="friendMail" type="text" class="school_friendField"/>';
    divInputBox+='</div>';
    divInputBox+='<div class="school_friend_lastColumn">';
    divInputBox+='<br />';
    divInputBox+='<input type="image" src="http://www.studentertyckertill.se/buttons/article_mail_friend.gif" width="170" height="23" alt="Skicka till kompis"  >';
    divInputBox+='</div>';
    divInputBox+='</form>';
	divInputBox+='</div>';
    
    var o = testForObject('school_send_to_friend_inner');
    if(o) {
   		var registrationBox = document.getElementById('school_send_to_friend');
		var oldRegistrationBox = document.getElementById('school_send_to_friend_inner');
		registrationBox.removeChild(oldRegistrationBox);
    } else {    
        var registrationBox = document.getElementById('school_send_to_friend');
        var newRegistrationBox = document.createElement('div');
        var divIdName = 'school_send_to_friend_inner';
        newRegistrationBox.setAttribute('id',divIdName);
        newRegistrationBox.innerHTML = divInputBox;
        registrationBox.appendChild(newRegistrationBox);
    }
}




function addToLinkage(divId, name, school, type, itemName) {
    saveForLinkgageArr.push(divId);
    if(saveForLinkgageArr.length%2==0) {
    	var divLinkageBox='	<div class="evenRow" id="rowId_'+divId+'">';
    } else {
    	var divLinkageBox='	<div class="oddRow" id="rowId_'+divId+'">';
    }
    divLinkageBox+='            <div class="text_wrapper_short">';
    divLinkageBox+='                    <strong>'+name+'</strong>';
    divLinkageBox+='             </div>';
    divLinkageBox+='             <div class="button_wrapper">';
    divLinkageBox+='                <a href="javascript:display_spaces()" onclick="removeFromLinkage('+divId+', \''+name+'\', \''+school+'\', \''+type+'\', \''+itemName+'\')">Ta bort från ihoplänkning</a>';
    divLinkageBox+='             </div>';
    divLinkageBox+='</div>';
    
    var o = testForObject('linkageLink_'+divId);
    if(o) {
 	   var linkage = document.getElementById('linkageLink_'+divId);
  	   linkage.innerHTML='Sparad';
    }
    
    var formId = document.getElementById('formId');
    formId.innerHTML="";
    formId.innerHTML='<input type="hidden" name="formIds" value="'+saveForLinkgageArr+'" />';
    
    var registrationBox = document.getElementById('linkageBoxSaved');
    var newRegistrationBox = document.createElement('div');
    var divIdName = 'linkageItem_'+divId;
    newRegistrationBox.setAttribute('id',divIdName);
    newRegistrationBox.innerHTML = divLinkageBox;
    registrationBox.appendChild(newRegistrationBox);
    
    var linkageHeader = document.getElementById('linkageHeader');
    linkageHeader.innerHTML='';
}

function removeFromLinkage(divId, name, school, type, itemName) {
	for(var i=0; i<saveForLinkgageArr.length; i++) {
    	if(saveForLinkgageArr[i]==divId) {
        	saveForLinkgageArr.splice(i, 1);
            break;
        }
    }
    var registrationBox = document.getElementById('linkageBoxSaved');
    var oldRegistrationBox = document.getElementById('linkageItem_'+divId);
    registrationBox.removeChild(oldRegistrationBox);
    
    var formId = document.getElementById('formId');
    formId.innerHTML="";
    formId.innerHTML='<input type="hidden" name="formIds" value="'+saveForLinkgageArr+'" />';
    
    var o = testForObject('linkageLink_'+divId);
    if(o) {
 	   var linkage = document.getElementById('linkageLink_'+divId);
       linkage.innerHTML='<a href="javascript:display_spaces()" onclick="addToLinkage('+divId+', \''+name+'\', \''+school+'\', \''+type+'\', \''+itemName+'\')">Spara för ihoplänkning</a>';
    }
    
    if(saveForLinkgageArr.length==0) {
    	var linkageHeader = document.getElementById('linkageHeader');
    	linkageHeader.innerHTML='Inga '+type+' är ihoplänkade '+itemName;
    }
    
    for(var i=0; i<saveForLinkgageArr.length; i++) {
    	var registrationBox = document.getElementById('rowId_'+saveForLinkgageArr[i]);
        if(i%2==0) {
            registrationBox.setAttribute('class','oddRow');
        } else {
            registrationBox.setAttribute('class','evenRow');
        }
        
    }
}

function removeAllLinkage() {
	saveForLinkgageArr = new Array();
    document.getElementById('linkageBoxSaved').innerHTML="";
	updateSearch();
}

function setAdvancedSearchActive(id, boxId) {
	window.location.replace("#searchType="+id);
	if(boxId) {
    	document.getElementById(boxId).checked=true;
    }
	advancedSearchHideAll();
    toggleLayerOn(id);
}

function setUserSectionActive(id, divClass) {
    document.getElementById('user_section_choise').innerHTML='<div class="'+divClass+'" />';
    
	userSectionHideAll();
    toggleLayerOn(id);
}

function numberOfWinnersForm(num) {
	var newFormDiv = "";
	for(var i=0; i<num; i++) {
    	newFormDiv+='<p>';
        newFormDiv+='    Fråga: '+(i+1)+'<br />';
        newFormDiv+='    <input type="text" name="question'+(i+1)+'" id="winner_question'+(i+1)+'" />';
        newFormDiv+='</p>';
        newFormDiv+='<p>';
        newFormDiv+='    Svar '+(i+1)+':<br />';
        newFormDiv+='    <textarea name="answer'+(i+1)+'" cols="60" rows="6" id="winner_answer'+(i+1)+'"></textarea>';
        newFormDiv+='</p>';
    }
    document.getElementById('winner_questions_form').innerHTML=newFormDiv;
}

function confirmGotoPage(message, url)
{
    var where_to= confirm(message);
    if (where_to== true)
    {
        window.location=url;
    }
}


function toggleLayerOn( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;

  vis.display = 'block';
}

function toggleLayerOff( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;

    vis.display = 'none';
}

function userSectionHideAll() {
    toggleLayerOff('ratings_show');
    toggleLayerOff('comments_show');
}

function addPanelPerson(str) {
	numOfPanelForms++;
	var strArr = str.split("_");
    var addToDiv = '<p>';
    	addToDiv+= strArr[1]+':<br />';
        addToDiv+= '<input type="hidden" name="panelPersonId_'+numOfPanelForms+'" value="'+strArr[0]+'">'
		addToDiv+= '<textarea name="panelPersonText_'+numOfPanelForms+'" cols="60" rows="3" id="panelPersonText_'+numOfPanelForms+'"></textarea>';
    	addToDiv+= '</p>';
        numOfPanelForms++;
    document.getElementById('panel_answers_form').innerHTML+=addToDiv;
    
    document.getElementById('panel_answers_num').innerHTML='<input type="hidden" name="panelPersonNum" value="'+numOfPanelForms+'" />';
}

function advancedSearchHideAll() {
    toggleLayerOff('advancedSearchSchool');
    toggleLayerOff('advancedSearchProgram');
    toggleLayerOff('advancedSearchCourse');
    toggleLayerOff('advancedSearchLecturer');
}

function clearTextField(field, stdStr) {
	if(field.value==stdStr) field.value='';
}

function showHelpBox(pos, txt) {
	toggleLayerOn('helper_popup');
  if(!pos||pos=='true') {
        document.getElementById('helper_popup').style['left'] = tempX+'px';
        document.getElementById('helper_popup').style['top'] = tempY+'px';
  }
  if(txt) {
  	document.getElementById('helper_popup_text').innerHTML=txt;
  }
}

function hideHelpBox() {
	toggleLayerOff('helper_popup');
}

function testForObject(Id, Tag)
{
  var o = document.getElementById(Id);
  if (o)
  {
    if (Tag)
    {
      if (o.tagName.toLowerCase() == Tag.toLowerCase())
      {
        return o;
      }
    }
    else
    {
      return o;
    }
  }
  return null;
}


