/*-------------------------------------------------------+
| Copyright © 2008-2010 Powered by .:MeF:.
+--------------------------------------------------------*/

    function in_array(what, where) {
    for(var i=0; i<where.length; i++)
        if(what == where[i])
            return true;
    return false;
    }
	
	function strip_tags(str){	
	return str.replace('/<\/?[^>]+>/gi', '');
    }
	
	function goto_url(url) {
	window.location.href=url;
    }
	
	function reg_guest_msg(title,text) {
	jAlert(text, title);
    }
	
	function select_photo(uid,aid,pid,konkurs) {
	
	if (aid == '' && pid == '') {
	var url = 'userid='+uid+'&konkurs_id='+konkurs; 
	var button = '';
	} else if (pid != '') {
	var url = 'photoid='+pid+'&konkurs_id='+konkurs;
    var button = '<input type="button" value="К списку альбомов" onclick="select_photo('+uid+',false,false,'+konkurs+'); return false;" class="button"/> <input type="button" value="К списку фотографий" onclick="select_photo('+uid+','+aid+',false,'+konkurs+'); return false;" class="button"/> <input type="button" value="Разместить фотографию" onclick="add_photo('+uid+','+aid+','+pid+','+konkurs+');" class="button"/>';
	} else { 
	var url = 'albumid='+aid+'&konkurs_id='+konkurs;
    var button = '<input type="button" value="К списку альбомов" onclick="select_photo('+uid+',false,false,'+konkurs+'); return false;" class="button"/>';	
	}
	
jWindow('<div align="center" style="width:560px;"><div align="center" style="max-height: 215px; overflow:auto;"><div id="content"><img src=\"../images/loader.gif\" alt=\"loading\" /></div></div></div>', 'Выибирите фотографию', '', button, '<input type="button" value="Закрыть" id="popup_cancel" class="button"/>');

jQuery('div#content').load('../includes/backend/select_photo.php?'+url);

    }
	
	function add_photo(uid,aid,pid,konkurs) {
	    jQuery.post('./includes/backend/select_photo.php?addphoto='+pid, { 'album': aid, 'konkurs_id': konkurs }, function(data) {
        
		jWindow('<div align="center" style="width:560px;"><div align="center" style="max-height: 215px; overflow:auto;"><div id="content"><img src=\"../images/loader.gif\" alt=\"loading\" /></div></div></div>', 'Выибирите фотографию', '', '', '<input type="button" value="Закрыть" id="popup_cancel" class="button"/>');

        jQuery('div#content').html(data);
	    });
	}
	
	function add_vote(uid,pid) {
	
	    jQuery.post('./includes/backend/select_photo.php?votephoto='+pid, '', function(data) {
        jQuery('div#result_votes').html(data);
	    });
	}
	
	function upload_photo(kid,step) {
	
	jQuery.post('./includes/backend/select_photo.php?uploadphoto='+kid+'&step='+step, '', function(data) {

	    jWindow('<div align="center" style="width:560px;"><div align="center" style="max-height: 215px; overflow:auto;"><div id="content"><img src=\"../images/loader.gif\" alt=\"loading\" /></div></div></div>', 'Выибирите фотографию', '', '', '<input type="button" value="Закрыть" id="popup_cancel" class="button"/>');
		
	jQuery('div#content').html(data);
	    });

	}
	
	function switch_tab_url(lid) {
	
	switch(lid) {
		case '11':
			var turl = 'news.php';
			break;
		case '12':
			var turl = 'turnirs.php';
			break;
		case '13':
			var turl = 'turnirs.php#reports';
			break;
		case '21':
			var turl = 'otels.php';
			break;
		case '23':
			var turl = 'turnir.php';
			break;
		case '31':
			var turl = 'gallery.php?view=photo&album=2';
			break;
		case '32':
			var turl = 'gallery.php?view=photo&album=3';
			break;
		case '33':
			var turl = 'people.php';
			break;
		case '34':
			var turl = 'forum/';
			break;
		case '41':
			var turl = 'gallery.php?view=photo';
			break;
		case '42':
			var turl = 'gallery.php?view=userphoto';
			break;
		case '43':
			var turl = 'gallery.php?view=video';
			break;
		case '44':
			var turl = 'gallery.php?view=uservideo';
			break;
		  default: var turl = false;
		}
		
		return turl;
	}
