﻿
                function openFacebook() {
                    var url = 'http://www.facebook.com/share.php?u=' + encodeURIComponent(document.location).toString() + '&t=' + encodeURIComponent(document.title).toString();
                    var width = 650;
                    var height = 500;
                    openShareWindow(url, width, height);
                }

                function openTwitter() {
                    var url = 'http://twitter.com/home?status=' + encodeURIComponent(document.location).toString();
                    var width = 790;
                    var height = 500;
                    openShareWindow(url, width, height);
                }

                function openIwiw() {
                    var url = 'http://iwiw.hu/pages/share/share.jsp?u=' + encodeURIComponent(document.location).toString() + '&t=' + encodeURIComponent(document.title).toString();
                    var width = 625;
                    var height = 525;
                    openShareWindow(url, width, height);
                }

                function openShareWindow(Url, Width, Height) {
                    shareWindow = window.open(Url, '_blank', 'height=' + Height.toString() + ',width=' + Width.toString() + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no');
                    shareWindow.moveTo((screen.width - Width) / 2, (screen.height - Height) / 2);
                }

function openPlayer(videoId) {
    var w = new sodaAjaxWindow();
    w.height = 600;
    w.width = 660;
    w.caption = 'Video';
    createWindowFromUrl('../pages/player.aspx?videoId=' + videoId, w);
}

function processQuizResult(s) {
            var d = document.getElementById('content');
            if (d != null) {
                d.innerHTML = s;
            }
        }
        function processQuiz() {
            sendDataRequest('divQuiz', 'http://www.painbalance.org/quiz/process.aspx', true, processQuizResult)
        }
        function jumpQuiz() {
            sendDataRequest('divQuiz', 'http://www.painbalance.org/quiz/question.aspx', true, processQuizResult)
        }
        
        function allOfTheAbove(v,t) {
            if (v.toLowerCase() == 'true') {
                var d = document.getElementById('divQuiz');
                if (d != null) {
                    var coll = d.getElementsByTagName('INPUT');
                    if (coll != null) {
                        for (var i = 0; i < coll.length; i++) {
                            
                            switch (coll[i].type) {
                                case 'checkbox':
                                    if (coll[i].value != t.value) {
                                        coll[i].checked = false;
                                        coll[i].disabled = t.checked;
                                    }
                                    break;
                            }
                        }
                    }
                }
            }
        }

function createCalendar(controlName,p) {
    var initValue = '';
    var d = document.getElementById(controlName);
    if (d != null) initValue = d.value;
    var html = '<img src="' + p + 'media/images/calendar.jpg" border="0" align="absmiddle" hspace="3" style="CURSOR:pointer" title="Calendar" onClick="showCalendar(\'' + controlName + '\');"/><div id="layer' + controlName + '" style="display:none;position:absolute;width:200px;height:180px;"><iframe src="' + p + 'services/calendar.aspx?control=' + controlName + '&initValue=' + initValue + '" frameborder="0" width="220" height="200" marginheight="0" marginwidth="0" allowtransparency="true"></iframe></div>';
    document.write(html);
}
var previousControl = '';
function showCalendar(controlName) {
    var d = document.getElementById('layer' + controlName);
    if (d != null) {
        if (d.style.display == 'inline') d.style.display = 'none';
        else {
            var x = document.getElementById(previousControl);
            if (x != null) x.style.display = 'none';
            d.style.display = 'inline';
            previousControl = 'layer' + controlName;
        }
    }
}
function processSearch(c){
	var d = document.getElementById('ctl00_PageView_PageView1_contentdiv');
	if (d != null){
		d.innerHTML = c;
	}
	d = document.getElementById('pageTitle');
	if (d != null){
		d.innerHTML = 'Search Results';
	}
}

	function notifyUrl(u1,u2){
		var oWin = window.open('../pages/gettemplate.aspx?id=exit&u1=' + encodeURIComponent(u1) + '&u2=' + encodeURIComponent(u2), null, 'height=255,width=415,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
		oWin.focus();
	}      
  function MM_showHideLayers() { //v9.0
            var i, p, v, obj, args = MM_showHideLayers.arguments;
            for (i = 0; i < (args.length - 2); i += 3)
                with (document) if (getElementById && ((obj = getElementById(args[i])) != null)) {
                v = args[i + 2];
                if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v; }
                obj.visibility = v;
            }
        }
        function submenuBackgroundOn(obj) {
            document.getElementById(obj).setAttribute('previousColor',document.getElementById(obj).style.color);
            document.getElementById(obj).style.color = '#ffffff';
            document.getElementById(obj).style.backgroundColor = '#465f80';
        }
        function submenuBackgroundOff(obj) {
            
            document.getElementById(obj).style.color = document.getElementById(obj).getAttribute('previousColor');
            document.getElementById(obj).style.backgroundColor = '';
        }
        function submitenter(myfield, e, u ) {
	   var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return true;

            if (keycode == 13) {
                searchForm(u + 'pages/search.aspx');
                return false;
            }
            else
                return true;
        }
        function submitlogin(myfield, e, u) {
            var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return true;

            if (keycode == 13) {
                loginForm(u + 'pages/login.aspx');
                return false;
            }
            else
                return true;
        }

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) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 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];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function fnOpenWindow(sURL,w_width,w_height){
	var oWin = window.open(sURL,'_blank','height='+ w_height + ',width=' + w_width + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no');	
}

function fnPopUp(url,name1,features){
	var oWin = window.open(url,null,features);	
}
	/*
		Name: fnSoapSubmit
		Purpose: submit data
	*/
	function fnSoapSubmit(formname){
		var oWin = window.open('about:blank','soapres','height=200,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
		var oForm = document.forms[formname];
		oForm.target = 'soapres';
		oForm.submit();
	}

/*
 Activity Tracker
*/
function activityTracker(){
    openAsyncUrl2('../services/status.aspx');
    setTimeout('activityTracker()',60000);
}
function showGalleryImage(url,w,h){
    var win = new sodaAjaxWindow();
    win.caption = 'Gallery';
    win.height = parseInt(h) + 10;
    win.width = parseInt(w) + 10;    
    createWindowFromUrl('../services/image.aspx?'+url,win);
}

function addComment(t){
    var win = new sodaAjaxWindow();
    win.caption = 'Add Comment';
    win.height = 350;
    win.width = 350;    
    createWindowFromUrl('../services/popup_comment.aspx?t=' + t,win);
}
function sendComment(){
    sendDataRequest('formPlaceholder','../services/addcomment.aspx',false);
    closeAjaxWindow();
    window.location.reload();
}
function addMessage(t,n){
    var win = new sodaAjaxWindow();
    win.caption = 'Add Message';
    win.height = 380;
    win.width = 350;    
    createWindowFromUrl('../services/popup_message.aspx?t=' + t + '&n=' + n,win);
}
function addFriend(t,n,type){
    var win = new sodaAjaxWindow();
    win.caption = 'Add Message';
    win.height = 380;
    win.width = 350;    
    createWindowFromUrl('../services/popup_friend.aspx?t=' + t + '&n=' + n +'&type=' + type,win);
}
function sendFriend(){
    sendDataRequest('formPlaceholder','../services/addfriend.aspx',false);
    closeAjaxWindow();
    window.location.reload();
}
function showMessage(id){
    var win = new sodaAjaxWindow();
    win.caption = 'Show Message';
    win.height = 380;
    win.width = 350;    
    createWindowFromUrl('../services/popup_messageview.aspx?id=' +id,win);
}
function replyMessage(id){
    closeAjaxWindowSimple();
    var win = new sodaAjaxWindow();
    win.caption = 'Edit Message';
    win.height = 380;
    win.width = 350;    
    createWindowFromUrl('../services/popup_message.aspx?id=' +id,win);
}
function sendMessage(){
    sendDataRequest('formPlaceholder','../services/addmessage.aspx',true);
    closeAjaxWindow();
}
function addVote(s,t){
    var win = new sodaAjaxWindow();
    win.caption = 'Add Vote';
    win.height = 250;
    win.width = 300;    
    createWindowFromUrl('../services/popup_vote.aspx?t=' + t,win);
}
function sendVote(){
    sendDataRequest('formPlaceholder','../services/vote.aspx',true);
    closeAjaxWindow();
}
function deleteImage(id){
    if (confirm('Biztos, hogy le akarod törölni ezt a képet?')){
        postUrl('../services/deleteimage.aspx','id=' + id);
        window.location.reload();
    }
}
function uploadImage(){
    var win = new sodaAjaxWindow();
    win.caption = 'Upload Image';
    win.height = 340;
    win.width = 400;    
    createWindowInFrame('upload.aspx',win);    
}
function finishUploadImage(){
    self.location.reload();
}
function deleteVideo(id){
    if (confirm('Biztos, hogy le akarod törölni ezt a videót?')){
        postUrl('../services/deletevideo.aspx','id=' + id);
        window.location.reload();
    }
}
function deleteComment(id){
    if (confirm('Biztos, hogy le akarod törölni ezt a véleményt?')){
        postUrl('../services/deletecomment.aspx','id=' + id);
        window.location.reload();
    }
}
function uploadVideo(id){
    var win = new sodaAjaxWindow();
    win.caption = 'Upload Video';
    win.height = 300;
    win.width = 400;    
    createWindowInFrame('uploadvideo.aspx?id=' + id,win);    
}
function deleteUser(){
    if (fnFormValidate()){
        return confirm('Biztos, hogy le akarod törölni a profilodat?');
    }else{
        return false;
    }
}
function deleteMessage(id,t){
    if (confirm('Biztos, hogy le akarod törölni az üzenetet?')){
        postUrl('../services/deletemessage.aspx','id=' + id + '&type=' + t);
        window.location.reload();
    }
}
function searchForm(action){
    var d = document.getElementById('searchform');
    if (d != null){
        d.action = action;
        d.submit();
    }
}
function loginForm(action){
    var d = document.getElementById('loginForm');
    if (d != null){
        d.action = action;
        d.submit();
    }
}
    function openJob(id){
        var win = new sodaAjaxWindow();
        win.caption = 'Show Open position';
        win.height = 600;
        win.width = 600;    
        createWindowInFrame('../tmc/jobview.aspx?id=' + id,win);    
    }
function step(currObject, nextObject, length){
	var _current = document.getElementById(currObject);
	var _next = document.getElementById(nextObject)
	if(_current.value.length == length){
		_next.select();
		_next.focus();
	}
}
            function wrongAccount(){
                alert('Hibás felhasználói név vagy jelszó!')
            }
