function toggleClassName(element, className) {
	var classPattern = new RegExp('(^|\\s)' + className + '(\\s|$)');
	if ((typeof element == 'string') && document.getElementById)
		element = document.getElementById(element);
	if (element)
		if (classPattern.test(element.className))
			element.className = element.className.replace(classPattern, ' ');
		else
			element.className += ' ' + className;
}

function change_menu(div_id,class_name){

	var m= document.getElementById(div_id);
	m.className=class_name;

}
function voidd(){
	var t=2;
}
/**
 *
 * @access public
 * @return void
 **/
function switch_thought(tp,thought_id){
	if(tp=='short'){
		document.getElementById('short_text_'+thought_id).style.display='block';
		document.getElementById('long_text_'+thought_id).style.display='none';
		document.getElementById('short_link_'+thought_id).style.display='block';
		document.getElementById('long_link_'+thought_id).style.display='none';
	}else{
		document.getElementById('long_text_'+thought_id).style.display='block';
		document.getElementById('short_text_'+thought_id).style.display='none';
		document.getElementById('long_link_'+thought_id).style.display='block';
		document.getElementById('short_link_'+thought_id).style.display='none';
	}
}
function switch_thought2(tp,thought_id){
	if(tp=='short'){
		document.getElementById('short_text2_'+thought_id).style.display='block';
		document.getElementById('long_text2_'+thought_id).style.display='none';
		document.getElementById('short_link2_'+thought_id).style.display='block';
		document.getElementById('long_link2_'+thought_id).style.display='none';
	}else{
		document.getElementById('long_text2_'+thought_id).style.display='block';
		document.getElementById('short_text2_'+thought_id).style.display='none';
		document.getElementById('long_link2_'+thought_id).style.display='block';
		document.getElementById('short_link2_'+thought_id).style.display='none';
	}
}
function switch_thought3(tp,thought_id){
	if(tp=='short'){
		document.getElementById('short_text3_'+thought_id).style.display='block';
		document.getElementById('long_text3_'+thought_id).style.display='none';
		document.getElementById('short_link3_'+thought_id).style.display='block';
		document.getElementById('long_link3_'+thought_id).style.display='none';
	}else{
		document.getElementById('long_text3_'+thought_id).style.display='block';
		document.getElementById('short_text3_'+thought_id).style.display='none';
		document.getElementById('long_link3_'+thought_id).style.display='block';
		document.getElementById('short_link3_'+thought_id).style.display='none';
	}
}
/**
 *
 * @access public
 * @return void
 **/
function show_div(div_id){
	document.getElementById(div_id).style.display='block';
}
function hide_div(div_id){
	document.getElementById(div_id).style.display='none';
}
function show_pmdiv(pmid){
	if(document.getElementById('pm_cont_'+pmid).className=='hidden_row'){
		document.getElementById('pm_cont_'+pmid).className='visible_row';
		document.getElementById('pm_img_'+pmid).src='/images/arrow_right2.gif';
	}else{
		document.getElementById('pm_cont_'+pmid).className='hidden_row';
		document.getElementById('pm_img_'+pmid).src='/images/arrow_down2.gif';
	}
	document.getElementById('col2_'+pmid).className='col2';
	document.getElementById('col3_'+pmid).className='col3';
	document.getElementById('col4_'+pmid).className='col4';
	var params = '';
	var url = "/direct-pm-set_read-"+pmid;
	var myAjax = new Ajax.Request(
			url,
			{
				method: 'post',
				postBody: params,
				onComplete: hideMsgWindow,
				onFailure: hideMsgWindow,
				onException: hideMsgWindow
			});
}

function countWords(min_len)
{
//alert(tinyMCE.getContent());
//return ;
var tiny_ID='content'; //This is the ID of your tinyMCE content ID
var strip=tinyMCE.activeEditor.getContent();

strip = strip.replace(/&(lt|gt);/g, function (strMatch, p1){
 		 	return (p1 == "lt")? "<" : ">";
 		});

strip=strip.replace(/<\/?[^>]+(>|$)/g, "");
var w_l=0;
if(strip=="")
{
document.new_thought.wordcount.value=w_l;
document.new_thought.submitt.disabled=true;
}
else
{
w_l=strip.split(' ').length;
document.new_thought.wordcount.value = w_l;
if(w_l<min_len){
	document.getElementById('wordcount').className='wordcount_red';
	document.new_thought.submitt.disabled=true;
}else{
	document.getElementById('wordcount').className='wordcount_green';
	document.new_thought.submitt.disabled=false;
}

}

setTimeout("countWords("+min_len+")",100);
}

function countWords2(min_len)
{
//alert(tinyMCE.getContent());
//return ;
document.new_thought.submitt.disabled=false;

if(document.new_thought.category_id.value==""){
	document.new_thought.submitt.disabled=true;
}
if(document.new_thought.scategory_id.value==""){
	document.new_thought.submitt.disabled=true;
}
/*
if(document.getElementById('nova_thought_synopsis[]').value==""){
	document.new_thought.submitt.disabled=true;
}
if(document.getElementById('nova_thought_title[]').value==""){
	document.new_thought.submitt.disabled=true;
}
*/
setTimeout("countWords2("+min_len+")",100);
}

/**
 *
 * @access public
 * @return void
 **/
function go_to_step(old_step,next_step){
	document.getElementById('step'+old_step).className='step_inactive';
	document.getElementById('step'+next_step).className='step_active';
}

/**
 *
 * @access public
 * @return void
 **/
