﻿
function trigger_effect(src_element, div_id) {
    var element;
    var element2;
    var image;
    var hidelement;
    var source;
    hidelement = document.getElementById(div_id);
    source = src_element;
    if (source.id == 'suche') {
        element = document.getElementById('quicksearchsmall');
        image = document.getElementById('erw_suche');
        image.onclick = function () { trigger_effect(image, 'extsearch'); };
        element2 = document.getElementById('extsearch');
    }
    else if (source.id == 'erw_suche') {
        element = document.getElementById('extsearch');
        image = document.getElementById('suche');
        image.onclick = function () { trigger_effect(image, 'quicksearchsmall'); };
        element2 = document.getElementById('quicksearchsmall');
    }

    image.src = '/images/search/';
    image.src = image.src + image.id + '.png';
    if (source.src.indexOf("_active") <= 0) { source.src = source.src.replace(source.id, source.id + '_active'); }

    element2.style.display = 'none';
    hidelement.style.display = 'none';
    Effect.toggle(element, 'slide');
    return true;
}


function open_vk(user_vk)
{
    window.location.href = "/PageTemplates/VCard.aspx?user_vk=" + user_vk +"";

}

function open_vkgallery(user_vk, item_id) {
    window.location.href = "/PageTemplates/VCard.aspx?user_vk=" + user_vk + "&itemid=" + item_id + "";

}

function open_vkmessage(user_vk)
{
    window.location.href = "/PageTemplates/VCard.aspx?user_vk=" + user_vk +"&message=1";

}

function open_vksearch(user_vk, age, sex, pictureprofile)
{
    window.location.href = "/PageTemplates/VCard.aspx?user_vk=" + user_vk +"&age="+ age +"&sex="+ sex +"&pictureprofile="+ pictureprofile +"";

}

function open_vknonactive(user_vk, age, sex, pictureprofile)
{
    window.location.href = "/PageTemplates/VCard.aspx?user_vk=" + user_vk +"&age="+ age +"&sex="+ sex +"&nonactive=1";

}


function open_vkOnline(user_vk)
{
    window.location.href = "/PageTemplates/VCard.aspx?user_vk=" + user_vk +"";

}



function upload(user_vk)
{
	window.open("/PageTemplates/PopUp/MediaUpload/VCardImage.aspx?sessid=" + sid,"UploadVCard","alwaysRaised=1,toolbar=0,location=0,scrollbars=yes,menubar=0,resizable=0,status=0,width=750,height=650").focus();
}

function uploadPlus()
{
	window.open("/PageTemplates/PopUp/MediaUpload/XXLImage.aspx?sessid=" + sid,"UploadXXL","alwaysRaised=1,toolbar=0,location=0,scrollbars=yes,menubar=0,resizable=0,status=0,width=750,height=650").focus();
}

function uploadMsg()
{
	window.open("/PageTemplates/PopUp/MediaUpload/MsgImage.aspx?sessid=" + sid,"UploadMsg","alwaysRaised=1,toolbar=0,location=0,scrollbars=yes,menubar=0,resizable=0,status=0,width=750,height=650").focus();
}

function uploadPictureProfile()
{
	window.open("/PageTemplates/PopUp/MediaUpload/PictureProfileImage.aspx?sessid=" + sid,"UploadPictureProfile","alwaysRaised=1,toolbar=0,location=0,scrollbars=yes,menubar=0,resizable=0,status=0,width=750,height=650").focus();
}

function getSessionUrl(url)
{
	var z='?';
	if(url.indexOf("?")>-1)
	{
		z = '&';
	}
	url = url + z + "sessid=" + sid;
	return url;
}

function popUp(url, windowname, width, height, scrollbars, resizable, options)
{
	if(url.indexOf("http")<0)
	{
		url = getSessionUrl(url);
	}
	var w = window.open(url, windowname, "width=" + width +",height=" + height + ",scrollbars=" + scrollbars + ",resizable=" + resizable + "," + options);
	w.focus();
} 

function remoteNavigate(win, url)
{
    if(url.indexOf("http")<0)
    {
	    url = getSessionUrl(url);
    }

    win.location.href = url;

} 
 
function checkNbrChars(areaobject, maxlength, countdisplay)
{

    if(areaobject)
    {
	    if(areaobject.value.length >= maxlength)
	    {
		    areaobject.value = areaobject.value.substr(0, maxlength-1);
	    }
	    var t = document.forms[0][countdisplay];
	    if(t)
	    {
		    t.value = maxlength - areaobject.value.length-1;
	    }
    }

}
 
var focusedelement = null;
function SetFocus(formelement)
{
	document.forms[0].elements["LastFocusedElementTemp"].value = formelement.name;	
	focusedelement = formelement;
}

function CheckKeyPress(e)
{
	if((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
	{
		if(focusedelement != null)
		{
			if(focusedelement.type == "textarea" || focusedelement.className == "chatbox")
			{
				return;
			}
			
		    if (typeof(Page_ClientValidate) != 'function' ||  Page_ClientValidate())
		    {
			    document.forms[0].elements["LastFocusedElement"].value = document.forms[0].elements["LastFocusedElementTemp"].value;
			    document.forms[0].submit();
		    }
		}
	}
}

function CheckSubmit(e, targetid)
{
    targetid = targetid.split(':').join('$');
    
    if((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
	{
	    __doPostBack(targetid,'');
	    return false;
	}
}

function ValidatorOnSubmit()
{
	//empty dummy function
}

function ShowImg(imagefile)
{
	window.open("/PageTemplates/PopUp/ShowImage.aspx?img=" + imagefile + "&sessid="+sid,"ShowImage","alwaysRaised=1,toolbar=0,location=0,scrollbars=yes,menubar=0,resizable=0,status=0,width=550,height=550").focus();
}

//document.observe('keypress', function(e){ CheckKeyPress(e); });

var windowobjects = new Array(10);
			
function getMainWindow()
{
	var w = window.top;
	var i=0;
	//while(w.name != "" && w.name != null && w.name.charAt(0) != '_')
	while(w.name == "WomenOnline" || w.name == "MenOnline" || w.name =="Visitenkarte" || w.name =="UserSlogan" || w.name =="TVGewinnspiel" || (w.name.indexOf("ChatInvitation")>-1) || (w.name.indexOf("PrivateChat")>-1) || (w.name.indexOf("UserDisplay")>-1) || (w.name.indexOf("msg")>-1))
	{			
		windowobjects[i] = w;
		i++;
		w=w.opener.top.window;			
	}
	return w;
}

function OpenChatDialog(userid, nick)
{
    if(privatechatgui != null)
        privatechatgui.openChatDialog(userid, nick);
}

var adomain = document.domain.split('.'); if(adomain.length >= 2){ document.domain = adomain[adomain.length-2] + '.' + adomain[adomain.length-1]; }