function check_register(){
	var form_ok=1;
	if(document.new_thought.username.value==''){
		document.getElementById('r_username').className='input_field field_red';
		form_ok=0;
	}else{
		document.getElementById('r_username').className='input_field';
	}
	if(document.new_thought.password.value==''){
		document.getElementById('r_password').className='input_field field_red';
		form_ok=0;
	}else{
		document.getElementById('r_password').className='input_field';
	}
	if(document.new_thought.c_password.value==''){
		document.getElementById('r_c_password').className='input_field field_red';
		form_ok=0;
	}else{
		document.getElementById('r_c_password').className='input_field';
	}
	if(document.new_thought.c_password.value!=document.new_thought.password.value){
		document.getElementById('r_c_password').className='input_field field_red';
		form_ok=0;
	}
	if(document.new_thought.email.value==''){
		document.getElementById('r_email').className='input_field field_red';
		form_ok=0;
	}else{

		if(emailCheck(document.new_thought.email.value)==false){
			document.getElementById('r_email').className='input_field field_red';
			form_ok=0;
		}else{
			document.getElementById('r_email').className='input_field';
		}
	}
	if(document.new_thought.firstname.value==''){
		document.getElementById('r_firstname').className='input_field field_red';
		form_ok=0;
	}else{
		document.getElementById('r_firstname').className='input_field';
	}
	if(document.new_thought.lastname.value==''){
		document.getElementById('r_lastname').className='input_field field_red';
		form_ok=0;
	}else{
		document.getElementById('r_lastname').className='input_field';
	}
	if(document.new_thought.control.value==''){
		document.getElementById('r_control').className='input_field field_red';
		document.new_thought.submitt.disabled=true;
	}else{
		document.getElementById('r_control').className='input_field';
		document.new_thought.submitt.disabled=false;
	}
	if(document.new_thought.terms.checked==false){
		document.new_thought.submitt.disabled=true;
		document.getElementById('terms_cond').className='error_field';
	}else{
		document.getElementById('terms_cond').className='normaltext';
	}
	if(form_ok!=1){
		document.new_thought.submitt1.disabled=true;
	}else{
		document.new_thought.submitt1.disabled=false;
	}
}


function emailCheck(emailfield)
{
	var formname;
	var emailfield;
	if (emailfield == "")
	 { //alert("Bitte tragen Sie Ihre Email-Adresse ein!");

	   return false;}

		var item = emailfield;

        var returnVal = false
        checkVal = 0
        period = 0
        count1 = 0
        count2 = 0

        for (var i=0; i < item.length; i++)
        {
                if (item.substring(i,i+1) == '@')
                {
                        checkVal = checkVal + 1
                        count1 = count1 + 1
                }
                if (item.substring(i,i+1) == '!')
                {
                        checkVal = checkVal + 2
                        count2 = count2 + 1
                }
                if (item.substring(i,i+1) == '.')
                {
                        if (period != 1)
                        {
                           checkVal = checkVal + 4
                           period = 1
                        }
                }
                if (item.substring(i,i+1) == ' ')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == ',')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == '"')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == '\'')
                {
                        checkVal = 8
                }
        }
        if (checkVal == 5 || checkVal == 6)
        {
               var p=item.split("@");
               var r=p[1].split(".");
               var lungime=(r.length-1);
		        if(p[0].length<1){
		        	var ret=1;
		        	fout="Vor dem @ muss mindestens ein Zeichen stehen!";
		        }

		        if(r[0].length<1){
		        	var ret=1;
		        	fout="Vor dem . muss mindestens ein Zeichen stehen!";
		        }
		        if(r[lungime].length<2){
		        	var ret=1;
		        	fout="Nach dem . müssen mindestens zwei Zeichen stehen!";
		        }

		        if(ret==1){
		        	returnVal=false;
		        }else{
		        	returnVal = true
		        }



        }
        else
	      return returnVal
}
/**
 *
 * @access public
 * @return void
 **/
function view_big_photo(e,photo_src,photo_width,photo_height){
   	var r, re;         //Declare variables.
   	re = /general/i;    //Create regular expression pattern.
   	r = photo_src.match(re);   //Attempt match on search string.
	if(r){
		return;
	}
	elementid='picture_big_popup';
	getMousePositionPhoto(e,elementid,photo_width,photo_height);

	msgContainer = $(elementid);
	var p_width=photo_width+3;
	var p_height=photo_height+3;
	msgContainer.style.display =  'block';
	document.getElementById('picture_big_src').src=photo_src;
	document.getElementById('picture_big_src').width=photo_width;
	document.getElementById('picture_big_src').height=photo_height;
	document.getElementById(elementid).style.width=p_width+'px';
	document.getElementById(elementid).style.height=p_height+'px';
}
/**
 *
 * @access public
 * @return void
 **/
function view_big_home(e,t){

	elementid='home_big_popup';
	getMousePosition3(e,elementid);

	msgContainer = $(elementid);

	msgContainer.style.display =  'block';
	document.getElementById('home_big_popup').innerHTML=t;
}
/**
 *
 * @access public
 * @return void
 **/
function view_big_rss(e,t){
	if(t){
	elementid='rss_big_popup';
	getMousePosition5(e,elementid);

	msgContainer = $(elementid);

	msgContainer.style.display =  'block';
	document.getElementById('rss_big_popup').innerHTML=t;
	}
}
/**
 *
 * @access public
 * @return void
 **/
function hide_big_rss(){
	document.getElementById('rss_big_popup').style.display = 'none';
}

function bookmarksite(title,url){
if (window.sidebar) // Firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // Opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all){ // IE
window.external.AddFavorite(url, title);
}else{
alert('Press Ctrl+D to add this site to bookmarks');
}
}
